Submission #428400

#TimeUsernameProblemLanguageResultExecution timeMemory
428400ponkungMiners (IOI07_miners)C++14
100 / 100
191 ms512 KiB
#include<bits/stdc++.h> using namespace std; int n,dp[2][4][4][4][4],val,mx=0,hsh[4],kmp; char str[100005]; 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++) { memset(hsh,0,sizeof hsh); hsh[j]=1; hsh[k]=1; hsh[val]=1; kmp=0; for(int d=1;d<=3;d++) { kmp+=hsh[d]; } dp[i%2][k][val][l][c]=max(dp[i%2][k][val][l][c],dp[1-(i%2)][j][k][l][c]+kmp); memset(hsh,0,sizeof hsh); hsh[l]=1; hsh[c]=1; hsh[val]=1; kmp=0; for(int d=1;d<=3;d++) { kmp+=hsh[d]; } dp[i%2][j][k][c][val]=max(dp[i%2][j][k][c][val],dp[1-(i%2)][j][k][l][c]+kmp); } } } } /*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 (stderr)

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