제출 #530750

#제출 시각아이디문제언어결과실행 시간메모리
530750perchutsMiners (IOI07_miners)C++17
17 / 100
1588 ms716 KiB
#include <bits/stdc++.h> #define maxn (int)(1e5+51) #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define ll long long #define pb push_back #define ull unsigned long long #define ii pair<int,int> #define iii tuple<int,int,int> #define inf 2000000001 #define mod 1000000007 //998244353 #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } map<pair<string,string>,int>dp[2]; int main(){_ int n;cin>>n; string s;cin>>s; dp[0][{"",""}] = -1; for(int i=1;i<=n;++i){ for(auto [a,b]:dp[(i-1)&1]){ auto [x,y] = a; if(x==y&&sz(x)==0)b = 0; int j = max(0,sz(x)-2),cntm=0,cntf=0,cntb=0; string newa,newb; while(j<sz(x))newa+=x[j++]; newa+=s[i]; for(auto u:newa){ cntm|=u=='M',cntf|=u=='F',cntb|=u=='B'; } ckmax(dp[i&1][{newa,y}],b+cntm+cntf+cntb); j = max(0,sz(y)-2), cntm = cntf = cntb = 0; while(j<sz(y))newb+=y[j++]; newb+=s[i]; for(auto u:newb){ cntm|=u=='M',cntf|=u=='F',cntb|=u=='B'; } ckmax(dp[i&1][{x,newb}],b+cntm+cntf+cntb); } } int ans = 0; for(auto [a,b]:dp[n&1])ckmax(ans,b); cout<<ans<<endl; }
#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...