제출 #147832

#제출 시각아이디문제언어결과실행 시간메모리
147832mosiashvililukaXylophone (JOI18_xylophone)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int a,b,c,d,e,n,f[5009],mn,cc;
void solve(int n){
	a=query(1,2);
	mn=n*2;
	f[1]=0;
	f[2]=a;
	for(c=2; c<n; c++){
		a=abs(f[c]-f[c-1]);
		if(f[c]>f[c-1]){
			b=query(c,c+1);
			cc=query(c-1,c+1);
			if(c==a+b){
				f[c+1]=f[c]+b;
			}else{
				f[c+1]=f[c]-b;
			}
		}else{
			b=query(c,c+1);
			cc=query(c-1,c+1);
			if(cc==a+b){
				f[c+1]=f[c]-b;
			}else{
				f[c+1]=f[c]+b;
			}
		}
	}
	int mx=-mn;
	for(c=1; c<=n; c++){
		if(mn>f[c]){
			mn=f[c];
			d=c;
		}
		if(mx<f[c]){
			mx=f[c];
			e=c;
		}
	}
	if(d>e){
		for(c=1; c<=n; c++) f[c]=-f[c];
	}
	mn=n*2;
	for(c=1; c<=n; c++) if(mn>f[c]) mn=f[c];
	for(c=1; c<=n; c++){
		answer(c,f[c]-mn+1);
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...