#include "Anna.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
void Anna(int n, vector<char> t) {
vector<int> s;
for(int i=0;i<n;i++){
if(t[i]=='X'){
s.pb(0);
}
else if (t[i]=='Y'){
s.pb(1);
}
else{
s.pb(2);
}
}
int fx=n, lz=-1;
vector<int> px(n,-1), pz(n,-1), nz(n,n);
for(int i=0;i<n;i++){
if(i!=0)px[i]=px[i-1];
if(s[i]==0){fx=min(fx,i);px[i]=i;}
if(i!=0)pz[i]=pz[i-1];
if(s[i]==2){pz[i]=i;}
}
for(int i=n-1;i>=0;i--){
if(i!=n-1)nz[i]=nz[i+1];
if(s[i]==2){nz[i]=i;lz=max(lz,i);}
}
vector<int> out(n,0);
if(fx<lz){
out[fx]=1;
for(int i=fx+1;i<=lz;i++){
if(s[i]==2)out[i]=1;
}
}
for(int i=0;i<n;i++)Send(out[i]);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool out[100005];
int N;
void rem(int x){
if(0<=x and x<N and !out[x]){
out[x]=true;
Remove(x);
}
}
void Bruno(int n, int l, vector<int> a) {
N=n;
vector<int> pos;
for(int i=0;i<(int)a.size();i++){
if(a[i])pos.pb(i);
}
for(int i=0;i<(pos.empty()?n:pos[0]);i++)rem(i);
for(int i=(pos.empty()?0:pos.back()+1);i<n;i++)rem(i);
for(int i=1;i<(int)pos.size();i++){
for(int j=pos[i]-1;j>pos[i-1];j--){
rem(j);
}
rem(pos[i]);
}
rem((pos.empty()?0:pos[0]));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |