답안 #601508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601508 2022-07-22T06:26:40 Z thezomb1e 순열 (APIO22_perm) C++17
64.6308 / 100
14 ms 1492 KB
#include "perm.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define eb emplace_back
#define pb push_back
#define ft first
#define sd second
#define pi pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(...) dbg_out(__VA_ARGS__)

using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;

//Constants
const ll INF = 5 * 1e18;
const int IINF = 2 * 1e9;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ld PI = 3.14159265359;

//Templates
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';}
void dbg_out() {cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
template<typename T> void mins(T& x, T y) {x = min(x, y);}
template<typename T> void maxs(T& x, T y) {x = max(x, y);}
template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;


vector<int> construct_permutation(ll k) {
	if (!(k & (k - 1))) {
		for (int i = 0; i < 60; i++) {
			if (k & (1ll << i)) {
				vector<int> ans;
				for (int j = 0; j < i; j++) {
					ans.pb(j);
				}
				return ans;
			}
		}
	}
    k--;
	int pp = 0, add = 0;
	vector<int> ans;
	for (int i = 0; i < 60; i++) {
		if (k & (1ll << i)) {
			for (int j = pp + i - 1; j >= pp; j--) {
				ans.pb(j);
			}
            add++;
			pp += i;
		}
	}
    for (int i = 0; i < add; i++) {
        ans.pb(pp++);
    }
	reverse(all(ans));
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Partially correct 1 ms 340 KB Partially correct
4 Partially correct 2 ms 340 KB Partially correct
5 Partially correct 8 ms 792 KB Partially correct
6 Partially correct 6 ms 596 KB Partially correct
7 Partially correct 11 ms 896 KB Partially correct
8 Partially correct 12 ms 1108 KB Partially correct
9 Correct 2 ms 340 KB Output is correct
10 Partially correct 14 ms 1492 KB Partially correct
11 Partially correct 11 ms 980 KB Partially correct
12 Partially correct 10 ms 928 KB Partially correct
13 Partially correct 11 ms 1196 KB Partially correct