Submission #85578

# Submission time Handle Problem Language Result Execution time Memory
85578 2018-11-21T01:10:46 Z KCSC Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 5005;

int vec[DIM], dif[DIM], sol[DIM], arr[DIM];
/*
int query(int l, int r) {
	int mn = 1e9, mx = -1e9;
	for (int i = l; i <= r; ++i) {
		mn = min(mn, arr[i]); mx = max(mx, arr[i]); }
	return mx - mn; }
*/
int _query(int l, int r) {
	static map<pair<int, int>, int> mmp;
	if (mmp.find(make_pair(l, r)) == mmp.end())
		mmp[make_pair(l, r)] = query(l, r);
	return mmp[make_pair(l, r)]; }
/*
void answer(int p, int v) {
	sol[p] = v; }
*/
void solve(int n) {
	vec[2] = query(1, 2);
	for (int i = 3, l = 1, s = 1; i <= n; ++i) {
		if (_query(l, i) != _query(l, i - 1) + _query(i - 1, i)) {
			s *= -1; l = i - 1; }
		vec[i] = s * _query(i - 1, i); }
	int mn = 0;
	for (int i = 2; i <= n; ++i) {
		vec[i] += vec[i - 1]; mn = min(mn, vec[i]); }
	int p1 = 0, pn = 0;
	for (int i = 1; i <= n; ++i) {
		vec[i] += 1 - mn;
		if (vec[i] == 1) { p1 = i; }
		if (vec[i] == n) { pn = i; } }
	if (p1 > pn) {
		for (int i = 1; i <= n; ++i) {
			vec[i] = n + 1 - vec[i]; } }
	for (int i = 1; i <= n; ++i) {
		answer(i, vec[i]); } }
/*
int main(void) {
#ifdef HOME
	freopen("xylophone.in", "r", stdin);
	freopen("xylophone.out", "w", stdout); 
#endif
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i]; cout << arr[i] << " "; }
	solve(n); cout << "\n";
	for (int i = 1; i <= n; ++i) {
		cout << sol[i] << " "; }
	return 0; }
*/

Compilation message

xylophone.cpp: In function 'int _query(int, int)':
xylophone.cpp:17:26: error: 'query' was not declared in this scope
   mmp[make_pair(l, r)] = query(l, r);
                          ^~~~~
xylophone.cpp:17:26: note: suggested alternative: '_query'
   mmp[make_pair(l, r)] = query(l, r);
                          ^~~~~
                          _query
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:24:11: error: 'query' was not declared in this scope
  vec[2] = query(1, 2);
           ^~~~~
xylophone.cpp:24:11: note: suggested alternative: '_query'
  vec[2] = query(1, 2);
           ^~~~~
           _query
xylophone.cpp:41:3: error: 'answer' was not declared in this scope
   answer(i, vec[i]); } }
   ^~~~~~
xylophone.cpp:41:3: note: suggested alternative: 'assert'
   answer(i, vec[i]); } }
   ^~~~~~
   assert