# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
862499 |
2023-10-18T11:07:11 Z |
JakobZorz |
Miners (IOI07_miners) |
C++14 |
|
125 ms |
98900 KB |
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second
int n;
string str;
int get_val(int a,int b,int c){
int res=1;
if(a==b||b==c||a==c)
res=2;
if(a==b&&b==c)
res=3;
return res;
}
bool dpt[4][4][4][4][100000];
int dp[4][4][4][4][100000];
int get(int m1,int m2,int m3,int m4,int i){
if(i==n)
return 0;
if(dpt[m1][m2][m3][m4][i])
return dp[m1][m2][m3][m4][i];
int curr=0;
if(str[i]=='M')
curr=1;
if(str[i]=='B')
curr=2;
if(str[i]=='F')
curr=3;
int r1=get(m2,curr,m3,m4,i+1)+get_val(m1,m2,curr);
int r2=get(m1,m2,m4,curr,i+1)+get_val(m1,m2,curr);
dpt[m1][m2][m3][m4][i]=true;
dp[m1][m2][m3][m4][i]=max(r1,r2);
return max(r1,r2);
}
int main(){
ios::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin>>n;
cin>>str;
cout<<get(0,0,0,0,0)<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
35420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
38236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
37468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
38348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
29276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
29276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
30812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
28252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
43868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
52308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
78596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
125 ms |
98900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |