# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
584117 |
2022-06-26T19:54:05 Z |
AtinaR |
Miners (IOI07_miners) |
C++14 |
|
1500 ms |
210256 KB |
#include <bits/stdc++.h>
using namespace std;
const long long MAX=100001;
long long n;
string s;
long long dp[MAX][4][4][4][4];
long long check(long long a, long long b, long long c)
{
set<long long> st;
if(a!=0)st.insert(a);
if(b!=0)st.insert(b);
if(c!=0)st.insert(c);
return st.size();
}
long long rek(long long i, long long L1,long long L2, long long R1, long long R2)
{
if(i==n)
{
return 0;
}
long long res=0;
if(dp[i][L1][R1][L2][R2]!=-1)return dp[i][L1][L2][R1][R2];
long long tmp;
if(s[i]=='M')
{
tmp=1;
}
else if(s[i]=='B')
{
tmp=2;
}
else
{
tmp=3;
}
res=rek(i+1,tmp,L1, R1, R2)+check(tmp,L1,L2);
res=max(res,rek(i+1,L1,L2,tmp,R1)+check(tmp,R1,R2));
return dp[i][L1][L2][R1][R2]=res;
}
int32_t main()
{
cin>>n;
cin>>s;
memset(dp,-1,sizeof(dp));
cout<<rek(0,0,0,0,0)<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
200664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
200604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
200596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
200652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
200676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
200656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1604 ms |
200668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1567 ms |
201164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1584 ms |
201596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1608 ms |
202972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1610 ms |
207812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1597 ms |
210256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |