Submission #709740

#TimeUsernameProblemLanguageResultExecution timeMemory
709740gun_ganPermutation (APIO22_perm)C++17
10 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; static long long MX=1e18; vector<int> construct_permutation(long long k) { vector<vector<int>> ans; if(k > 31) { int last = 0; for(int i = 59; i >= 0; i -= 5) { ll cur = 0; for(int j = i, z = 4; j > i - 5; j--, z--) { cur += (k >> j & 1) << z; } if(cur > 0) { ans.push_back({}); for(int j = 0; j < i - 4; j++) { ans.back().push_back(last); last++; } for(int j = 0; j < cur - (i != 4); j++) { ans.back().push_back(last + cur - j - 1 - (i != 4)); } last += cur - (i != 4); } } } else { ans.push_back({}); for(int i = k - 2; i >= 0; i--) { ans.back().push_back(i); } } vector<int> ret; reverse(ans.begin(), ans.end()); for(auto x : ans) { for(auto i : x) ret.push_back(i); } 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(100); // for(auto x : v) { // cout << x << " "; // } // cout << '\n'; // cout << count_increasing(v); for(int i = 2; i <= 1000; i++) { auto v = construct_permutation(i); if(count_increasing(v) != i) { cout << i << '\n'; // for(auto x : v) cout << x << " "; // cout << '\n'; // break; } } } */

Compilation message (stderr)

perm.cpp:5:18: warning: 'MX' defined but not used [-Wunused-variable]
    5 | static long long MX=1e18;
      |                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...