제출 #912496

#제출 시각아이디문제언어결과실행 시간메모리
912496linvg순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include "perm.h" std::vector<int> construct_permutation(long long x) { int64_t sum = 1; int64_t mn = 1e9 - 1; vector<int64_t> res; while (sum < x) { int64_t cnt = 0; for (int64_t i = 1; i <= 62; ++i) { if (sum + (1ll << i) - 1 > x) { sum += (1ll << (i - 1)) - 1; cnt = i - 1; break; } } // dbg(sum, cnt); for (int64_t i = mn - cnt; i < mn; ++i) { // cout << i << " "; res.pb(i); } mn -= cnt; for (int64_t i = 62; i >= 1; --i) { if (sum + (1ll << (i - 1)) <= x) { sum += (1ll << (i - 1)); cnt = i - 1; res.pb(mn + cnt); } } } // dbg(sum); // dbg(sz(res)); int ans[sz(res)] = {0}; for (int64_t i = 0; i < sz(res); ++i) { ans[i] = res[i]; } return ans; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:5:5: error: 'int64_t' was not declared in this scope
    5 |     int64_t sum = 1;
      |     ^~~~~~~
perm.cpp:7:12: error: expected ';' before 'mn'
    7 |     int64_t mn = 1e9 - 1;
      |            ^~~
      |            ;
perm.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int64_t> res;
      |     ^~~~~~
perm.cpp:9:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
perm.cpp:9:21: error: 'res' was not declared in this scope
    9 |     vector<int64_t> res;
      |                     ^~~
perm.cpp:11:12: error: 'sum' was not declared in this scope
   11 |     while (sum < x)
      |            ^~~
perm.cpp:13:16: error: expected ';' before 'cnt'
   13 |         int64_t cnt = 0;
      |                ^~~~
      |                ;
perm.cpp:14:21: error: expected ';' before 'i'
   14 |         for (int64_t i = 1; i <= 62; ++i)
      |                     ^~
      |                     ;
perm.cpp:14:29: error: 'i' was not declared in this scope
   14 |         for (int64_t i = 1; i <= 62; ++i)
      |                             ^
perm.cpp:19:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   19 |                 cnt = i - 1;
      |                 ^~~
      |                 int
perm.cpp:24:21: error: expected ';' before 'i'
   24 |         for (int64_t i = mn - cnt; i < mn; ++i)
      |                     ^~
      |                     ;
perm.cpp:24:36: error: 'i' was not declared in this scope
   24 |         for (int64_t i = mn - cnt; i < mn; ++i)
      |                                    ^
perm.cpp:24:40: error: 'mn' was not declared in this scope
   24 |         for (int64_t i = mn - cnt; i < mn; ++i)
      |                                        ^~
perm.cpp:29:9: error: 'mn' was not declared in this scope
   29 |         mn -= cnt;
      |         ^~
perm.cpp:29:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
   29 |         mn -= cnt;
      |               ^~~
      |               int
perm.cpp:31:21: error: expected ';' before 'i'
   31 |         for (int64_t i = 62; i >= 1; --i)
      |                     ^~
      |                     ;
perm.cpp:31:30: error: 'i' was not declared in this scope
   31 |         for (int64_t i = 62; i >= 1; --i)
      |                              ^
perm.cpp:43:13: error: 'sz' was not declared in this scope
   43 |     int ans[sz(res)] = {0};
      |             ^~
perm.cpp:44:17: error: expected ';' before 'i'
   44 |     for (int64_t i = 0; i < sz(res); ++i)
      |                 ^~
      |                 ;
perm.cpp:44:25: error: 'i' was not declared in this scope
   44 |     for (int64_t i = 0; i < sz(res); ++i)
      |                         ^
perm.cpp:46:9: error: 'ans' was not declared in this scope
   46 |         ans[i] = res[i];
      |         ^~~
perm.cpp:48:12: error: 'ans' was not declared in this scope
   48 |     return ans;
      |            ^~~