Submission #441037

# Submission time Handle Problem Language Result Execution time Memory
441037 2021-07-04T00:51:43 Z kig9981 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
72 ms 8024 KB
#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);
  	bool chk=false;
	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) 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'; chk=true;
	}
	if(chk)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, p=-1;
	if(L==0) {
		for(int i=0;i<N;i++) Remove(i);
		return;
	}
	for(int i=0;i<N;i++) if(A[i]) {
		s=min(s,i);
		e=i;
	}
	vector<char> S(N);
	vector<int> I;
	for(int i=0;i<N;i++) S[i]='?';
	for(int i=s+1;i<e;i++) 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<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();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8024 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -