Submission #912374

# Submission time Handle Problem Language Result Execution time Memory
912374 2024-01-19T10:38:46 Z huyngo Permutation (APIO22_perm) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>  
#include "perm.h"
using namespace std;
using ll = long long;
using i64 = long long;
void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char* x) { cerr << '"' << x << '"'; } void __print(const string& x) { cerr << '"' << x << '"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template<typename T, typename V> void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template<typename T> void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#define ln "\n"
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define ar array
int Bit(int mask, int b) { return (mask >> b) & 1; }
const ll base = 311, MOD = 998244353, M = 1e9 + 7, INF = 1e18;

const int mxN = 1e6 + 5;
int n;

vector<int> construct_permutation(long long X) {
    vector<int> ans;
    int l = 0, r = 0;
    auto work = [&](auto self, i64 x) ->void {
        if (x == 0) return;
        if (x & 1) {
            ans.push_back(--l);
            self(self, x - 1);
        }
        else {
            ans.push_back(++r);
            self(self, x >> 1);
        }
        };
    work(work, X);
    int mn = *min_element(all(ans));
    for (int& i : ans)
        i -= mn;
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Integer 3 violates the range [0, 2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Integer 3 violates the range [0, 2]
2 Halted 0 ms 0 KB -