Submission #968328

# Submission time Handle Problem Language Result Execution time Memory
968328 2024-04-23T10:08:14 Z batsukh2006 Permutation (APIO22_perm) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#include "perm.h"
using namespace std;
#define ff first
#define ss second
vector<int> construct_permutation(long long k){
	int x=0;
    bool ok=0;
    vector<int> v;
    for(int i=59; i>=0; i--){
    	if(k&(1ll<<i)){
	    	vector<int> c;
	    	if(ok==0){
	    		ok=1;
	    		for(int z=0; z<i; z++,x++){
	    			c.push_back(x);
	    		}
	    	}else{
	    		int s=0;
	    		int need=(1ll<<i)+1;
	    		for(int z=59; z>=0; z--){
	    			if(need&(1ll<<z)){
	    				if(z==0){
	    					c.push_back(x);
	    					x++;
	    				}else{
		    				vector<int> t;
		    				for(int l=0; l<z; l++,x++){
		    					t.push_back(x);
		    				}
		    				for(int j=t.size()-1; j>=0; j--){
		    					c.push_back(t[j]);
		    				}
		    			}
	    			}
	    		}
	    	}
	    	for(int j=c.size()-1; j>=0; j--){
	    		v.push_back(c[j]);
	    	}
	    }
    }
    reverse(v.begin(),v.end());
	return v;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:19:12: warning: unused variable 's' [-Wunused-variable]
   19 |        int s=0;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -