제출 #414632

#제출 시각아이디문제언어결과실행 시간메모리
414632Christopher_RdzMiners (IOI07_miners)C++14
100 / 100
192 ms100884 KiB
#include <bits/stdc++.h> using namespace std; int n; int food[100002]; char s; int dp[100002][4][4][4][4]; int costo(int a, int b, int c){ int tot = 1; if (a != b and !(a == 0 or b == 0)) tot++; if (a != c and b != c and !(b == 0 or c == 0)) tot++; return tot; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; i++){ cin >> s; if (s == 'M') food[i] = 1; if (s == 'F') food[i] = 2; if (s == 'B') food[i] = 3; } for (int i = n - 1; i >= 0; i--){ for (int x1 = 0; x1 < 4; x1++){ for (int x2 = 0; x2 < 4; x2++){ for (int y1 = 0; y1 < 4; y1++){ for (int y2 = 0; y2 < 4; y2++){ int aux = costo(food[i], x1, x2); int c1 = 0, c2 = 0; c1 = dp[i + 1][food[i]][x1][y1][y2] + aux; aux = costo(food[i], y1, y2); c2 = dp[i + 1][x1][x2][food[i]][y1] + aux; dp[i][x1][x2][y1][y2] = max(c1, c2); } } } } } cout << dp[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...