제출 #581355

#제출 시각아이디문제언어결과실행 시간메모리
581355Omar_ElgedawyMiners (IOI07_miners)C++14
68 / 100
825 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<pair<int,pair<deque<char>,deque<char>>>,int>dp; map<pair<int,pair<deque<char>,deque<char>>>,bool>vis; int rec(int idx,deque<char>msk1,deque<char>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<char>before=msk1,before2=msk2; msk1.push_back(s[idx]); int m=0,b=0,f=0; for(int i=0;i<msk1.size();i++){ m+=msk1[i]=='M'; b+=msk1[i]=='B'; f+=msk1[i]=='F'; } if(msk1.size()==3) msk1.pop_front(); int c1=rec(idx+1,msk1,msk2)+(m>0)+(b>0)+(f>0); msk2.push_back(s[idx]); m=0,b=0,f=0; for(int i=0;i<msk2.size();i++){ m+=msk2[i]=='M'; b+=msk2[i]=='B'; f+=msk2[i]=='F'; } if(msk2.size()==3){ msk2.pop_front(); } int c2=rec(idx+1,before,msk2)+(m>0)+(b>0)+(f>0); return dp[make_pair(idx,make_pair(before,before2))]=max(c1,c2); } void testcase(int h){ cin>>n>>s; deque<char>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; }

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

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