# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1008061 |
2024-06-26T07:07:39 Z |
vjudge1 |
Miners (IOI07_miners) |
C++17 |
|
61 ms |
100672 KB |
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<ll,ll>
const ll mxN = 3e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;
int dp[mxN][4][4][4][4];
signed main(){
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int n;
string s = "#",s1;
cin >>n>>s1;
s += s1;
int ans = 0;
for(int i = 1;i <= n;i++){
int num = (s[i] == 'M' ? 1 : (s[i] == 'B' ? 2 : 3));
for(int a = 1;a < 4;a++){
for(int b = 1; b < 4;b++){
for(int c = 1;c < 4;c++){
for(int d = 1;d < 4;d++){
if(dp[i - 1][a][b][c][d] == -1) continue;
int val;
if(num != a && a != b && a && b) val = 3;
else if(num != a && (a == b || !b)&& a) val = 2;
else if((num == a || !a) && a != b && b) val = 2;
else val = 1;
// cout<<i<<' '<<num<<' '<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<val<<'\n';
dp[i][num][a][c][d] =max(dp[i][num][a][c][d], dp[i - 1][a][b][c][d] + val);
if(num != c && c != d && c && d) val = 3;
else if(num != c && (c == d || !d) && c) val = 2;
else if((num == c || !c) && c != d && d) val = 2;
else val = 1;
// cout<<i<<' '<<num<<' '<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<val<<'\n';
dp[i][a][b][num][c] = max(dp[i][a][b][num][c],dp[i - 1][a][b][c][d] + val);
ans = max({ans,dp[i][num][a][c][d],dp[i][a][b][num][c]});
}
}
}
}
// cout<<ans<<' ';
}
cout<<ans - 6;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
10332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
25432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
75600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
100672 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |