Submission #658297

#TimeUsernameProblemLanguageResultExecution timeMemory
658297Zena_HossamPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "perm.h" #include "grader.cpp" #define ll int using namespace std; std::vector<long long> construct_permutation(long long k) { vector<pair<ll,ll>>v; vector<ll>s,x; long long l=1; for(ll i=0;i<1e18;i++) { v.push_back({l-1,i}); l*=2; if(l-1>1e18)break; } ll p=k-2;k--; while(1) { pair<ll,ll>h={k,0}; ll o=lower_bound(v.begin(),v.end(),h)-v.begin(); if(v[o].first>k)o--; for(ll i=p-v[o].second+1;i<=p;i++){ s.push_back(i); } // cout<<v[o].first<<" "<<v[o].second<<" "<<k<<"\n"; p-=v[o].second; k-=v[o].first; if(k<=0)break; }x=s; sort(x.begin(),x.end()); map<ll,ll>m; for(ll i=0;i<x.size();i++) { m[x[i]]=i; } for(ll i=0;i<x.size();i++) { s[i]=m[s[i]]; } return s; }

Compilation message (stderr)

perm.cpp:6:24: error: ambiguating new declaration of 'std::vector<long long int> construct_permutation(long long int)'
    6 | std::vector<long long> construct_permutation(long long k)
      |                        ^~~~~~~~~~~~~~~~~~~~~
In file included from grader.cpp:1,
                 from perm.cpp:3:
perm.h:3:18: note: old declaration 'std::vector<int> construct_permutation(long long int)'
    3 | std::vector<int> construct_permutation(long long k);
      |                  ^~~~~~~~~~~~~~~~~~~~~
perm.cpp: In function 'std::vector<long long int> construct_permutation(long long int)':
perm.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(ll i=0;i<x.size();i++)
      |                ~^~~~~~~~~
perm.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(ll i=0;i<x.size();i++)
      |                ~^~~~~~~~~
perm.cpp:41:12: error: could not convert 's' from 'vector<int>' to 'vector<long long int>'
   41 |     return s;
      |            ^
      |            |
      |            vector<int>