답안 #417338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417338 2021-06-03T14:57:34 Z pavement Ancient Machine (JOI21_ancient_machine) C++17
컴파일 오류
0 ms 0 KB
#include "Anna.h"
#include <bits/stdc++.h>
 
void Anna(int N, std::vector<char> S) {
	for (int i = 0; i < N; i++) {
		if (S[i] == 'X') Send(0), Send(0);
		else if (S[i] == 'Y') Send(0), Send(1);
		else Send(1), Send(0);
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
 
void Bruno(int N, int L, std::vector<int> A) {
	std::vector<char> B(N, 0);
	std::vector<bool> r(N, 0);
	std::vector<int> tocl(N, -1), tocr(N, -1);
	std::vector<pair<int, int> > segs;
	for (int i = 0; i < L; i += 2) {
		if (A[i] == 0 && A[i + 1] == 0) B[i] = 'X';
		else if (A[i] == 0 && A[i + 1] == 1) B[i] = 'Y';
		else B[i] = 'Z';
	}
	for (int i = 0, cl = -1; i < N; i++) {
		if (B[i] == 'X') cl = i;
		else if (B[i] == 'Y') tocl[i] = cl;
	}
	for (int i = N - 1, cr = -1; i >= 0; i--) {
		if (B[i] == 'Z') cr = i;
		else if (B[i] == 'Y') tocr[i] = cr;
	}
	for (int i = 0; i < N; i++)
		if (B[i] == 'Y' && tocl[i] != -1 && tocr[i] != -1) {
			segs.emplace_back(tocl[i], tocr[i]);
		}
	std::sort(segs.begin(), segs.end());
	segs.erase(std::unique(segs.begin(), segs.end()), segs.end());
	for (auto i : segs) {
		assert(B[i.first] == 'X' && B[i.second] == 'Z');
		int pos = -1;
		for (int j = i.first; j <= i.second; j++)
			if (!r[j] && B[j] == 'Y') pos = j;
		assert(pos != -1);
		for (int j = i.first + 1; j < pos; j++)
			if (!r[j]) r[j] = 1, Remove(j);
		for (int j = pos + 1; j < i.second; j++)
			if (!r[j]) r[j] = 1, Remove(j);
		Remove(pos);
	}
	for (int i = 0; i < N; i++)
		if (!r[i]) Remove(i);
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:8:14: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    8 |  std::vector<pair<int, int> > segs;
      |              ^~~~
      |              std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from Bruno.h:1,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
Bruno.cpp:8:27: error: template argument 1 is invalid
    8 |  std::vector<pair<int, int> > segs;
      |                           ^
Bruno.cpp:8:27: error: template argument 2 is invalid
Bruno.cpp:8:29: error: expected unqualified-id before '>' token
    8 |  std::vector<pair<int, int> > segs;
      |                             ^
Bruno.cpp:24:4: error: 'segs' was not declared in this scope
   24 |    segs.emplace_back(tocl[i], tocr[i]);
      |    ^~~~
Bruno.cpp:26:12: error: 'segs' was not declared in this scope
   26 |  std::sort(segs.begin(), segs.end());
      |            ^~~~