Submission #1190514

#TimeUsernameProblemLanguageResultExecution timeMemory
1190514Panda50OXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include "xylophone.h"
// #include<bits/stdc++.h>
using namespace std;


int B[5001];
int d1[5001], d2[5001];

void solve(int N) {
    for(int i = 1; i <= N-1; ++i) {
        d1[i] = query(i, i+1);
    }
    for(int i = 1; i <= N-2; ++i) {
        d2[i] = query(i, i+2);
    }
    B[1] = 0;
    B[2] = B[1] + d1[1];
    for(int i = 3; i <= N; ++i) {
        B[i] = B[i-1] + d1[i-1];
        if(max({abs(B[i]-B[i-1]), abs(B[i]-B[i-2]), abs(B[i-1]-B[i-2])}) != d2[i-2]) {
            B[i] = B[i-1] - d1[i-1];
        }
    }

    for(int i = 1; i <= N; ++i) {
        if(B[i] == 1) break;
        else if(B[i] == N) {
            for(int j = 1; j <= N; ++j) {
                B[j] = N - B[j] + 1;
            }
        }
    }

	for(int i = 1; i <= N; i++) {
		answer(i, B[i]);
	}

}

/*
5
1 5 3 4 2  
*/

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:17: error: 'abs' was not declared in this scope
   20 |         if(max({abs(B[i]-B[i-1]), abs(B[i]-B[i-2]), abs(B[i-1]-B[i-2])}) != d2[i-2]) {
      |                 ^~~
xylophone.cpp:20:12: error: 'max' was not declared in this scope
   20 |         if(max({abs(B[i]-B[i-1]), abs(B[i]-B[i-2]), abs(B[i-1]-B[i-2])}) != d2[i-2]) {
      |            ^~~