Submission #293350

#TimeUsernameProblemLanguageResultExecution timeMemory
293350HemimorMiners (IOI07_miners)C++14
100 / 100
158 ms688 KiB
#include <algorithm> #include <iostream> #include <iomanip> #include <numeric> #include <vector> #include <cmath> #include <queue> #include <set> #include <map> #define syosu(x) fixed<<setprecision(x) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<P,int> pip; typedef vector<pip> vip; const int inf=1<<30; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-8; const ll mod=1e9+7; const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1}; int f(int i,int j,int k){ if(j==3) j=i; if(k==3) k=i; if(i==j&&j==k) return 1; if(i==j||j==k||k==i) return 2; return 3; } int n,dp[4][4][4][4]; string s; int main(){ cin>>n>>s; 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++) dp[i][j][k][l]=-inf; dp[3][3][3][3]=0; for(auto c:s){ int v; if(c=='M') v=0; if(c=='F') v=1; if(c=='B') v=2; int DP[4][4][4][4]; 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++) DP[i][j][k][l]=-inf; 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++){ DP[v][i][k][l]=max(DP[v][i][k][l],dp[i][j][k][l]+f(v,i,j)); DP[i][j][v][k]=max(DP[i][j][v][k],dp[i][j][k][l]+f(v,k,l)); } swap(dp,DP); } int res=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++) res=max(res,dp[i][j][k][l]); cout<<res<<endl; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:40:2: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |  if(i==j&&j==k) return 1;
      |  ^~
miners.cpp:53:7: note: 'v' was declared here
   53 |   int v;
      |       ^
#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...