#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
void Anna(int n, vector<char> s){
for (int i=0; i<n; ++i){
if (s[i]=='X')Send(0), Send(0);
else if (s[i]=='Y')Send(1), Send(0);
else Send(1), Send(1);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
bool custom(pair<pii, int> a, pair<pii, int> b){
return a.fi.se-a.fi.fi<b.fi.se-b.fi.fi;
}
void Bruno(int n, int l, vector<int> a){
//x, y, z=0, 1, 2
vector<int> vect(n+1), y, lx(n+1, -1), rz(n+2, n+1);
for (int i=0; i<2*n; i+=2)vect[i/2+1]=a[i]+a[i+1];
for (int i=1; i<=n; ++i)if (vect[i]==1)y.pb(i);
set<int> s;
for (int i=1; i<=n; ++i)s.insert(i);
map<pii, int> mm;
for (int i=1; i<=n; ++i){
if (!vect[i])lx[i]=i;
lx[i]=max(lx[i], lx[i-1]);
}
for (int i=n; i>=1; --i){
if (vect[i]==2)rz[i]=i;
rz[i]=min(rz[i], rz[i+1]);
}
for (auto c:y)mm[mp(lx[c], rz[c])]=c;
vector<pair<pii, int> > ord;
for (auto c:mm)ord.pb(c);
// sort(ord.begin(), ord.end(), custom);
for (auto aa:ord){
pii lr=aa.fi;
int c=aa.se;
if (lr.fi==-1||lr.se==n+1)continue;
vector<int> del;
for (auto it=s.upper_bound(lr.fi); it!=s.end()&&*it<lr.se; ++it)if (*it!=c)del.pb(*it);
for (auto a:del)Remove(a-1), s.erase(a);
Remove(c-1);
s.erase(c);
}
for (auto a:s)Remove(a-1);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |