# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
737379 | becaido | Permutation (APIO22_perm) | C++17 | 3 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
vector<int> construct_permutation(ll k) {
vector<int> ans;
vector<pair<int, int>> p;
int m = __lg(k);
FOR (i, 0, m - 1) p.pb(2 * i, 10000 + i);
k -= 1ll << m;
int cnt = 0, mn = 100, smn = 100;
for (int i = m; i >= 0; i--) if (k >> i & 1) {
if (i > 0 && k >> (i - 1) & 1 && cnt >= 2) {
p.pb(2 * (m - i) + 1, smn + i);
i--;
} else {
p.pb(2 * (m - i) - 1, 100 * i);
smn = mn, mn = 100 * i;
cnt++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |