Submission #377130

#TimeUsernameProblemLanguageResultExecution timeMemory
377130kevinxiehkMiners (IOI07_miners)C++17
100 / 100
54 ms620 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second #define ick cout<<"ickbmi32.9\n" using namespace std; int val(int a,int b){ if(a==9)return 1; if(a/3==b&&a%3==b)return 1; if(a/3==a%3||a/3==b||a%3==b)return 2; return 3; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); unordered_map<char,int>dis; dis['M']=0;dis['F']=1;dis['B']=2; int n;cin>>n; int dp[2][10][10]; memset(dp,0,sizeof dp); string s;cin>>s; for(int i=n-1;i>=0;i--){ int t=i%2,b=dis[s[i]]; for(int j=0;j<10;j++){ for(int k=0;k<10;k++){ int n1,n2; if(j==9)n1=b*4; else n1=(j%3)*3+b; if(k==9)n2=b*4; else n2=(k%3)*3+b; dp[t][j][k]=max(dp[t^1][n1][k]+val(j,b),dp[t^1][j][n2]+val(k,b)); } } } cout<<dp[0][9][9]<<'\n'; return 0; }
#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...