# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059580 | KasymK | Miners (IOI07_miners) | C++17 | 1576 ms | 808 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 ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int get(string v){
int n = (int)v.size();
int sm = 0;
for(int i = 0; i < n; ++i){
int ok = 0, ok1 = 0, ok2 = 0;
for(int j = i-2; j <= i; ++j){
if(j < 0)
continue;
if(v[j] == 'M')
ok = 1;
else if(v[j] == 'B')
ok1 = 1;
else
ok2 = 1;
}
sm += ok+ok1+ok2;
}
return sm;
}
int main(){
int n;
scanf("%d", &n);
string s;
cin >> s;
int answer = 0;
for(int mk = 0; mk < (1<<n); ++mk){
string t = "", t1 = "";
for(int i = 0; i < n; ++i){
if(mk>>i&1)
t += s[i];
else
t1 += s[i];
}
int coal = get(t)+get(t1);
umax(answer, coal);
}
printf("%d\n", answer);
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... |