답안 #110943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110943 2019-05-13T09:28:55 Z Jatana 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include "library.h"

using namespace std;

#define pb push_back
#define len(v) ((int)v.size())

int N;
vector<int> go(int x, int forb) {
	vector<int> p{x};
	vector<int> other;
	for (int i = 0; i < N; i++) {
		if (i != x && i != forb) other.pb(i);
	}
	while (!other.empty()) {
		int l = 0;
		int r = len(other);
		while (r - l > 1) {
			int m = (l + r) / 2;
			vector<int> Q(N, 0);
			for (int j = l; j < m; j++) {
				Q[other[j]] = 1;
			}
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (A == B) {
				r = m;
			} else {
				l = m;	
			}
		}
		{
			vector<int> Q(N, 0);
			Q[other[l]] = 1;
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (A != B) return p;
		}
		p.pb(other[l]);
		other.erase(other.begin() + l);
		x = p.back();
	}
	return p;
}

void Solve(int _N) {
	N = _N;
	{
		vector<int> p = go(0, -1);
		if (len(p) == N) {
			for (int &x : p) x++;
			Answer(p);
			return;
		}
		vector<int> q = go(0, p[1]);
		reverse(q.begin(), q.end());
		q.pop_back();
		// reverse(p.begin(), p.end());
		for (int x : p) {
			q.pb(x);
		}
		swap(p, q);
		for (int &x : p) x++;
		// for (int x : p) {
		// 	cout << x << " ";
		// }
		// cout << endl;
		Answer(p);
		return;
	}

	// vector<int> M(N);

	// for(int i = 0; i < N; i++) {
	// 	M[i] = 1;
	// }

	// int A = Query(M);

	// vector<int> res(N);

	// for(int i = 0; i < N; i++) {
	// 	res[i] = i + 1;
	// }

	// Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:61:3: error: 'reverse' was not declared in this scope
   reverse(q.begin(), q.end());
   ^~~~~~~