Submission #263651

#TimeUsernameProblemLanguageResultExecution timeMemory
263651updown1Miners (IOI07_miners)C++17
Compilation error
0 ms0 KiB
import java.util.*; import java.io.*; public class miners { static int[][] store = new int[100][5]; public static void main(String[] args) throws IOException{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int N = Integer.parseInt(bf.readLine()); String[] food = bf.readLine().split(""); int[][][] dp = new int[N+2][34][34]; int[] combos = new int[]{0, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33}; for (int i=0; i<100; i++) for (int j=0; j<5; j++) store[i][j] = -1; //1 = Meat, 2 = Fish, 3 = Bread for(int i = 0; i < 13; i++){ for(int c = 0; c < 13; c++){ dp[N+1][combos[i]][combos[c]] = 0; } } for(int i = N; i > 0; i--){ int f = -1; if(food[i-1].equals("M"))f = 1; if(food[i-1].equals("F"))f = 2; if(food[i-1].equals("B"))f = 3; for(int s1 = 0; s1 < 13; s1++){ for(int s2 = 0; s2 < 13; s2++){ int ns1 = (combos[s1]%10)*10 + f; int ns2 = (combos[s2]%10)*10 + f; if(combos[s1] == 0)ns1 = f; if(combos[s2] == 0)ns2 = f; dp[i][combos[s1]][combos[s2]] = Math.max(dp[i+1][ns1][combos[s2]] + value(combos[s1], f), dp[i+1][combos[s1]][ns2] + value(combos[s2], f)); //System.out.println("(" + i + ", " + combos[s1] + ", " + combos[s2] + ") = " + dp[i][combos[s1]][combos[s2]]); } } } pw.println(dp[1][0][0]); pw.close(); } public static int value(int state, int f){ if (store[state][f] != -1) return store[state][f]; int s = -1; s = state*10 + f; int[] v = new int[10]; while(s != 0){ int num = s%10; s /= 10; v[num]++; } int ret = 0; for (int i=0; i<10; i++) { if (v[i] > 0) ret++; } store[state][f] = ret; return ret; } }

Compilation message (stderr)

miners.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
miners.cpp:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
miners.cpp:3:1: error: expected unqualified-id before 'public'
    3 | public class miners {
      | ^~~~~~