# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890775 | UmairAhmadMirza | Miners (IOI07_miners) | C++17 | 1576 ms | 604 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;
int main(){
int n;
cin>>n;
string s;
cin>>s;
int st=0;
string a="",b="";
int ans=0;
while(st<(1<<n)){
a="",b="";
for (int i = 0; i < n; ++i){
if(st&(1<<i))
a+=s[i];
else
b+=s[i];
}
int mx1=0,mx2=0;
set<char> uni;
for (int i = 0; i < a.length(); ++i)
{
uni.insert(a[i]);
mx1+=int(uni.size());
if(i>=2 && a[i]!=a[i-2] && a[i-2]!=a[i-1])
uni.erase(a[i-2]);
}
uni.clear();
for (int i = 0; i < b.length(); ++i)
{
uni.insert(b[i]);
mx2+=int(uni.size());
if(i>=2 && b[i]!=b[i-2] && b[i-2]!=b[i-1])
uni.erase(b[i-2]);
}
ans=max(ans,mx1+mx2);
st++;
}
cout<<ans<<endl;
return 0;
}
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... |