Submission #502546

#TimeUsernameProblemLanguageResultExecution timeMemory
502546fabijan_cikacXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int N){ int m[10010][10010]; vector<pair<int, int> > v; int a[15000]; bool b = true; int sol[15000]; m[0][1] = query(0, 1); for (int i = 2; i < N; ++i){ m[i - 2][i] = query(i - 2, i); m[i - 1][i] = query(i - 1, i); } //a[0] < a[1] a[0] = 0; a[1] = m[0][1]; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } if (!b || x > y){ a[0] = 0; a[1] = -m[0][1]; b = true; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } v.clear(); for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } } for (int i = 0; i < n; ++i) answer(i + 1, sol[i]); return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:30:25: error: 'n' was not declared in this scope
   30 |     for (int i = 0; i < n; ++i){
      |                         ^
xylophone.cpp:52:29: error: 'n' was not declared in this scope
   52 |         for (int i = 0; i < n; ++i){
      |                             ^
xylophone.cpp:58:25: error: 'n' was not declared in this scope
   58 |     for (int i = 0; i < n; ++i)
      |                         ^