# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011339 |
2024-06-30T11:03:53 Z |
kaopj |
Miners (IOI07_miners) |
C++17 |
|
1500 ms |
41196 KB |
#include <iostream>
#include <vector>
#define lgm cin.tie(0)->sync_with_stdio(0);
using namespace std;
#define int long long
signed main() {
lgm;
int n;
cin >> n;
string c;
cin >> c;
auto dfs = [&] (auto dfs,int p,vector<char> a,vector<char> b)->int {
vector<char> ua=a,ub=b;
int sa=0,sb=0;
bool hm=0,hb=0,hf=0;
ua[0]=ua[1];
ua[1]=ua[2];
ua[2]=c[p];
ub[0]=ub[1];
ub[1]=ub[2];
ub[2]=c[p];
for (int i=0;i<3;i++) {
if (ua[i] == 'M') {
sa+=1-hm;
hm=1;
} else if (ua[i] == 'B') {
sa+=1-hb;
hb=1;
} else if (ua[i] == 'F') {
sa+=1-hf;
hf=1;
}
}
hm=0; hb=0; hf=0;
for (int i=0;i<3;i++) {
if (ub[i] == 'M') {
sb+=1-hm;
hm=1;
} else if (ub[i] == 'B') {
sb+=1-hb;
hb=1;
} else if (ub[i] == 'F') {
sb+=1-hf;
hf=1;
}
}
if (p == n-1) {
return max(sa,sb);
}
return max(sa+dfs(dfs,p+1,ua,b),sb+dfs(dfs,p+1,a,ub));
};
cout << dfs(dfs,0,{' ',' ',' '},{' ',' ',' '});
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1564 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1547 ms |
860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1529 ms |
2428 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1538 ms |
4440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1548 ms |
10584 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1567 ms |
31068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1564 ms |
41196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |