Submission #575080

#TimeUsernameProblemLanguageResultExecution timeMemory
575080SlavicGXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 5005;
int Paiu[N][N];

void solve(int n) {
    vector<int> dif(n, 0);
    for(int i = 0; i + 1 < n; ++i) {
        Paiu[i][i + 1] = query(i + 1, i + 2);
        if(i + 2 < n) Paiu[i][i + 2] = query(i + 1, i + 3);
    }

    vector<int> type(n, 1);
    for(int i = 0; i + 2 < n; ++i) {
        if(Paiu[i][i + 1] + Paiu[i + 1][i + 2] != Paiu[i][i + 2]) {
            type[i + 2] = -type[i + 1];
        } else {
            type[i + 2] = type[i + 1];
        }
    }

    for(int startval = -10000; startval <= 10000; ++startval) {
        vector<int> a(n, startval);
        for(int i = 1; i < n; ++i) {
            if(type[i] == 1) a[i] = a[i - 1] + Paiu[i - 1][i];
            else a[i] = a[i - 1] - Paiu[i - 1][i];
        }
        set<int> st;
        forn(i, n) st.insert(i + 1);
        forn(i, n) st.erase(a[i]);
        if(sz(st)) continue;
        map<int, int> pos;
        forn(i, n) pos[a[i]] = i;
        if(pos[1] > pos[n]) continue;
        for(int i = 0; i < n; ++i) {
            answer(i + 1, a[i]);
        } 
        return;
    }

    forn(i, n) type[i] = -type[i];
    for(int startval = -10000; startval <= 10000; ++startval) {
        vector<int> a(n, startval);
        for(int i = 1; i < n; ++i) {
            if(type[i] == 1) a[i] = a[i - 1] + Paiu[i - 1][i];
            else a[i] = a[i - 1] - Paiu[i - 1][i];
        }
        set<int> st;
        forn(i, n) st.insert(i + 1);
        forn(i, n) st.erase(a[i]);
        if(sz(st)) continue;
        map<int, int> pos;
        forn(i, n) pos[a[i]] = i;
        if(pos[1] > pos[n]) continue;
        for(int i = 0; i < n; ++i) {
            answer(i + 1, a[i]);
        } 
        return;
    }

}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:19:26: error: 'query' was not declared in this scope
   19 |         Paiu[i][i + 1] = query(i + 1, i + 2);
      |                          ^~~~~
xylophone.cpp:46:13: error: 'answer' was not declared in this scope
   46 |             answer(i + 1, a[i]);
      |             ^~~~~~
xylophone.cpp:66:13: error: 'answer' was not declared in this scope
   66 |             answer(i + 1, a[i]);
      |             ^~~~~~