Submission #464044

#TimeUsernameProblemLanguageResultExecution timeMemory
464044dutchMiners (IOI07_miners)C++17
92 / 100
1576 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define F(z) for(int z=0; z<4; ++z) #define remax(x, y) x = max(x, y) #define fill(z) F(a) F(b) F(x) F(y) z[a][b][x][y] = -2e9 int cost(int a, int b, int c){ int m[3] = {a, b, c}; sort(m, m+3); return -(m[2] == 3) + (unique(m, m+3) - m); } int n, dp[4][4][4][4], c[4][4][4][4], ans; char inp; signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> n; fill(c); c[3][3][3][3] = 0; for(int i=0, j; i<n; ++i){ cin >> inp; j = (inp > 'B') + (inp > 'F'); swap(c, dp); fill(c); for(int k : {j, 3}) F(a) F(b) F(x) F(y){ remax(c[b][k][x][y], dp[a][b][x][y] + cost(a, b, k)); remax(c[a][b][y][k], dp[a][b][x][y] + cost(x, y, k)); remax(ans, c[a][b][x][y]); } } cout << ans; }
#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...