제출 #650488

#제출 시각아이디문제언어결과실행 시간메모리
650488Koful123Xylophone (JOI18_xylophone)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h>
#include <xylophone.h>
using namespace std;

void solve(int n){
	vector<int> v(n+1),th(n+1),se(n+1);
	for(int i=1;i<=n;i++){
		se[i] = query(i-1,i);
		if(i != 1) th[i] = query(i-2,i);
	}
	for(int i=1;i<=n;i++){
		int ok = 1; v[1] = i;
		vector<int> vis(n+1,0); vis[i] = 1;
		for(int j=2;j<=n;j++){
			if(th[j] == se[j-1]){
				v[j] = v[j-1] + (v[j-2] > v[j-1] ? se[j] : -se[j]);
			}
			else{
				if(v[j-2] > v[j-1]){
					if(se[j] == th[j]) v[i] = v[j-1] + se[j];
					else v[j] = v[j-1] - se[j];
				}
				else{
					if(th[j] == se[j]) v[j] = v[j-1] - se[j];
					else v[j] = v[j-1] + se[j];
				}
			}
			if(vis[v[j]]){
				ok = 0;
				break;
			}
			vis[v[j]] = 1;
		}
		if(!ok) continue;
		for(int i=1;i<=n;i++){
			answer(i,v[i]);
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...