제출 #379256

#제출 시각아이디문제언어결과실행 시간메모리
379256qwerty234Xylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; const int MAXN = 5e5 + 10, inf = 2e9; // int n; // vector <int> a; // int query(int s, int t) { // // cout << "plus" << endl; // s--; t--; // int mx = a[s], mn = a[s]; // for (int i = s; i <= t; i++) mx = max(mx, a[i]), mn = min(mn, a[i]); // return mx - mn; // } void solve(int n) { vector <int> b; b.assign(n, 0); vector <bool> vis(n + 1, false); int l = 0, r = n - 1, posn = n - 1; while (l <= r) { int m = (l + r) / 2; int tmp = query(1, m + 1); if (tmp < n - 1) { l = m + 1; } else { posn = min(posn, m); r = m - 1; } } b[posn] = n; vis[n] = true; int cnt = 0; for (int i = posn + 1; i < n; i++) { int x, y, tmp = query(i, i + 1); x = b[i - 1] + tmp; y = b[i - 1] - tmp; if (x > n || vis[x]) { b[i] = y; } else if (y < 1 || vis[y]) { b[i] = x; } else { int j = i - 1; while (b[j] <= x) j--; int tmp = query(j + 1, i + 1); if (tmp == b[j] - x) { b[i] = x; } else { b[i] = y; } } vis[b[i]] = true; cnt++; if (cnt == n - 1) { int t1; for (int j = 1; j <= n; j++) if (!vis[j]) t1 = j; for (int j = 0; j < n; j++) if (b[j] == 0) b[j] = t1; break; } } for (int i = posn - 1; i >= 0; i--) { int x, y, tmp = query(i + 1, i + 2); x = b[i + 1] + tmp; y = b[i + 1] - tmp; if (x > n || vis[x]) { b[i] = y; } else if (y < 1 || vis[y]) { b[i] = x; } else { int j = i + 1; while (b[j] <= x) j++; int tmp = query(i + 1, j + 1); if (tmp == b[j] - x) { b[i] = x; } else { b[i] = y; } } vis[b[i]] = true; cnt++; if (cnt == n - 1) { int t1; for (int j = 1; j <= n; j++) if (!vis[j]) t1 = j; for (int j = 0; j < n; j++) if (b[j] == 0) b[j] = t1; break; } } for (int i = 0; i < n; i++) { answer(i + 1, b[i]); // cout << b[i] << " "; } }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:28:15: error: 'query' was not declared in this scope
   28 |     int tmp = query(1, m + 1);
      |               ^~~~~
xylophone.cpp:41:21: error: 'query' was not declared in this scope
   41 |     int x, y, tmp = query(i, i + 1);
      |                     ^~~~~
xylophone.cpp:73:21: error: 'query' was not declared in this scope
   73 |     int x, y, tmp = query(i + 1, i + 2);
      |                     ^~~~~
xylophone.cpp:105:5: error: 'answer' was not declared in this scope
  105 |     answer(i + 1, b[i]);
      |     ^~~~~~