제출 #565609

#제출 시각아이디문제언어결과실행 시간메모리
565609RealSnakeXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" int a[5001]; bool sol(int n, int j, int val) { a[j] = val; int b[n + 1]; for(int i = j - 1; i >= 1; i--) { int x = query(i, i + 1); b[i] = x; if(i == j - 1) { a[i] = x + 1; if(val != 1) a[i] = val - x; continue; } int y = query(i, i + 2); if(a[i + 1] < a[i + 2]) { if(a[i + 1] + x < a[i + 2]) { if(y == b[i + 1]) a[i] = a[i + 1] + x; else a[i] = a[i + 1] - x; } else { if(y == a[i + 2] - (a[i + 1] - x)) a[i] = a[i + 1] - x; else a[i] = a[i + 1] + x; } } else { if(a[i + 1] - x > a[i + 2]) { if(y == b[i + 1]) a[i] = a[i + 1] - x; else a[i] = a[i + 1] + x; } else { if(y == (a[i + 1] + x) - a[i + 2]) a[i] = a[i + 1] + x; else a[i] = a[i + 1] - x; } } } for(int i = j + 1; i <= n; i++) { int x = query(i - 1, i); b[i] = x; if(i == j + 1) { a[i] = x + 1; if(val != 1) a[i] = val - x; continue; } int y = query(i - 2, i); if(a[i - 1] < a[i - 2]) { if(a[i - 1] + x < a[i - 2]) { if(y == b[i - 1]) a[i] = a[i - 1] + x; else a[i] = a[i - 1] - x; } else { if(y == a[i - 2] - (a[i - 1] - x)) a[i] = a[i - 1] - x; else a[i] = a[i - 1] + x; } } else { if(a[i - 1] - x > a[i - 2]) { if(b[i - 1] == y) a[i] = a[i - 1] - x; else a[i] = a[i - 1] + x; } else { if(y == (a[i - 1] + x) - a[i - 2]) a[i] = a[i - 1] + x; else a[i] = a[i - 1] - x; } } } vector<int> ve; for(int i = 1; i <= n; i++) ve.push_back(a[i]); sort(ve.begin(), ve.end()); for(int i = 1; i <= n; i++) { if(ve[i - 1] != i) return 0; } return 1; } void solve(int n) { int j = 1; for(int i = 1; i <= n; i++) a[i] = 0; for(int i = 1; i <= n; i++) { int x = query(i, n); if(x == n - 1) j = i; else break; } if(!sol(n, j, 1)) sol(n, j, n); for(int i = 1; i <= n; i++) answer(i, a[i]); }

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

xylophone.cpp: In function 'bool sol(int, int, int)':
xylophone.cpp:87:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   87 |     vector<int> ve;
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
xylophone.cpp:87:12: error: expected primary-expression before 'int'
   87 |     vector<int> ve;
      |            ^~~
xylophone.cpp:89:9: error: 've' was not declared in this scope
   89 |         ve.push_back(a[i]);
      |         ^~
xylophone.cpp:90:10: error: 've' was not declared in this scope
   90 |     sort(ve.begin(), ve.end());
      |          ^~
xylophone.cpp:90:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   90 |     sort(ve.begin(), ve.end());
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: 'std::sort' declared here
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~