Submission #1008247

#TimeUsernameProblemLanguageResultExecution timeMemory
1008247vjudge1Miners (IOI07_miners)C++17
100 / 100
694 ms63932 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define ll long long #define int long long const long long inf=1e18; const int MOD=1e9+7; const int N=1e5+1; int dp[N][3][3][3][3];//M=0 F1 B=2 signed main() { int n; cin>>n; string s; cin>>s; s='#'+s; int ans=0; for(int i=1;i<=n;i++){ int x=0; if(s[i]=='F')x=1; if(s[i]=='B')x=2; for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ for(int u=0;u<3;u++){ int score; set<int> a={x,j,k}; score=a.size(); dp[i][k][x][l][u]=max(dp[i][k][x][l][u],dp[i-1][j][k][l][u]+score); a={x,l,u}; score=a.size(); dp[i][j][k][u][x]=max(dp[i][j][k][u][x],dp[i-1][j][k][l][u]+score); ans=max({ans,dp[i][k][x][l][u],dp[i][j][k][u][x]}); } } } } } cout<<ans-6; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...