제출 #896862

#제출 시각아이디문제언어결과실행 시간메모리
896862Litusiano순열 (APIO22_perm)C++17
10 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "perm.h" using namespace std; const int CT = 1000; mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count()); vector<int> shuffle(vector<int>& v){ int sz = v.size(); for(int i = 0; i < 2 * v.size(); i++){ int a = rng()%sz; int b = rng()%sz; swap(v[a],v[b]); } return v; } long long getdp(vector<int>& v, long long MX) { 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); if(dp[x+1] == MX+1) return 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; } vector<int> construct_permutation(long long k) { const int CT = 1000; if(k <= 90){ vector<int> v; for(int i = k-2; i>=0; i--){ v.push_back(i); } return v; } vector<int> v; for(int a = 1; a<=90; a++){ v.push_back(a); if(a > 8){ for(int _ = 0; _ < CT; _++){ v = shuffle(v); if(getdp(v,k) == k){ return v; } } } else{ sort(v.begin(),v.end()); do{ if(getdp(v,k) == k) return v; }while(next_permutation(v.begin(),v.end())); } } return v; }

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp: In function 'std::vector<int> shuffle(std::vector<int>&)':
perm.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i = 0; i < 2 * v.size(); i++){
      |                 ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...