# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078624 | 8pete8 | Ancient Machine (JOI21_ancient_machine) | C++17 | 49 ms | 8784 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 "Anna.h"
#include <vector>
using namespace std;
namespace {
int variable_example = 0;
}
void Anna(int N, vector<char> S){
int found=0;
for(auto i:S){
if(found==0){
if(i=='X')found=1;
Send(found);
}
else{
if(i=='Z')Send(1);
else Send(0);
}
}
}
/*
10
X Y X Y Z X Y Z Y Z
trying to solve in N
if we highlight all y and do it backward it might remove a z
but not an x between -xz
and wont remove x'z'yz
x yyyyyy xz yyyy z
we have to choose one
so the 2nd x will becomne uselss and the 2nd group of y
what if we remove all useless one first
then we will be left with
xyyyz xyyz xyyz
now can we just do from left to right
highlight first x and a pair of y->z
then we can get rid of useless one then remove left to right and save the first x for last
case:
x y x y z
x y z y z
**
we can split each z then for each block do right to left but we do block left to right
we will also highlight 1 x
for case like x z y z
then we just need to remove everything so the left of the comp is x
will this work??
**
*/
#include "Bruno.h"
#include<iostream>
#include<cassert>
#include <vector>
using namespace std;
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
}
void Bruno(int N, int L,vector<int> A){
int found=0,x=-1;
vector<int>done(N,0);
for(int i=0;i<L;i++){
if(A[i]){
int cur=i-1;
while(!A[cur]&&cur>=0){
if(done[cur])break;
Remove(cur);
done[cur]=1;
cur--;
}
if(found&&!done[i]){
//if(done[i])assert(0);
Remove(i),done[i]=1;
}
else x=i;
}
found|=A[i];
}
if(x!=-1)Remove(x),done[x]=1;
for(int i=0;i<N;i++)if(!done[i])Remove(i);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |