Submission #911482

# Submission time Handle Problem Language Result Execution time Memory
911482 2024-01-19T01:59:39 Z weakweakweak Permutation (APIO22_perm) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fs first
#define sc second 
#define pii pair<int,int>

vector<int> main(int n){
        vector<int>v;
        int dd=1;
        while(dd*2<=n){
            v.push_back(v.size()+1);
            dd*=2;
        }
        int id=0, zz=10000;
        n-=dd;

        int z=v.size();
        id=-1;
        for(int i=0, dd=1; i<=z; i++, zz--, dd*=2){
            while(i!=0 and v[id]!=i and id+1<=v.size())id++;
            if(n&dd){
                // cout << i << ' ' << id << ' ' << v[id] << '\n';
                v.insert(v.begin()+id+1,zz);
            }
            if(i==0)id=0;
        }
        return v;
}

Compilation message

perm.cpp:9:1: error: '::main' must return 'int'
    9 | vector<int> main(int n){
      | ^~~~~~~~~~~
perm.cpp:9:13: warning: first argument of 'int main(long long int)' should be 'int' [-Wmain]
    9 | vector<int> main(int n){
      |             ^~~~
perm.cpp:9:13: warning: 'int main(long long int)' takes only zero or two arguments [-Wmain]
perm.cpp: In function 'int main(long long int)':
perm.cpp:22:45: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             while(i!=0 and v[id]!=i and id+1<=v.size())id++;
      |                                         ~~~~^~~~~~~~~~
perm.cpp:29:16: error: cannot convert 'std::vector<long long int>' to 'int' in return
   29 |         return v;
      |                ^