Submission #572595

# Submission time Handle Problem Language Result Execution time Memory
572595 2022-06-04T18:30:42 Z arthur_nascimento Permutation (APIO22_perm) C++17
Compilation error
0 ms 0 KB
std::vector<int> construct_permutation(long long k)
{
	
   // k++;
    ll aux = k, sz = 0;
    
    while(aux)
        aux /= 2, sz++;
        
        
    vector<pii> ans;
    
    for(int i=0;i<sz-1;i++)
        ans.pb({2*i,i+1});
        
    vector<int> dec;
    dec.pb(1);
    
    int x = 1, y = 0, skip = 0;
    
    for(int i=sz-2;i>=0;i--, x += 2, y--){
        
        if((k & (1ll << i)) == 0) continue;
        
        if(skip){
            skip = 0;
            ans.pb({x,dec[dec.size()-2]+1});
            continue;
        }
        
        
        if(dec.size() == 1 || i == 0 || (k & (1ll << (i-1))) == 0){
            
            ans.pb({x,y});
            dec.pb(y);
            
            
        }
        
        else {
    
            skip = 1;
            
        }
        
        
        
    }

    sort(ans.begin(), ans.end());
    
    int c = 0;
    for(auto &p : ans)  p.first = c++;
    
    c = 0;
    sort(ans.begin(), ans.end(), [](pii i,pii j){
        if(i.second == j.second) return i.first > j.first;
        return i.second < j.second;
    });
    
    for(auto &p : ans)  p.second = c++;
    
    sort(ans.begin(), ans.end());

	vector<int> r;
	for(auto p : ans)
		r.pb(p.second);

    return r;

}

Compilation message

perm.cpp:1:6: error: 'vector' in namespace 'std' does not name a template type
    1 | std::vector<int> construct_permutation(long long k)
      |      ^~~~~~
perm.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | std::vector<int> construct_permutation(long long k)