Submission #76930

#TimeUsernameProblemLanguageResultExecution timeMemory
76930farukkastamonudaMiners (IOI07_miners)C++14
100 / 100
304 ms113560 KiB
#include <bits/stdc++.h> #define li 100005 #define inf 1000000000 using namespace std; int n,dp[li][4][4][4][4]; char s[li]; int solve(int a,int b,int c){ int tp[5]={}; tp[a]++; tp[b]++; tp[c]++; int cev=0; for(int i=1;i<=3;i++){ if(tp[i]>=1) cev++; } return cev; } int dfs(int node,int pre1,int pre2,int on1,int on2){ int cevap=-inf; if(node==n+1) return 0; if(~dp[node][pre1][pre2][on1][on2]) return dp[node][pre1][pre2][on1][on2]; int tut1=0; if(s[node]=='B') tut1=1; if(s[node]=='M') tut1=2; if(s[node]=='F') tut1=3; cevap=max(cevap,dfs(node+1,tut1,pre1,on1,on2)+solve(tut1,pre1,pre2)); cevap=max(cevap,dfs(node+1,pre1,pre2,tut1,on1)+solve(tut1,on1,on2)); return dp[node][pre1][pre2][on1][on2]=cevap; } int main(){ memset(dp,-1,sizeof(dp)); scanf("%d %s",&n,s+1); int ty=dfs(1,0,0,0,0); printf("%d\n",ty); return 0; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %s",&n,s+1);
     ~~~~~^~~~~~~~~~~~~~~~
#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...