답안 #441036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441036 2021-07-04T00:50:55 Z kig9981 Ancient Machine (JOI21_ancient_machine) C++17
컴파일 오류
0 ms 0 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 "Anna.h"
#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 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);
}

void Bruno(int N, int L, std::vector<int> A) {
    int s=N, e=0, j=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();
	}
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:32:19: warning: unused variable 'j' [-Wunused-variable]
   32 |     int s=N, e=0, j=0, p=-1;
      |                   ^
/usr/bin/ld: /tmp/ccozIRc5.o: in function `Anna(int, std::vector<char, std::allocator<char> >)':
Bruno.cpp:(.text+0x15b): undefined reference to `Send(int)'
collect2: error: ld returned 1 exit status