Submission #449684

#TimeUsernameProblemLanguageResultExecution timeMemory
449684CyberSleeperMiners (IOI07_miners)C++14
100 / 100
289 ms114144 KiB
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) #define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl #define fi first #define se second #define mp make_pair #define pb push_back #define ll long long #define ull unsigned long long #define ld long double #define pld pair<ld, ld> #define pli pair<ld, int> #define pii pair<int, int> #define pis pair<int, string> #define pl pair<ll, ll> #define nl '\n' using namespace std; int N, vis[100007][4][4][4][4], A[100007]; string S, food="MFB", choice[]={"FB", "MB", "MF", "BF", "BM", "FM"}; vector<int> loc[3]; int DP(int loc, int M11, int M12, int M21, int M22){ if(loc>=N) return 0; int &ret=vis[loc][M11][M12][M21][M22], cnt=0; if(ret==-1){ bool ada[4]={0, 0, 0, 0}; ada[M11]=ada[M12]=ada[A[loc]]=1; for(int i=0; i<3; i++) cnt+=ada[i]; ret=max(ret, cnt+DP(loc+1, M12, A[loc], M21, M22)); ada[0]=ada[1]=ada[2]=cnt=0; ada[M21]=ada[M22]=ada[A[loc]]=1; for(int i=0; i<3; i++) cnt+=ada[i]; ret=max(ret, cnt+DP(loc+1, M11, M12, M22, A[loc])); } return ret; } int main(){ fastio; memset(vis, -1, sizeof(vis)); cin >> N >> S; for(int i=0; i<N; i++){ for(int j=0; j<3; j++){ if(S[i]==food[j]){ A[i]=j; loc[j].pb(i); } } } cout << DP(0, 3, 3, 3, 3); }

Compilation message (stderr)

miners.cpp: In function 'int DP(int, int, int, int, int)':
miners.cpp:32:33: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   32 |         ada[0]=ada[1]=ada[2]=cnt=0;
      |                              ~~~^~
#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...