Submission #911401

# Submission time Handle Problem Language Result Execution time Memory
911401 2024-01-18T21:12:38 Z asdasdqwer Permutation (APIO22_perm) C++17
71.2154 / 100
23 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

vector<int32_t> construct_permutation(long long x) {
    if (x==2) {
        return {0};
    }

    x--;

    vector<int32_t> out;
    __uint128_t ONE=1;

    int cnt=0;
    vector<int> v;
    for (int i=65;i>0;i--) {
        while (x >= (((ONE<<i)-1))) {
            v.push_back(i);
            x -= ((ONE<<i)-1);
        }
    }

    for (int i=1;i<=v.size();i++) {
        int start=(1e9-1e5)/i;

        for (int j=0;j<v[i-1];j++) {
            out.push_back(start+j);
        }
    }

    vector<int32_t> al=out;
    sort(al.begin(),al.end());
    map<int,int> mp;
    for (int i=0;i<al.size();i++) {
        mp[al[i]]=i;
    }

    for (int32_t &x:out) {
        x = mp[x];
    }

    return out;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:19:18: warning: comparison of integer expressions of different signedness: 'long long int' and '__int128 unsigned' [-Wsign-compare]
   19 |         while (x >= (((ONE<<i)-1))) {
      |                ~~^~~~~~~~~~~~~~~~~
perm.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=1;i<=v.size();i++) {
      |                  ~^~~~~~~~~~
perm.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0;i<al.size();i++) {
      |                  ~^~~~~~~~~~
perm.cpp:16:9: warning: unused variable 'cnt' [-Wunused-variable]
   16 |     int cnt=0;
      |         ^~~
# 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 2 ms 348 KB Partially correct
5 Partially correct 8 ms 860 KB Partially correct
6 Partially correct 8 ms 604 KB Partially correct
7 Partially correct 14 ms 860 KB Partially correct
8 Partially correct 21 ms 1224 KB Partially correct
9 Correct 2 ms 344 KB Output is correct
10 Partially correct 23 ms 1372 KB Partially correct
11 Partially correct 19 ms 1116 KB Partially correct
12 Partially correct 16 ms 980 KB Partially correct
13 Partially correct 17 ms 1112 KB Partially correct