제출 #709760

#제출 시각아이디문제언어결과실행 시간메모리
709760gun_gan순열 (APIO22_perm)C++17
91.33 / 100
3 ms352 KiB
#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'; } } } */

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

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