Submission #339436

#TimeUsernameProblemLanguageResultExecution timeMemory
339436prasanth30Miners (IOI07_miners)C++14
36 / 100
1588 ms2316 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int signed main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); int n;cin>>n; string s;cin>>s; int mx=0; for(int mask=0;mask<(1<<n);mask++){ vector<int> a,b; for(int i=0;i<n;i++){if(mask&(1<<i))a.push_back(i);else b.push_back(i);} int ans=0; for(int i=0;i<a.size();i++){ if(i==0)ans++; else if(i==1){ ans++; if(s[a[i]]!=s[a[i-1]])ans++; } else{ set<int> x; x.insert(s[a[i]]); x.insert(s[a[i-1]]); x.insert(s[a[i-2]]); ans+=x.size(); } } // a=b; for(int i=0;i<b.size();i++){ if(i==0)ans++; else if(i==1){ ans++; if(s[b[i]]!=s[b[i-1]])ans++; } else{ set<int> x; x.insert(s[b[i]]); x.insert(s[b[i-1]]); x.insert(s[b[i-2]]); ans+=x.size(); } } mx=max(mx,ans); } cout<<mx; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:16:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i=0;i<a.size();i++){
      |                     ~^~~~~~~~~
miners.cpp:31:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<b.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...