제출 #466871

#제출 시각아이디문제언어결과실행 시간메모리
466871julian33Miners (IOI07_miners)C++14
100 / 100
1041 ms516 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][4][4][4][4]; int id[1000]; int calc(int a,int b,int c){ set<int> res={a,b,c}; int k=*res.begin(); if(!k) res.erase(k); return sz(res); } 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; id['F']=2; id['B']=3; memset(dp,-1,sizeof(dp)); dp[1][0][0][0][0]=0; int ans=0; for(int i=0;i<n;i++){ memset(dp[i&1],-1,sizeof(dp[i&1])); for(int a=0;a<4;a++){ for(int b=0;b<4;b++){ for(int c=0;c<4;c++){ for(int d=0;d<4;d++){ if(dp[i&1^1][a][b][c][d]==-1) continue; int k=id[s[i]]; maxa(dp[i&1][b][k][c][d],dp[i&1^1][a][b][c][d]+calc(a,b,k)); maxa(dp[i&1][a][b][d][k],dp[i&1^1][a][b][c][d]+calc(c,d,k)); maxa(ans,dp[i&1][b][k][c][d]); maxa(ans,dp[i&1][a][b][d][k]); } } } } } cout<<ans<<"\n"; }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int main()':
miners.cpp:66:32: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   66 |                         if(dp[i&1^1][a][b][c][d]==-1)
      |                               ~^~
miners.cpp:68:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   68 |                         int k=id[s[i]];
      |                                      ^
miners.cpp:69:54: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   69 |                         maxa(dp[i&1][b][k][c][d],dp[i&1^1][a][b][c][d]+calc(a,b,k));
      |                                                     ~^~
miners.cpp:70:54: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   70 |                         maxa(dp[i&1][a][b][d][k],dp[i&1^1][a][b][c][d]+calc(c,d,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...