# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709760 | gun_gan | Permutation (APIO22_perm) | C++17 | 3 ms | 352 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.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX = 1e18;
vector<int> construct_permutation(ll k) {
ll b = 63 - __builtin_clzll(k);
ll c = 0;
vector<int> V;
for(int i = 0; i < b; i++) {
c += 100;
V.push_back(c);
}
vector<int> v;
for(int i = 0; i < b; i++) {
if(!(k >> i & 1)) continue;
int k = i;
for(int j = (int)V.size() - 1; j >= 0 && k >= 0; j--, k--) {
if(k == 0) v.push_back(i + 1 + V[j]);
}
}
for(auto x : V) v.push_back(x);
vector<int> vals;
for(auto x : v) vals.push_back(x);
sort(vals.begin(), vals.end());
vector<int> ret;
for(auto x : v) {
for(int i = 0; i < vals.size(); i++) {
if(vals[i] == x) {
ret.push_back(i);
break;
}
}
}
return ret;
}
/*
long long count_increasing(vector<int>& v) {
vector<long long> dp(v.size() + 1, 0);
dp[0] = 1;
for (int x : v)
{
for (int i = 0; i <= x; i++)
{
dp[x+1] += dp[i];
dp[x+1] = min(dp[x+1],MX+1);
}
}
long long result = 0;
for (int i = 0; i <= (int)v.size(); i++){
result += dp[i];
result = min(result,MX+1);
}
return result;
}
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
// auto v = construct_permutation(6);
// for(auto x : v) {
// cout << x << " ";
// }
// cout << '\n';
// cout << count_increasing(v) << '\n';
for(int i = 2; i <= 100000; i++) {
auto v = construct_permutation(i);
if(count_increasing(v) != i) {
cout << i << " keluarnya " << count_increasing(v) << '\n';
cout << bitset<7>(i) << '\n';
}
}
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |