답안 #912274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912274 2024-01-19T09:22:14 Z TienDungz 순열 (APIO22_perm) C++17
컴파일 오류
0 ms 0 KB
#include "perm.h"
#include <bits/stdc++.h> 

std::vector<int> construct_permutation(long long n)
{
  vector<int> res;
    int p = 0;
    for (int j = 60; j >= 0; j--) {
        int m = 1LL << j;
        if (n - m >= 0) {
            n -=m;
            if (ok) {
                ok = false;
                for (int i = 1; i <= j; i++) {
                    res.push_back(2 * i);
                }
                p = j;
            } else {
                res.push_back(2 * j + 1);
            }
        }
    }
    return res;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> res;
      |   ^~~~~~
perm.cpp:6:3: 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:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> res;
      |          ^~~
perm.cpp:12:17: error: 'ok' was not declared in this scope
   12 |             if (ok) {
      |                 ^~
perm.cpp:15:21: error: 'res' was not declared in this scope
   15 |                     res.push_back(2 * i);
      |                     ^~~
perm.cpp:19:17: error: 'res' was not declared in this scope
   19 |                 res.push_back(2 * j + 1);
      |                 ^~~
perm.cpp:23:12: error: 'res' was not declared in this scope
   23 |     return res;
      |            ^~~