제출 #674019

#제출 시각아이디문제언어결과실행 시간메모리
674019CookieMiners (IOI07_miners)C++14
100 / 100
164 ms111948 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define vt vector #define se second #define fi first #define pb push_back int n; int aa[100001]; int d[100001][4][4][4][4]; int get(int p){ if(p == 0)return(0); return(1 << (p - 1)); } int solve(int id, int a, int b, int c, int dd){ if(id == n)return(0); if(d[id][a][b][c][dd] != -1)return(d[id][a][b][c][dd]); int crmask = (get(a)) | (get(b)) | (get(aa[id])); crmask = max(crmask, 1 << (aa[id] - 1)); int cr = 0; cr = max(cr, solve(id + 1, b, aa[id], c, dd) + __builtin_popcount(crmask)); crmask = (get(c)) | (get(dd)) | (get(aa[id])); cr = max(cr, solve(id + 1, a, b, dd, aa[id]) + __builtin_popcount(crmask)); d[id][a][b][c][dd] = cr; return(cr); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0; i < n; i++){ char c; cin >> c; if(c == 'M')aa[i] = 1; else if(c == 'B')aa[i] = 2; else aa[i] = 3; } memset(d, -1, sizeof(d)); solve(0, 0, 0, 0, 0); cout << d[0][0][0][0][0]; return 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...