# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882879 | Matjaz | Miners (IOI07_miners) | C++14 | 1553 ms | 1188 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.
//
// MinersIOI2007.cpp
//
//
// Created by Matjaz Leonardis on 04/12/2023.
//
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Trying all the different Miners solutions
int N;
string food;
int coal(string s){
int res = 0;
for (int i=0;i<s.size();i++){
bool m=false,b=false,f=false;
for (int j=i;j>i-3 && j>=0;j--){
if (s[j] == 'M') m = true;
if (s[j] == 'F') f = true;
if (s[j] == 'B') b = true;
}
res += m + f + b;
}
return res;
}
int main(){
cin >> N;
cin >> food;
int best = 0;
for (int i=0;i<(1<<N);i++){
string mine1;
string mine2;
for (int j=0;j<N;j++) if ((i&(1<<j)) != 0) mine1 += food[j]; else mine2 += food[j];
best = max(best, coal(mine1) + coal(mine2));
}
cout << best << 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... |