Submission #58365

# Submission time Handle Problem Language Result Execution time Memory
58365 2018-07-17T15:01:25 Z khohko Xylophone (JOI18_xylophone) C++17
0 / 100
2 ms 312 KB
#include <bits/stdc++.h>
#include "xylophone.h"
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;


ll a[ARRS];

void solve(int n) {
	ll l,r;
	a[1]=0;
	a[2]=query(1,2);
	for(int i=3; i<=n; i++){
		ll k,p;
		k=query(i-2,i);
		p=query(i-1,i);
		if(k>p)
			a[i]=a[i-1]+p;
		else a[i]=a[i-1]-p;
	}
	pair<ll,ll> mn,mx;
	mn.fr=MAX;
	mx.fr=-MAX;
	for(int i=1; i<=n; i++){
		mn=min(mn,{a[i],i});
		mx=max(mx,{a[i],i});
	}
	ll t;
	if(mn.sc>mx.sc){
		for(int i=1; i<=n; i++)
			a[i]=-a[i];
		t=mx.fr;
	}
	else t=-mn.fr;
	//cout<<mn.fr<<" "<<mn.sc<<endl;
	//cout<<mx.fr<<" "<<mx.sc<<endl;
	//cout<<t<<endl;
	//
	for(int i=1; i<=n; i++)a[i]+=t+1;
	//for(int i=1; i<=n; i++)
		//cout<<a[i]<<" ";
	//cout<<endl;
	for(int i = 1; i <= n; i++) 
		answer(i, a[i]);
}


Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:25:5: warning: unused variable 'l' [-Wunused-variable]
  ll l,r;
     ^
xylophone.cpp:25:7: warning: unused variable 'r' [-Wunused-variable]
  ll l,r;
       ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 312 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 312 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 312 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -