# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831796 | Kerim | Miners (IOI07_miners) | C++17 | 1566 ms | 852 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"
#define pb(x) push_back(x)
using namespace std;
const int N = 1e5+5;
const int INF = 1e9+10;
char s[N];
int a[2], b[2];
int arr[N];
int f(int x, int y, int z){
set<int> s;
//TODO
if (x) s.insert(x);
if (y) s.insert(y);
if (z) s.insert(z);
return s.size();
}
int main(){
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int n;
scanf("%d", &n);
scanf("%s", s);
for (int i = 0; i < n; i++){
if (s[i] == 'M') arr[i] = 1;
else if(s[i] == 'F') arr[i] = 2;
else arr[i] = 3;
}
int answer = 0;
for (int mask = 0; mask < (1<<n); mask++){
a[0] = a[1] = 0;
b[0] = b[1] = 0;
int cost = 0;
for (int i = 0; i < n; i++){
if (mask>>i&1){
cost += f(a[0], a[1], arr[i]);
a[0] = a[1]; a[1] = arr[i];
}
else{
cost += f(b[0], b[1], arr[i]);
b[0] = b[1]; b[1] = arr[i];
}
}
answer = max(answer, cost);
}
printf("%d\n", answer);
}
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... |