제출 #94329

#제출 시각아이디문제언어결과실행 시간메모리
94329fedoseevtimofeyXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include "xylophone.h" int my_query(int l, int r, vector <int> &a) { int mx = -1e9, mn = 1e9; for (int i = l; i <= r; ++i) { mx = max(mx, a[i]); mn = min(mn, a[i]); } return mx - mn; } void solve(int n) { int r = n; while (query(1, r) == n - 1) --r; ++r; vector <int> a(n + 1, -1); a[r] = n; if (r != n) { a[r + 1] = n - query(r, r + 1); } if (r != 1) { a[r - 1] = n - query(r - 1, r); } for (int i = r - 2; i >= 1; --i) { int x = query(i, i + 1); int y = query(i, i + 2); for (int z = 1; z <= n; ++z) { a[i] = z; if (my_query(i, i + 1, a) == x && my_query(i, i + 2, a) == y) { break; } } assert(a[i] != -1); } for (int i = r + 2; i <= n; ++i) { int x = query(i - 1, i); int y = query(i - 2, i); for (int z = 1; z <= n; ++z) { a[i] = z; if (my_query(i - 1, i, a) == x && my_query(i - 2, i, a) == y) { break; } } assert(a[i] != -1); } for (int i = 1; i <= n; ++i) { answer(i, a[i]); } }

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

xylophone.cpp:3:28: error: 'vector' has not been declared
 int my_query(int l, int r, vector <int> &a) {
                            ^~~~~~
xylophone.cpp:3:35: error: expected ',' or '...' before '<' token
 int my_query(int l, int r, vector <int> &a) {
                                   ^
xylophone.cpp: In function 'int my_query(int, int, int)':
xylophone.cpp:6:22: error: 'a' was not declared in this scope
         mx = max(mx, a[i]);
                      ^
xylophone.cpp:6:14: error: 'max' was not declared in this scope
         mx = max(mx, a[i]);
              ^~~
xylophone.cpp:6:14: note: suggested alternative: 'mx'
         mx = max(mx, a[i]);
              ^~~
              mx
xylophone.cpp:7:14: error: 'min' was not declared in this scope
         mn = min(mn, a[i]);
              ^~~
xylophone.cpp:7:14: note: suggested alternative: 'mn'
         mn = min(mn, a[i]);
              ^~~
              mn
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:16:5: error: 'vector' was not declared in this scope
     vector <int> a(n + 1, -1);
     ^~~~~~
xylophone.cpp:16:13: error: expected primary-expression before 'int'
     vector <int> a(n + 1, -1);
             ^~~
xylophone.cpp:17:5: error: 'a' was not declared in this scope
     a[r] = n;
     ^
xylophone.cpp:33:9: error: 'assert' was not declared in this scope
         assert(a[i] != -1);
         ^~~~~~
xylophone.cpp:33:9: note: suggested alternative: 'answer'
         assert(a[i] != -1);
         ^~~~~~
         answer
xylophone.cpp:44:9: error: 'assert' was not declared in this scope
         assert(a[i] != -1);
         ^~~~~~
xylophone.cpp:44:9: note: suggested alternative: 'answer'
         assert(a[i] != -1);
         ^~~~~~
         answer