제출 #1086232

#제출 시각아이디문제언어결과실행 시간메모리
1086232pudelosMiners (IOI07_miners)C++17
100 / 100
77 ms516 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i=a; i<=b; ++i) #define gc getchar_unlocked #define V vector int n, w; int daj[4][4][4]; int main() { FOR(a, 0, 3) FOR(b, 0, 3) FOR(c, 0, 3) { V<int> all = {a, b, c}; stable_sort(all.begin(), all.end()); FOR(i, 0, 2) { if(all[i]==0 || (i>=1&&all[i]==all[i-1])) continue; daj[a][b][c]++; } } V<V<int>> stary(16, V<int>(16, -1e9)); stary[0][0]=0; cin>>n; gc(); FOR(i, 0, n-1) { char c = gc(); int a=1; if(c=='M') a=2; if(c=='F') a=3; V<V<int>> nowy(16, V<int>(16, -1e9)); nowy[0][0]=0; FOR(s1, 0, 15) FOR(s2, 0, 15) { nowy[(s1%4)*4+a][s2]=max(nowy[(s1%4)*4+a][s2], stary[(s1/4*4)+(s1%4)][s2]+daj[s1/4][s1%4][a]); nowy[s1][(s2%4)*4+a]=max(nowy[s1][(s2%4)*4+a], stary[s1][(s2/4*4)+(s2%4)]+daj[s2/4][s2%4][a]); } swap(stary, nowy); } int w=0; FOR(a, 0, 15) FOR(b, 0, 15) w=max(w, stary[a][b]); cout << w << '\n'; }
#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...