Submission #449555

#TimeUsernameProblemLanguageResultExecution timeMemory
449555CyberSleeperMiners (IOI07_miners)C++14
45 / 100
1577 ms844 KiB
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) #define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl #define fi first #define se second #define mp make_pair #define pb push_back #define ll long long #define ull unsigned long long #define ld long double #define pld pair<ld, ld> #define pli pair<ld, int> #define pii pair<int, int> #define pis pair<int, string> #define pl pair<ll, ll> #define nl '\n' using namespace std; int N; string S, food="MFB"; int main(){ fastio; cin >> N >> S; int ans=0; for(int i=0; i<(1<<N); i++){ string A="", B=""; for(int j=0; j<N; j++){ if(i&(1<<j)) A+=S[j]; else B+=S[j]; } int tmp=0; int cnt[3]={0, 0, 0}; for(int j=0; j<A.size(); j++){ for(int l=0; l<3; l++){ if(A[j]==food[l]){ cnt[l]++; } if(j>2 && A[j-3]==food[l]) cnt[l]--; } for(int l=0; l<3; l++) if(cnt[l]) tmp++; } cnt[0]=cnt[1]=cnt[2]=0; for(int j=0; j<B.size(); j++){ for(int l=0; l<3; l++){ if(B[j]==food[l]){ cnt[l]++; } if(j>2 && B[j-3]==food[l]) cnt[l]--; } for(int l=0; l<3; l++) if(cnt[l]) tmp++; } ans=max(ans, tmp); } cout << ans << endl; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int j=0; j<A.size(); j++){
      |                      ~^~~~~~~~~
miners.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int j=0; j<B.size(); j++){
      |                      ~^~~~~~~~~
#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...