Submission #955684

# Submission time Handle Problem Language Result Execution time Memory
955684 2024-03-31T10:23:50 Z Otalp Permutation (APIO22_perm) C++17
71.2154 / 100
10 ms 1372 KB
#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back


vector<int> construct_permutation(ll k)
{
    vector<int> ans;
    ll h = k - 1;
    vector<int> d;
    ll ls = -1;
    for(int i=60; i>=1; i--){
        while(h >= (1ll << i) - 1){
            d.pb(i);
            ls += i;
            h -= (1ll << i) - 1;
        }
    }
    if(h > 0) d.pb(1), ls ++;
    for(auto x: d){
        int l=ls-x+1, r=ls;
        ls -= x;
        for(int i=l; i<=r; i++){
            ans.pb(i);
        }
    }
    for(int i=0; i<d.size(); i++){
        //cout<<d[i]<<' ';
    }
    //cout<<'\n';
    for(int i=0; i<ans.size(); i++){
        //cout<<ans[i]<<' ';
    }

    return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=0; i<d.size(); i++){
      |                  ~^~~~~~~~~
perm.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i<ans.size(); i++){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Partially correct 1 ms 348 KB Partially correct
4 Partially correct 1 ms 436 KB Partially correct
5 Partially correct 4 ms 604 KB Partially correct
6 Partially correct 4 ms 712 KB Partially correct
7 Partially correct 7 ms 860 KB Partially correct
8 Partially correct 9 ms 1116 KB Partially correct
9 Correct 2 ms 348 KB Output is correct
10 Partially correct 10 ms 1372 KB Partially correct
11 Partially correct 8 ms 1116 KB Partially correct
12 Partially correct 7 ms 860 KB Partially correct
13 Partially correct 8 ms 1116 KB Partially correct