#include "Anna.h"
#include "bits/stdc++.h"
using namespace std;
#define ar array
void Anna(int n, vector<char> s) {
vector<int> res(n);
ar<int, 3> last {n, n, n};
vector<ar<int, 3>> par(n + 1); par[n] = last;
for(int i=n-1;~i;i--){
last[s[i] - 'X'] = i;
par[i] = last;
}
int i = par[0][0];
if(i < n){
int j = i; res[i] = 1;
while(j < n){
j = par[j][1];
int l = par[j][2];
if(l < n){
res[j] = res[l] = 1;
} j = l;
}
}
//~ for(int i=0;i<n;i++) cout<<res[i]<<" ";
//~ cout<<endl;
for(int i=0;i<n;i++){
Send(res[i]);
}
}
#include "Bruno.h"
#include "bits/stdc++.h"
using namespace std;
void Bruno(int n, int l, vector<int> a) {
vector<int> res, tot;
for(int i=0;i<n;i++){
if(a[i]) tot.push_back(i);
}
auto add = [&](int l, int r){
for(int i=l;i<=r;i++){
//~ cout<<i<<endl;
Remove(i);
}
};
if((int)tot.size() >= 3){
assert((int)tot.size()&1);
add(0, tot[0] - 1);
int last = tot[0];
for(int i=1;i<(int)tot.size();i+=2){
add(last + 1, tot[i] - 1);
add(tot[i] + 1, tot[i+1] - 1);
Remove(tot[i]);
//~ cout<<tot[i]<<endl;
Remove(tot[i+1]);
//~ cout<<tot[i+1]<<endl;
last = tot[i+1];
}
Remove(tot[0]);
//~ cout<<tot[0]<<endl;
add(last + 1, n - 1);
} else {
add(0, n - 1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
484 KB |
Output is correct |
2 |
Correct |
1 ms |
580 KB |
Output is correct |
3 |
Correct |
1 ms |
572 KB |
Output is correct |
4 |
Correct |
0 ms |
500 KB |
Output is correct |
5 |
Incorrect |
0 ms |
576 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
9168 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |