# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339436 | prasanth30 | Miners (IOI07_miners) | C++14 | 1588 ms | 2316 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |