Submission #1060950

# Submission time Handle Problem Language Result Execution time Memory
1060950 2024-08-16T04:56:44 Z KasymK Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 348 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

vector<int> construct_permutation(ll k){
    if(k <= 90){
        vector<int> A;
        for(int i = k-2; i >= 0; --i)
            A.pb(i);
        return A;
    }
    vector<int> A;
    int sm = 0, sm_ = 0;
    bool ok = false;
    vector<int> answer;
    for(int i = 60; i >= 0; --i){
        if(ok){   
            A.pb(sm);
            sm++;
            if(k>>i&1){
                sm_--;
                A.pb(sm_);
            }
        }
        if(k>>i&1)
            ok = true;
    }
    for(auto &i : A)
        answer.pb(i-sm_);
    return answer;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Partially correct 1 ms 348 KB Partially correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Partially correct 1 ms 348 KB Partially correct
9 Correct 2 ms 348 KB Output is correct
10 Partially correct 1 ms 348 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 348 KB Partially correct