Submission #992681

# Submission time Handle Problem Language Result Execution time Memory
992681 2024-06-05T00:50:04 Z ezzzay Training (IOI07_training) C++14
0 / 100
35 ms 98968 KB
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
const int N=1e5+5;
int dp[4][4][4][4][N];
map<char,int>mp;
signed main(){
    mp['M']=1;
    mp['F']=2;
    mp['B']=3;
    int n;
    string s;
    cin>>n>>s;
    int h=mp[s[0]];
    
    for(int i=0;i<n;i++){
    	for(int x1=0;x1<4;x1++){
    		for(int y1=0;y1<4;y1++){
    			for(int x2=0;x2<4;x2++){
    				for(int y2=0;y2<4;y2++){
    					dp[x1][y1][x2][y2][i]=-1e9;
					}
				}
			}
		}
	}
    dp[0][h][0][0][0]=1;
    dp[0][0][0][h][0]=1;
    for(int i=1;i<n;i++){
    	int k=mp[s[i]];
    	for(int x1=0;x1<4;x1++){
    		for(int y1=0;y1<4;y1++){
    			for(int x2=0;x2<4;x2++){
    				for(int y2=0;y2<4;y2++){
    					set<int>st;
    					if(x1!=0)st.insert(x1);
    					if(y1!=0)st.insert(y1);
    					st.insert(k);
    					int h=st.size();
    					dp[y1][k][x2][y2][i]=max(dp[y1][k][x2][y2][i],dp[x1][y1][x2][y2][i-1]+h);
    					
    					st.clear();
    					if(x2!=0)st.insert(x2);
    					if(y2!=0)st.insert(y2);
    					st.insert(k);
    					h=st.size();
    					dp[x1][y1][y2][k][i]=max(dp[x1][y1][y2][k][i],dp[x1][y1][x2][y2][i-1]+h);
    					
					}
				}
			}
		}
	}
	int mx=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				for(int l=0;l<4;l++){
					mx=max(mx,dp[i][j][k][l][n-1]);
				}
			}
		}
	}
	cout<<mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 98904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 98904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 98908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 98904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 98908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 98908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 98968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 98908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 98904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 98904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 98940 KB Output isn't correct
2 Halted 0 ms 0 KB -