제출 #722116

#제출 시각아이디문제언어결과실행 시간메모리
722116yeyso순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "perm.h"
#define int long long;
vector<int> construct_permutation(long long k)
{
	k -= 1;
	int x = 1;
	vector<int> sub = {0};
	vector<int> res;
	while(sub[sub.size()-1] < k * 2){
		sub.push_back(pow(2, x)-1);
		x += 1;
	}
	while(k > 0){
		for(int i = 0; i < sub.size(); i ++){
			if(sub[i] > k){
				k -= sub[i-1];
				res.push_back(i-1);
                break;
			}
		}
	}
    vector<vector<int>> inc;
    int res0;
    for(int i = 0; i < res.size(); i ++){
        inc.push_back({});
        for(int j = 0; j < res[i]; j ++){
            inc[i].push_back(j+res0);
        }
        res0 += res[i];
    }
    vector<int> res2;
    reverse(inc.begin(), inc.end());
    for(int i = 0; i < inc.size(); i ++){
        for(int j = 0; j < inc[i].size(); j ++){
            res2.push_back(inc[i][j]);
        }

    }
	return res2;
}

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

perm.cpp:4:18: error: template argument 1 is invalid
    4 | #define int long long;
      |                  ^~~~
perm.cpp:5:8: note: in expansion of macro 'int'
    5 | vector<int> construct_permutation(long long k)
      |        ^~~
perm.cpp:4:18: error: template argument 2 is invalid
    4 | #define int long long;
      |                  ^~~~
perm.cpp:5:8: note: in expansion of macro 'int'
    5 | vector<int> construct_permutation(long long k)
      |        ^~~
perm.cpp:5:11: error: expected unqualified-id before '>' token
    5 | vector<int> construct_permutation(long long k)
      |           ^