# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831475 | OrazB | Miners (IOI07_miners) | C++14 | 1585 ms | 24668 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 all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
const int N = 1e5+5;
int n;
string s;
int nw[26], c[N], A[3], mx = 0, vis[N];
pair<int,pii> dp[N][5];
int T(char c){
if (c == 'M') return 0;
if (c == 'B') return 1;
return 2;
}
int F(string str){
int ans = 0;
for (int i = 0; i < str.size(); i++){
for (int j = i; j > max(i-3, -1); j--){
A[T(str[j])] = 1;
}
ans += A[0]+A[1]+A[2];
A[0] = A[1] = A[2] = 0;
}
return ans;
}
void bit(int x){
if (x == n){
string a = "", b = "";
for (int i = 0; i < n; i++){
if (c[i]) a += s[i];
else b += s[i];
}
mx = max(mx, F(a)+F(b));
return;
}
for (int i = 0; i < 2; i++){
c[x] = i;
bit(x+1);
}
}
int main ()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> s;
bit(0);
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... |