Submission #716929

# Submission time Handle Problem Language Result Execution time Memory
716929 2023-03-31T12:12:17 Z raysh07 Permutation (APIO22_perm) C++17
91.3333 / 100
3 ms 348 KB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ans;

void dowork(int y){
    for (int i=0; i<ans.size(); i++){
        if (ans[i] >= y){
            ans[i]++;
        }
    }
}

vector<int> construct_permutation(long long k)
{
    ans.clear();
	int last = -1;
	long long fk = k;
	for (int i=0; i<62; i++){
	    if (fk != 0){
	        if (fk >> i & 1)
	        fk -= 1LL<<i;
	        
	        if (fk != 0)
	        ans.push_back(i);
	        last = i;
	    }
	}
	
	for (int i=last - 1; i>=0; i--){
	    if (k >> i & 1){
	        dowork(i);
	        ans.push_back(i);
	    }
	}
	
	return ans;
}

// int main(){
//     int k; cin>>k;
//     vector <int> ok = construct_permutation(k);
//     for (auto x: ok) cout<<x<<" ";
//     return 0;
// }

Compilation message

perm.cpp: In function 'void dowork(int)':
perm.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for (int i=0; i<ans.size(); i++){
      |                   ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Partially correct 1 ms 304 KB Partially correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Partially correct 2 ms 340 KB Partially correct
9 Correct 2 ms 340 KB Output is correct
10 Partially correct 2 ms 348 KB Partially correct
11 Partially correct 3 ms 296 KB Partially correct
12 Partially correct 3 ms 340 KB Partially correct
13 Partially correct 2 ms 340 KB Partially correct