# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739243 |
2023-05-10T08:57:05 Z |
Toxtaq |
Miners (IOI07_miners) |
C++17 |
|
1500 ms |
29284 KB |
#include<bits/stdc++.h>
using namespace std;
int n;
string s; /// M-0, B-1, F-2
long long rec(int indx, int mine, int last11, int last12, int last21, int last22){
long long res = 0;
set<int>st;
if(indx == n)return 0;
if(mine == 1){
if(last11 != -1)st.insert(last11);
if(last12 != -1)st.insert(last12);
last12 = last11;
last11 = s[indx];
}
else{
if(last21 != -1)st.insert(last21);
if(last22 != -1)st.insert(last22);
last22 = last21;
last21 = s[indx];
}
st.insert(s[indx]);
res = st.size() + max(rec(indx + 1, 1, last11, last12, last21, last22), rec(indx + 1, 2, last11, last12, last21, last22));
return res;
}
int main()
{
cin >> n >> s;
cout << max(rec(0, 1, -1, -1, -1, -1), rec(0, 2, -1, -1, -1, -1));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1581 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1567 ms |
468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1564 ms |
1492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1575 ms |
3156 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1562 ms |
6740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1573 ms |
16440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1565 ms |
29284 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |