# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440939 | kig9981 | Ancient Machine (JOI21_ancient_machine) | C++17 | 71 ms | 8012 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 <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
void Anna(int N, std::vector<char> S) {
vector<int> R(N);
int s=N, e=0;
for(int i=0;i<N;i++) {
if(S[i]=='X') s=min(s,i);
else if(S[i]=='Y') e=i;
}
if(s>=e) {
for(int i=0;i<N;i++) Send(0);
return;
}
R[s]=R[e]=1;
for(int i=s+1;i<e;i++) if(S[i]=='Y' && S[i+1]!='Y') {
R[i]=1; R[i+1]=S[i+1]=='Z';
}
for(auto r: R) Send(r);
}
#include "Bruno.h"
#include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
int s=N, e=0, j=0, p=-1;
for(int i=0;i<N;i++) if(A[i]) {
s=min(s,i);
e=i;
}
if(s>=e) {
for(int i=0;i<N;i++) Remove(i);
return;
}
vector<char> S(N);
vector<int> I;
for(int i=0;i<N;i++) S[i]='?';
for(int i=s+1;i<e;i+=2) if(A[i]) {
S[i++]='Y';
S[i]=A[i] ? 'Z':'X';
}
S[s]='X'; S[e]='Z';
for(int i=0;i<N;i++) {
if(S[i]=='?') Remove(i);
else if(S[i]=='Y') p=i+1;
}
if(p==-1) {
for(int i=0;i<N;i++) if(S[i]!='?') Remove(i);
return;
}
if(p<e) {
Remove(p);
S[p]='?';
}
for(int i=0;i<N;i++) if(S[i]!='?') {
if(S[i]=='Z') {
for(;;) {
Remove(I.back());
I.pop_back();
if(I.size()==1) {
Remove(i);
break;
}
Remove(I.back());
I.pop_back();
}
}
else I.push_back(i);
}
while(I.size()) {
Remove(I.back());
I.pop_back();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |