제출 #821033

#제출 시각아이디문제언어결과실행 시간메모리
821033Hanksburger순열 (APIO22_perm)C++17
10 / 100
155 ms262144 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { if (k&1) { for (long long i=2; ; i*=2) { if (i<k && i*2>k) { vector<int> res1=construct_permutation(i); vector<int> res2=construct_permutation(k-i+1); for (long long j=0; j<res1.size(); j++) res1[j]+=res2.size(); for (long long j=0; j<res2.size(); j++) res1.push_back(res2[j]); return res1; } } } long long cnt=0; while (k%2==0) { k/=2; cnt++; } if (k==1) { vector<int> res; for (long long i=0; i<cnt; i++) res.push_back(i); return res; } vector<int> res1=construct_permutation(1<<cnt); vector<int> res2=construct_permutation(k); for (long long j=0; j<res2.size(); j++) res2[j]+=res1.size(); for (long long j=0; j<res2.size(); j++) res1.push_back(res2[j]); return res1; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:14:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |                 for (long long j=0; j<res1.size(); j++)
      |                                     ~^~~~~~~~~~~~
perm.cpp:16:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |                 for (long long j=0; j<res2.size(); j++)
      |                                     ~^~~~~~~~~~~~
perm.cpp:37:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (long long j=0; j<res2.size(); j++)
      |                         ~^~~~~~~~~~~~
perm.cpp:39:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (long long j=0; j<res2.size(); j++)
      |                         ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...