Submission #147724

#TimeUsernameProblemLanguageResultExecution timeMemory
147724mosiashvililukaXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,n,f[5009],mn;
pair <int, int> p[3];
void upd(int q, int w){
	if(p[1].first>=q){
		p[2].first=p[1].first;
		p[1].first=q;
		p[1].second=w;
	}else{
		if(p[2].first>q){
			p[2].first=q;
			p[2].second=w;
		}
	}
}
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);
			c=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);
			c=query(c-1,c+1);
			if(c==a+b){
				f[c+1]=f[c]-b;
			}else{
				f[c+1]=f[c]+b;
			}
		}
	}
	p[1].first=n*2;
	p[2].first=n*2;
	for(c=1; c<=n; c++){
		upd(f[c],c);
	}
	if(p[1].second>p[2].second){
		for(c=1; c<=n; c++) f[c]=-f[c];
	}
	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);
	}
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:18:4: error: 'query' was not declared in this scope
  a=query(1,2);
    ^~~~~
xylophone.cpp:52:3: error: 'answer' was not declared in this scope
   answer(c,f[c]+mn+1);
   ^~~~~~
xylophone.cpp:52:3: note: suggested alternative: 'assert'
   answer(c,f[c]+mn+1);
   ^~~~~~
   assert