Submission #263750

#TimeUsernameProblemLanguageResultExecution timeMemory
263750updown1Miners (IOI07_miners)C++17
Compilation error
0 ms0 KiB
import java.util.*; import java.io.*; public class miners { public static void main(String[] args) throws IOException{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); 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}; int[][] store = new int[100][5]; int[][] go = new int[13][5]; for (int i=0; i<100; i++) for (int j=0; j<5; j++) store[i][j] = value(i, j); for (int i=0; i<13; i++) for (int j=0; j<5; j++) go[i][j] = (combos[i]%10)*10 + j; //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; else if(food[i-1].equals("F"))f = 2; else f = 3; for(int s1 = 0; s1 < 13; s1++){ int ns1 = go[s1][f]; int vs1 = store[combos[s1]][f]; for(int s2 = 0; s2 < 13; s2++){ int ns2 = go[s2][f]; dp[i][combos[s1]][combos[s2]] = Math.max(dp[i+1][ns1][combos[s2]] + vs1, dp[i+1][combos[s1]][ns2] + store[combos[s2]][f]); //System.out.println("(" + i + ", " + combos[s1] + ", " + combos[s2] + ") = " + dp[i][combos[s1]][combos[s2]]); } } } System.out.println(dp[1][0][0]); } public static int value(int state, int 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++; } 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 {
      | ^~~~~~