답안 #169762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169762 2019-12-22T16:51:00 Z Mounir Xylophone (JOI18_xylophone) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
 
void answer(int i, int j);
int query(int i, int j);
 
void solve(int N){
	int nVals = N;
	vector<int> vals(nVals), diffVoisin(nVals), signe(nVals);
	for (int& val : vals)
		val = 0;
	
	for (int iVal = 0; iVal < nVals - 1; ++iVal)
		diffVoisin[iVal] = query(iVal + 1, iVal + 2);
		
	for (int signe0 = -1; signe0 <= 1; signe0 += 2){
		signe[0] = signe0;
		for (int iVal = 1; iVal < nVals - 1; ++iVal){
			if (query(iVal + 1, min(nVals, iVal + 3)) == diffVoisin[iVal] + diffVoisin[iVal + 1])
				signe[iVal] = signe[iVal - 1];
			else
				signe[iVal] = -signe[iVal - 1];
		}
		//On vérifie que ca fait une permutation, càd que tout soit distinct
		vals[0] = 1;
		set<int> verif;
		for (int iVal = 0; iVal < nVals - 1; ++iVal){
			vals[iVal + 1] = vals[iVal] + signe[iVal] * diffVoisin[iVal];
			verif.insert(vals[iVal]);
		}
		
	//	for (int& i : vals)
		//	cout << i << " ";
		//cout << endl;
		verif.insert(vals[nVals - 1]);
	
		if ((int)verif.size() == nVals && vals[0] < vals[nVals - 1]){
			int delta = 1 - *verif.begin();
			for (int iVal = 0; iVal < nVals; ++iVal)
				answer(iVal + 1, vals[iVal] + delta);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -