Submission #581339

#TimeUsernameProblemLanguageResultExecution timeMemory
581339Omar_ElgedawyMiners (IOI07_miners)C++14
60 / 100
1166 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define cin(vec) for(auto& i : vec) cin >> i #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n"; #define fast ios::sync_with_stdio(0);cin.tie(0); #define loop(i,a,b) for (int i = a; i < b; i++) #define F first #define S second #define pb(n) push_back(n) #define pf(n) push_front(n) #define dci(d) fixed<<setprecision(d) #define sp ' ' #define el '\n' #define all(v) v.begin(),v.end() #define int long long int dx[8]= {0,0,1,-1,-1,1,1,-1}; int dy[8]= {-1,1,0,0,-1,1,-1,1}; int const N=1e5+1,M=1e3+1,Mod=1e9+7; string s; int n; map<char,int>m; map<pair<int,pair<deque<int>,deque<int>>>,int>dp; map<pair<int,pair<deque<int>,deque<int>>>,bool>vis; int rec(int idx,deque<int>msk1,deque<int>msk2){ if(idx==n)return 0; if(vis[make_pair(idx,make_pair(msk1,msk2))]){ return dp[make_pair(idx,make_pair(msk1,msk2))]; } vis[make_pair(idx,make_pair(msk1,msk2))]=1; deque<int>before=msk1,before2=msk2; if(msk1.size()==3) msk1.pop_front(); msk1.push_back(m[s[idx]]); set<int>cnt; for(int i=0;i<msk1.size();i++)cnt.insert(msk1[i]); int c1=rec(idx+1,msk1,msk2)+cnt.size(); cnt.clear(); if(msk2.size()==3){ msk2.pop_front(); } msk2.push_back(m[s[idx]]); for(int i=0;i<msk2.size();i++)cnt.insert(msk2[i]); int c2=rec(idx+1,before,msk2)+cnt.size(); return dp[make_pair(idx,make_pair(before,before2))]=max(c1,c2); } void testcase(int h){ cin>>n>>s; m['M']=0; m['B']=1; m['F']=2; deque<int>q; cout<<rec(0,q,q); } int32_t main() { // fast testcase(1); // int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i); return 0; }

Compilation message (stderr)

miners.cpp: In function 'long long int rec(long long int, std::deque<long long int>, std::deque<long long int>)':
miners.cpp:35:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=0;i<msk1.size();i++)cnt.insert(msk1[i]);
      |               ~^~~~~~~~~~~~
miners.cpp:42:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=0;i<msk2.size();i++)cnt.insert(msk2[i]);
      |               ~^~~~~~~~~~~~
#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...