Submission #95244

#TimeUsernameProblemLanguageResultExecution timeMemory
95244easruiMiners (IOI07_miners)C++14
100 / 100
127 ms668 KiB
#include <bits/stdc++.h> using namespace std; int dec(int a, int b, int c) { if(a==0){ if(b==0) return 1; if(b==c) return 1; return 2; } if(a==b){ if(a==c) return 1; return 2; } if(a==c || b==c) return 2; return 3; } int main() { int D[16][16][2], N, val, a1, a2, b1, b2, ans = 0; string S; cin >> N >> S; for(int i=0; i<16; i++){ for(int j=0; j<16; j++){ D[i][j][0] = D[i][j][1] = INT_MIN; } } D[0][0][1] = 0; for(int i=0; i<N; i++){ if(S[i] == 'M') val = 1; if(S[i] == 'B') val = 2; if(S[i] == 'F') val = 3; for(int j=0; j<16; j++){ for(int k=0; k<16; k++){ a2 = j%4; a1 = j/4; b2 = k%4; b1 = k/4; D[a2*4+val][k][i%2] = max(D[a2*4+val][k][i%2],D[j][k][(i+1)%2] + dec(a1,a2,val)); D[j][b2*4+val][i%2] = max(D[j][b2*4+val][i%2],D[j][k][(i+1)%2] + dec(b1,b2,val)); } } } for(int i=0; i<16; i++){ for(int j=0; j<16; j++){ ans = max(ans,D[i][j][(N-1)%2]); } } cout << ans; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:12:9: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if(a==c) return 1;
         ^~
miners.cpp:21:26: note: 'val' was declared here
     int D[16][16][2], N, val, a1, a2, b1, b2, ans = 0;
                          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...