Submission #466860

#TimeUsernameProblemLanguageResultExecution timeMemory
466860julian33Miners (IOI07_miners)C++14
60 / 100
1591 ms2636 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mxN=1e5+5; //make sure this is right const int mod=1e9+7; int dp[2][1<<9][1<<9]; int id[1000]; int calc(int mask){return __builtin_popcount(mask%(1<<3)|(mask>>3)%(1<<3)|(mask>>6)%(1<<3));} int main(){ cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int n; cin>>n; string s; cin>>s; id['M']=1<<6; id['F']=1<<7; id['B']=1<<8; memset(dp,-1,sizeof(dp)); dp[1][0][0]=0; int ans=0; for(int i=0;i<n;i++){ memset(dp[i&1],-1,sizeof(dp[i&1])); for(int j=0;j<(1<<9);j++){ for(int k=0;k<(1<<9);k++){ if(dp[i&1^1][j][k]==-1) continue; int m1=(j>>3)|id[s[i]]; int m2=(k>>3)|id[s[i]]; maxa(dp[i&1][m1][k],dp[i&1^1][j][k]+calc(m1)); maxa(dp[i&1][j][m2],dp[i&1^1][j][k]+calc(m2)); } } } for(int j=0;j<(1<<9);j++){ for(int k=0;k<(1<<9);k++){ maxa(ans,dp[n&1^1][j][k]); } } cout<<ans<<"\n"; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:58:24: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   58 |                 if(dp[i&1^1][j][k]==-1)
      |                       ~^~
miners.cpp:60:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   60 |                 int m1=(j>>3)|id[s[i]];
      |                                      ^
miners.cpp:61:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   61 |                 int m2=(k>>3)|id[s[i]];
      |                                      ^
miners.cpp:62:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   62 |                 maxa(dp[i&1][m1][k],dp[i&1^1][j][k]+calc(m1));
      |                                        ~^~
miners.cpp:63:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   63 |                 maxa(dp[i&1][j][m2],dp[i&1^1][j][k]+calc(m2));
      |                                        ~^~
miners.cpp:69:26: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   69 |             maxa(ans,dp[n&1^1][j][k]);
      |                         ~^~
#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...