제출 #1316985

#제출 시각아이디문제언어결과실행 시간메모리
1316985pobeXylophone (JOI18_xylophone)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long using namespace std; using namespace __gnu_pbds; using ordered_set = tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>; ostream &operator <<(ostream &out, vector <int> val) { for (auto v : val) { out << v << ' '; } return out; } void solve(int n) { vector <int> res(n); if (n == 1) { ans(1, 1); return; } else if (n == 2) { ans(1, 1); ans(2, 2); return; } vector <int> d(n - 1); for (int i = 0; i < n - 1; ++i) { d[i] = query(i + 1, i + 2); } res[0] = 0; res[1] = d[0]; for (int i = 0; i < n - 2; ++i) { int v = query(i + 1, i + 3); if (v == d[i] + d[i + 1]) { if (res[i] < res[i + 1]) { res[i + 2] = res[i + 1] + d[i + 1]; } else { res[i + 2] = res[i + 1] - d[i + 1]; } } else { if (res[i] < res[i + 1]) { res[i + 2] = res[i + 1] - d[i + 1]; } else { res[i + 2] = res[i + 1] + d[i + 1]; } } } int ind1 = min_element(res.begin(), res.end()) - res.begin(); int ind2 = max_element(res.begin(), res.end()) - res.begin(); int v = res[ind1]; for (int i = 0; i < n; ++i) { res[i] = res[i] - v + 1; if (ind2 < ind1) { res[i] = n + 1 - res[i]; } ans(i + 1, res[i]); } }

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

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:18:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         ans(1, 1);
      |         ^~~
      |         abs
xylophone.cpp:21:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |         ans(1, 1);
      |         ^~~
      |         abs
xylophone.cpp:27:16: error: 'query' was not declared in this scope
   27 |         d[i] = query(i + 1, i + 2);
      |                ^~~~~
xylophone.cpp:32:17: error: 'query' was not declared in this scope
   32 |         int v = query(i + 1, i + 3);
      |                 ^~~~~
xylophone.cpp:55:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |         ans(i + 1, res[i]);
      |         ^~~
      |         abs