답안 #160581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160581 2019-10-28T15:29:33 Z iefnah06 Xylophone (JOI18_xylophone) C++11
0 / 100
2 ms 504 KB
#include "xylophone.h"

#include<bits/stdc++.h>
using namespace std;

void solve(int N) {
	vector<int> A(N);
	vector<int> two;
	vector<int> three;
	for (int i = 0; i+1 < N; i++) {
		two.push_back(query(i+1, i+2));
	}
	for (int i = 0; i+2 < N; i++) {
		three.push_back(query(i+1, i+3));
	}
	A[0] = 0;
	A[1] = A[0] + two[0];
	for (int i = 0; i+2 < N; i++) {
		if (three[i] == two[i]) {
			A[i+2] = (A[i] < A[i+1] ? A[i+1] - three[i] : A[i+1] + three[i]);
		} else {
			assert(three[i] > two[i]);
			if (bool(A[i] < A[i+1]) == bool(two[i] + two[i+1] == three[i])) {
				A[i+2] = A[i+1] + two[i+1];
			} else {
				A[i+2] = A[i+1] - two[i+1];
			}
		}
	}

	int mi = *min_element(A.begin(), A.end());
	for (int i = 0; i < N; i++) {
		A[i] -= mi;
	}
	assert(set<int>(A.begin(), A.end()).size() == size_t(N) && *max_element(A.begin(), A.end()) == N-1);
	if (int(find(A.begin(), A.end(), 0) - A.begin()) > int(find(A.begin(), A.end(), N-1) - A.begin())) {
		for (int i = 0; i < N; i++) {
			A[i] = N - 1 - A[i];
		}
	}
	for (int i = 0; i < N; i++) {
		answer(i+1, A[i]+1);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 308 KB Output is correct
2 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 308 KB Output is correct
2 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 308 KB Output is correct
2 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -