Submission #417186

# Submission time Handle Problem Language Result Execution time Memory
417186 2021-06-03T12:45:26 Z jamezzz Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
84 ms 9872 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace{
	int X[2],Y[2],Z[2],cntX,cntY,cntZ;
	void SendX(){
		if(X[0]==0)Send(0);
		else Send(1),Send(X[1]);
	}
	void SendY(){
		if(Y[0]==0)Send(0);
		else Send(1),Send(Y[1]);
	}
	void SendZ(){
		if(Z[0]==0)Send(0);
		else Send(1),Send(Z[1]);
	}
}

void Anna(int N,vector<char> S){
	for(int i=0;i<N;++i){
		if(S[i]=='X')++cntX;
		if(S[i]=='Y')++cntY;
		if(S[i]=='Z')++cntZ;
	}
	if(cntX>=cntY&&cntX>=cntZ){
		X[0]=0;
		Y[0]=1;Y[1]=0;
		Z[0]=1;Z[1]=1;
		Send(0);Send(0);
	}
	else if(cntY>=cntX&&cntY>=cntZ){
		X[0]=1;X[1]=0;
		Y[0]=0;
		Z[0]=1;Z[1]=1;
		Send(0);Send(1);
	}
	else{
		X[0]=1;X[1]=0;
		Y[0]=1;Y[1]=1;
		Z[0]=0;
		Send(1);
	}
	
	for(int i=0;i<N;++i){
		if(S[i]=='X')SendX();
		if(S[i]=='Y')SendY();
		if(S[i]=='Z')SendZ();
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

#define pf printf
#define pb push_back

namespace{
	vector<char> s;
	char c[2][2];
	
	struct thing{ int x,p,l; };
	vector<thing> v;
	
	stack<thing> st;
	
	void rem(thing t){
		for(int i=t.p;i<t.p+t.l;++i){
			Remove(i);
		}
	}
}

void Bruno(int N,int L,vector<int> A) {
	if(A[0]==1){
		c[1][0]='X';
		c[1][1]='Y';
		c[0][0]='Z';
	}
	else if(A[1]==0){
		c[0][0]='X';
		c[1][0]='Y';
		c[1][1]='Z';
	}
	else{
		c[1][0]='X';
		c[0][0]='Y';
		c[1][1]='Z';
	}
	int cur=2;
	while(cur<L){
		if(A[cur]==0)++cur,s.pb(c[0][0]);
		else if(A[cur+1]==0)cur+=2,s.pb(c[1][0]);
		else cur+=2,s.pb(c[1][1]);
	}
	char pv='L';int p=-1,l=-1;
	for(int i=0;i<N;++i){
		if(s[i]!=pv){
			if(pv=='X')v.pb({0,p,l});
			if(pv=='Y')v.pb({1,p,l});
			if(pv=='Z')v.pb({2,p,l});
			pv=s[i],p=i,l=1;
		}
		else ++l;
	}
	if(pv=='X')v.pb({0,p,l});
	if(pv=='Y')v.pb({1,p,l});
	if(pv=='Z')v.pb({2,p,l});
	int cnt=0;
	for(thing t:v){
		if(t.x==0)st.push(t);
		else if(t.x==1)st.push(t),++cnt;
		else{
			while(cnt!=0){
				thing tp=st.top();st.pop();
				rem(tp);
				if(tp.x==1)--cnt;
			}
			rem(t);
		}
	}
	while(!st.empty())rem(st.top()),st.pop();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 496 KB Output is correct
2 Correct 1 ms 496 KB Output is correct
3 Incorrect 1 ms 492 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 84 ms 9772 KB Partially correct
2 Partially correct 82 ms 9868 KB Partially correct
3 Incorrect 84 ms 9872 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -