Submission #996012

# Submission time Handle Problem Language Result Execution time Memory
996012 2024-06-10T07:19:31 Z Tozzyyyy Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#include "xylophone.h"

using namespace std;

void solve(int n) {
	vector<int> a(n+2);
	vector<int> b(n+1) , c(n+1);
	for(int i = 1 ; i < n ; i++){
		b[i] = query(i , i+1);
	}
	for(int i = 2 ; i < n ; i++){
		c[i] = query(i-1 , i+1);
	}
	for(int i = 1 ; i <= n ; i++){
		a[i] = 1;
		a[i+1] = 1 + b[i];
		a[i-1] = b[i-1] + 1;
		for(int j = i + 2 ; j <= n ; j++){
			if(a[j-1] > a[j-2]){
				if(b[j-2] < c[j-1]) a[j] = a[j-1] + b[j-1];
				else a[j] = a[j-1] - b[j-1];
			}else{
				if(b[j-2] < c[j-1]) a[j] = a[j-1] - b[j-1];
				else a[j] = a[j-1] + b[j-1];	
			}
		}
		for(int j = i - 2 ; j >= 1 ; j--){
			if(a[j+1] > a[j+2]){
				if(b[j+1] < c[j+1]) a[j] = a[j+1] + b[j];
				else a[j] = a[j+1] - b[j];
			}else{
				if(b[j+1] < c[j+1]) a[j] = a[j+1] - b[j];
				else a[j] = a[j+1] + b[j];
			}
		}
		vector<int> cnt(n+1);
		int C = 0;
		for(int i = 1 ; i <= n ; i ++){
			if(a[i] < 1 or a[i] > n){
				C=1; break;
			}
			if(cnt[a[i]] == 1){
				C=1; break;
			}
			cnt[a[i]]=1;
		}
		if(C==0){
			for(int i = 1 ; i <= n ; i++) answer(i , a[i]);
			break;
		}
	}

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -