import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; /** * Solution to The Paladin * * @author vanb */ public class paladin_vanb { /** Input. */ private static Scanner sc; /** Output. */ private static PrintStream ps; private static final int MAX = 1000000; /** * Do it! */ private void doit() { int n = sc.nextInt(); int k = sc.nextInt(); int k2 = k%2==0 ? k/2 : k/2+1; // costs[i][j] is the cost of letter pair (i+'a')(j+'a') int costs[][] = new int[26][26]; // best[i][j] is the best you can do with a string of length j+1 ending in letter (i+'a') int best[][] = new int[26][k2]; // Init the arrays for( int i=0; i<26; i++ ) { Arrays.fill( costs[i], MAX ); Arrays.fill( best[i], MAX ); best[i][0] = 0; } // Read the letter pairs & costs for( int i=0; i