Submission #239049

#TimeUsernameProblemLanguageResultExecution timeMemory
239049T0p_Miners (IOI07_miners)C++14
100 / 100
177 ms512 KiB
#include<bits/stdc++.h> using namespace std; long long dp[2][4][4][4][4]; map<char, int> mp; int cost(int a, int b, int c) { int ret = 0; if(a == 1 || b == 1 || c == 1) ret++; if(a == 2 || b == 2 || c == 2) ret++; if(a == 3 || b == 3 || c == 3) ret++; return ret; } int main() { mp['M'] = 1; mp['B'] = 2; mp['F'] = 3; for(int i=0 ; i<2 ; i++) for(int j=0 ; j<4 ; j++) for(int k=0 ; k<4 ; k++) for(int l=0 ; l<4 ; l++) for(int m=0 ; m<4 ; m++) dp[i][j][k][l][m] = -1e18; dp[0][0][0][0][0] = 0; int n; scanf(" %d",&n); for(int i=1 ; i<=n ; i++) { char c; scanf(" %c",&c); int z = mp[c]; for(int j=0 ; j<4 ; j++) for(int k=0 ; k<4 ; k++) for(int l=0 ; l<4 ; l++) for(int m=0 ; m<4 ; m++) { dp[i%2][k][z][l][m] = max(dp[i%2][k][z][l][m], dp[(i-1)%2][j][k][l][m] + cost(j, k, z)); dp[i%2][j][k][m][z] = max(dp[i%2][j][k][m][z], dp[(i-1)%2][j][k][l][m] + cost(l, m, z)); } } long long ans = -1e18; for(int j=0 ; j<4 ; j++) for(int k=0 ; k<4 ; k++) for(int l=0 ; l<4 ; l++) for(int m=0 ; m<4 ; m++) ans = max(ans, dp[n%2][j][k][l][m]); printf("%lld\n",ans); return 0; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d",&n);
  ~~~~~^~~~~~~~~~
miners.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",&c);
   ~~~~~^~~~~~~~~~
#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...