답안 #417195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417195 2021-06-03T12:50:38 Z jamezzz Ancient Machine (JOI21_ancient_machine) C++17
38 / 100
95 ms 10348 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) {
	int cur=0;
	if(A[0]==1){
		++cur;
		c[1][0]='X';
		c[1][1]='Y';
		c[0][0]='Z';
	}
	else if(A[1]==0){
		cur+=2;
		c[0][0]='X';
		c[1][0]='Y';
		c[1][1]='Z';
	}
	else{
		cur+=2;
		c[1][0]='X';
		c[0][0]='Y';
		c[1][1]='Z';
	}
	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){
				thing tp=st.top();st.pop();
				rem(tp);
				if(tp.x==1)--cnt;
			}
			rem(t);
		}
	}
	while(!st.empty())rem(st.top()),st.pop();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 488 KB Output is correct
2 Correct 1 ms 488 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 1 ms 488 KB Output is correct
5 Correct 1 ms 488 KB Output is correct
6 Correct 1 ms 488 KB Output is correct
7 Correct 1 ms 488 KB Output is correct
8 Correct 1 ms 488 KB Output is correct
9 Correct 1 ms 488 KB Output is correct
10 Correct 1 ms 496 KB Output is correct
11 Correct 0 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 83 ms 9804 KB Partially correct
2 Partially correct 95 ms 9760 KB Partially correct
3 Partially correct 83 ms 9872 KB Partially correct
4 Partially correct 83 ms 9820 KB Partially correct
5 Partially correct 86 ms 9980 KB Partially correct
6 Partially correct 86 ms 9784 KB Partially correct
7 Partially correct 82 ms 9820 KB Partially correct
8 Partially correct 83 ms 9788 KB Partially correct
9 Partially correct 89 ms 9948 KB Partially correct
10 Partially correct 84 ms 9908 KB Partially correct
11 Partially correct 85 ms 9748 KB Partially correct
12 Partially correct 83 ms 9884 KB Partially correct
13 Partially correct 77 ms 10172 KB Partially correct
14 Partially correct 89 ms 10148 KB Partially correct
15 Partially correct 79 ms 10268 KB Partially correct
16 Partially correct 89 ms 10348 KB Partially correct
17 Partially correct 71 ms 8084 KB Partially correct
18 Partially correct 73 ms 8136 KB Partially correct
19 Partially correct 71 ms 8184 KB Partially correct
20 Partially correct 80 ms 10152 KB Partially correct
21 Partially correct 83 ms 10176 KB Partially correct
22 Partially correct 71 ms 8136 KB Partially correct
23 Partially correct 81 ms 10020 KB Partially correct
24 Partially correct 83 ms 10004 KB Partially correct
25 Partially correct 75 ms 8108 KB Partially correct
26 Partially correct 70 ms 8216 KB Partially correct
27 Partially correct 77 ms 8188 KB Partially correct
28 Partially correct 72 ms 8200 KB Partially correct
29 Partially correct 73 ms 8204 KB Partially correct
30 Partially correct 72 ms 8072 KB Partially correct
31 Partially correct 76 ms 8136 KB Partially correct
32 Partially correct 82 ms 9592 KB Partially correct
33 Partially correct 81 ms 9664 KB Partially correct