# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739247 |
2023-05-10T09:02:33 Z |
Toxtaq |
Miners (IOI07_miners) |
C++17 |
|
1500 ms |
429924 KB |
#include<bits/stdc++.h>
using namespace std;
int n;
string s; /// M-1, B-2, F-3
long long table[100001][2][4][4][4][4];
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 != 0)st.insert(last11);
if(last12 != 0)st.insert(last12);
last12 = last11;
last11 = s[indx];
}
else{
if(last21 != 0)st.insert(last21);
if(last22 != 0)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;
for(int i = 0;i < n;++i){
for(int j = 0;j < 2;++j){
for(int l = 0;l < 4;++l){
for(int r = 0;r < 4;++r){
for(int k = 0;k < 4;++k){
for(int z = 0;z < 4;++z){
table[i][j][l][r][k][z] = -1e18;
}
}
}
}
}
}
cout << max(rec(0, 1, 0, 0, 0, 0), rec(0, 2, 0, 0, 0, 0));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1593 ms |
340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1568 ms |
4564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1576 ms |
21516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1584 ms |
43220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1579 ms |
106828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1575 ms |
316932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1587 ms |
429924 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |