Submission #760590

#TimeUsernameProblemLanguageResultExecution timeMemory
760590coding_snorlaxPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
//Main function split it to #(2^k-1)
vector<int> split(long long int k){
    vector<int> ans;
    while(k){
        //cout << k << " ";
        long long int a = (long long int)log2(k+1);
        ans.push_back(a);
        k -= (long long int) pow(2,a)-1;
    }
    return  ans;
}

vector<int> construct_permutation(long long int k)
{
    k-=1;
    vector<int> process = split(k);
    int Count = 0;
    for(int i:process){
        Count+=i;
    }
    vector<int> s;
    for(int i:process){
        for(int j=Count-i;j<Count;j++){
            s.push_back(j);
        }
        Count-=i;
    }
	return s;
}

int main(){

    //vector<int> answer = construct_permutation(3);
    //for(int i:answer) cout << i << " ";
    vector<int> answer = construct_permutation(1000);//split((long long int)1024*1024*1024*1024*1024*1024-1);
    for(int i:answer) cout << i << " ";
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccBqpJCd.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmw6b9c.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status