Submission #1117447

#TimeUsernameProblemLanguageResultExecution timeMemory
1117447trinhvtuanMiners (IOI07_miners)C++17
0 / 100
55 ms1100 KiB
#include <bits/stdc++.h> using namespace std; int c,d,x,y,z,n,kq; int i,j,k; typedef pair<int,int>i2; string s; int a[200005],dp[3][4][4][4][4]; int main() { // freopen("MINERS.INP", "r" ,stdin); // freopen("MINERS.OUT", "w" ,stdout); // freopen("tongab.inp", "r" ,stdin); // freopen("tongab.txt", "w" ,stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; cin>>s; s='0'+s; for (int i=1;i<=n;i++) if (s[i]=='M') a[i]=1; else if (s[i]=='B') a[i]=2; else a[i]=3; for (int rep=1;rep<=n;rep++) { x=1; y=0; if (rep>1) k=1; else k=0; for (int x1=0;x1<=3;x1++) for (int x2=0;x2<=3;x2++) for (int y1=0;y1<=3;y1++) for (int y2=0;y2<=3;y2++) { if (dp[y][x1][x2][y1][y2]==0 && rep>1) continue; if (rep==1 && (x1!=0 || x2!=0 || y1!=0 || y2!=0)) continue; vector<int>b; int d=0; b.push_back(x1); b.push_back(x2); b.push_back(a[rep]); sort(b.begin(),b.end()); d=1; for (int i=1;i<b.size();i++) if (b[i]!=b[i-1]) d++; if (b[0]==0) d--; c=dp[y][x1][x2][y1][y2]+d; dp[x][x2][a[rep]][y1][y2]=max(dp[x][x2][a[rep]][y1][y2],c); b.clear(); b.push_back(y1); b.push_back(y2); b.push_back(a[rep]); sort(b.begin(),b.end()); d=1; for (int i=1;i<b.size();i++) if (b[i]!=b[i-1]) d++; if (b[0]==0) d--; c=dp[y][x1][x2][y1][y2]+d; dp[x][x1][x2][y2][a[rep]]=max(dp[x][x1][x2][y2][a[rep]],c); b.clear(); } for (int x1=0;x1<=3;x1++) for (int x2=0;x2<=3;x2++) for (int y1=0;y1<=3;y1++) for (int y2=0;y2<=3;y2++) { if (dp[y][x1][x2][y1][y2]==0 && rep>1) continue; if (rep==1 && (x1!=0 || x2!=0 || y1!=0 || y2!=0)) continue; dp[y][x1][x2][y1][y2]=dp[x][x1][x2][y1][y2]; if (rep==n) kq=max(kq,dp[y][x1][x2][y1][y2]); dp[x][x1][x2][y1][y2]=0; } } cout<<kq; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for (int i=1;i<b.size();i++)
      |                          ~^~~~~~~~~
miners.cpp:49:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for (int i=1;i<b.size();i++)
      |                          ~^~~~~~~~~
#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...