Submission #58556

# Submission time Handle Problem Language Result Execution time Memory
58556 2018-07-18T07:10:27 Z gusfring Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
//#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e3 + 5;

int A[MAXN], dif[MAXN];

void solve(int N){ 
  for(int i=1; i<N; ++i) dif[i - 1] = query(i, i + 1);
  int sign = 1;
  A[0] = 0, A[1] = dif[0];
  for(int i=1; i<N-1; ++i){
    if(query(i, i + 2) != (dif[i - 1] + dif[i])) sign = -sign;
    A[i + 1] = A[i] + sign * dif[i];
  }
  int mn = 0, mx = 0;
	for(int i=1; i<N; ++i){
    if(A[i] < A[mn]) mn = i;
    if(A[i] > A[mx]) mx = i;
  }
  if(mn > mx){
    for(int i=1; i<N; ++i) A[i] = -A[i];
    swap(mn, mx);
  }
  for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:11:39: error: 'query' was not declared in this scope
   for(int i=1; i<N; ++i) dif[i - 1] = query(i, i + 1);
                                       ^~~~~
xylophone.cpp:15:8: error: 'query' was not declared in this scope
     if(query(i, i + 2) != (dif[i - 1] + dif[i])) sign = -sign;
        ^~~~~
xylophone.cpp:27:26: error: 'answer' was not declared in this scope
   for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1);
                          ^~~~~~
xylophone.cpp:27:26: note: suggested alternative: 'assert'
   for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1);
                          ^~~~~~
                          assert