Submission #701596

# Submission time Handle Problem Language Result Execution time Memory
701596 2023-02-21T14:24:58 Z Alexabcde1 Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 464 KB
#include<bits/stdc++.h> 
#include "xylophone.h"
#define f first
#define s second
using namespace std;
long long n,i,j,ress[5005][5005],resp,neg,minn,maxx;
long long ans[5005];
void solve(int n){
	if (n==2){
		answer(1,1);
		answer(2,2);
		return;
	}
	for (i=1;i<n;i++) ress[i][i+1]=query(i,i+1);
	for (i=1;i<n-1;i++) ress[i][i+2]=query(i,i+2);
	ans[1]=0;
	for (i=1;i<=n-2;i++){
		if (ress[i][i+1]+ress[i+1][i+2]==ress[i][i+2]){
			ans[i+1]=ans[i]+ress[i][i+1];
			ans[i+2]=ans[i]+ress[i][i+2];
			if (ans[i+2]>=n){
				ans[i+1]=ans[i]-ress[i][i+1];
				ans[i+2]=ans[i]-ress[i][i+2];
			}
		}
		else {
			ans[i+1]=ans[i]+ress[i][i+1];
			ans[i+2]=ans[i+1]-ress[i+1][i+2];
			if (ans[i+1]>=n){
				ans[i+1]=ans[i]-ress[i][i+1];
				ans[i+2]=ans[i+1]+ress[i+1][i+2];
			}
		}
		if (ans[i+2]<0 || ans[i+1]<0) neg=1;
	}
	maxx=1; minn=1;
	for (i=2;i<=n;i++){
		if (ans[i]>ans[maxx]) maxx=i;
		if (ans[i]<ans[minn]) minn=i;
	}
	if (maxx<minn) {
		for (i=1;i<=n;i++){
			ans[i]=-ans[i];
		}
	}
	minn=ans[1];
	for (i=2;i<=n;i++){
		minn=min(minn,ans[i]);
	}
	minn=-minn+1;
	for (i=1;i<=n;i++) answer(i,ans[i]+minn);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 464 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 464 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 464 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -