# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428387 | 2021-06-15T11:17:37 Z | ponkung | Miners (IOI07_miners) | C++14 | 1500 ms | 460 KB |
#include<bits/stdc++.h> using namespace std; int n,dp[2][4][4][4][4],val,mx=0; char str[100005]; set<int> s; int main() { for(int j=0;j<4;j++) { for(int k=0;k<4;k++) { for(int l=0;l<4;l++) { for(int c=0;c<4;c++) { dp[0][j][k][l][c]=-1e9; } } } } dp[0][0][0][0][0]=0; scanf("%d%s",&n,str+1); for(int i=1;i<=n;i++) { //printf("%d\n",i); for(int j=0;j<4;j++) { for(int k=0;k<4;k++) { for(int l=0;l<4;l++) { for(int c=0;c<4;c++) { dp[i%2][j][k][l][c]=-1e9; } } } } if(str[i]=='M') { val=1; }else if(str[i]=='F') { val=2; }else { val=3; } for(int j=0;j<4;j++) { for(int k=0;k<4;k++) { for(int l=0;l<4;l++) { for(int c=0;c<4;c++) { if(j!=0) { s.insert(j); } if(k!=0) { s.insert(k); } s.insert(val); dp[i%2][k][val][l][c]=max(dp[i%2][k][val][l][c],dp[1-(i%2)][j][k][l][c]+(int)s.size()); s.clear(); if(l!=0) { s.insert(l); } if(c!=0) { s.insert(c); } s.insert(val); dp[i%2][j][k][c][val]=max(dp[i%2][j][k][c][val],dp[1-(i%2)][j][k][l][c]+(int)s.size()); s.clear(); } } } } /*for(int j=0;j<4;j++) { for(int k=0;k<4;k++) { for(int l=0;l<4;l++) { for(int c=0;c<4;c++) { printf("%d %d %d %d %d\n",j,k,l,c,dp[i%2][j][k][c][l]); } } } }*/ } for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { for(int k=0;k<4;k++) { for(int l=0;l<4;l++) { mx=max(mx,dp[n%2][i][j][k][l]); } } } } printf("%d\n",mx); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 240 ms | 292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 415 ms | 296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1051 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1578 ms | 332 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1573 ms | 460 KB | Time limit exceeded |