제출 #428387

#제출 시각아이디문제언어결과실행 시간메모리
428387ponkungMiners (IOI07_miners)C++14
84 / 100
1578 ms460 KiB
#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); }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int main()':
miners.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     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...