제출 #763267

#제출 시각아이디문제언어결과실행 시간메모리
763267cheat_when_I_was_youngXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
#include "xylophone.h" #include<set> int q[5005][5005], a[5005]; bool check_permutation(int n) { set<int> s; for (int i = 1; i <= n; ++i) s.insert(a[i]); if (s.size() != n) return false; if (*(s.begin()) != 1) return false; auto k = s.end(); --k; if (*k != n) return false; for (int i = 1; i < n; ++i) if (a[i+1] - a[i] != q[i+1][i]) return false; return true; } void build_permutation1(int n) { a[1] = 10000; a[2] = 10001; for (int i = 3; i <= n; ++i) { if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) { if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i]; else a[i] = a[i-1] + q[i-1][i]; } else { if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i]; else a[i] = a[i-1] - q[i-1][i]; } } int mi = *min_element(a+1, a+n+1) - 1; for (int i = 1; i <= n; ++i) a[i] -= mi; } void build_permutation2(int n) { a[1] = 10001; a[2] = 10000; for (int i = 3; i <= n; ++i) { if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) { if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i]; else a[i] = a[i-1] + q[i-1][i]; } else { if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i]; else a[i] = a[i-1] - q[i-1][i]; } } int mi = *min_element(a+1, a+n+1) - 1; for (int i = 1; i <= n; ++i) a[i] -= mi; } void solve(int n) { for (int i = 1; i <= n-1; ++i) q[i][i+1] = q[i+1][i] = query(i, i+1); for (int i = 1; i <= n-2; ++i) q[i][i+2] = q[i+2][i] = query(i, i+2); int pos = 1; for (int i = 1<<12; i > 0; i >>= 1) { if (pos + i > n) continue; if (query(pos + i, n) == n - 1) pos += i; } build_permutation1(n); if (check_permutation(n)) { for (int i = 1; i <= n; ++i) answer(i, a[i]); return; } build_permutation2(n); for (int i = 1; i <= n; ++i) answer(i, a[i]); }

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

xylophone.cpp: In function 'bool check_permutation(int)':
xylophone.cpp:5:5: error: 'set' was not declared in this scope
    5 |     set<int> s;
      |     ^~~
xylophone.cpp:5:5: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from xylophone.cpp:2:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
xylophone.cpp:5:9: error: expected primary-expression before 'int'
    5 |     set<int> s;
      |         ^~~
xylophone.cpp:6:34: error: 's' was not declared in this scope
    6 |     for (int i = 1; i <= n; ++i) s.insert(a[i]);
      |                                  ^
xylophone.cpp:7:9: error: 's' was not declared in this scope
    7 |     if (s.size() != n) return false;
      |         ^
xylophone.cpp:8:11: error: 's' was not declared in this scope
    8 |     if (*(s.begin()) != 1) return false;
      |           ^
xylophone.cpp:9:14: error: 's' was not declared in this scope
    9 |     auto k = s.end();
      |              ^
xylophone.cpp: In function 'void build_permutation1(int)':
xylophone.cpp:27:12: error: 'min_element' was not declared in this scope
   27 |  int mi = *min_element(a+1, a+n+1) - 1;
      |            ^~~~~~~~~~~
xylophone.cpp: In function 'void build_permutation2(int)':
xylophone.cpp:42:12: error: 'min_element' was not declared in this scope
   42 |  int mi = *min_element(a+1, a+n+1) - 1;
      |            ^~~~~~~~~~~