Submission #111032

# Submission time Handle Problem Language Result Execution time Memory
111032 2019-05-13T14:56:13 Z Pajaraja Xylophone (JOI18_xylophone) C++17
0 / 100
2 ms 384 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[5007],s[5007],sgn[5007],inv[5007];
void solve(int n)
{
	int znk=1;
	sgn[0]=1;
	for(int i=0;i<n-1;i++) s[i]=query(i+1,i+2);
	for(int i=2;i<n;i++)
	{
		if(s[i-2]+s[i-1]==query(i-1,i+1)) sgn[i-1]=sgn[i-2];
		else sgn[i-1]=-sgn[i-2];
	}
	int m=0,cur=0;
	for(int i=1;i<n;i++)
	{
		cur+=sgn[i-1]*s[i-1];
		m=min(m,cur);
	}
	cur=-m;
	a[0]=-m;
	for(int i=0;i<n;i++)
	{
		cur+=sgn[i-1]*s[i-1];
		a[i]=cur;
	}
	for(int i=0;i<n;i++) inv[a[i]]=i;
	if(inv[0]>inv[n-1]) for(int i=0;i<n;i++) a[i]=n-1-a[i];
	for(int i=0;i<n;i++) answer(i+1,a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:7:6: warning: unused variable 'znk' [-Wunused-variable]
  int znk=1;
      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -