제출 #821405

#제출 시각아이디문제언어결과실행 시간메모리
821405Hanksburger순열 (APIO22_perm)C++17
83.32 / 100
4 ms608 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { if (k%2==0) { 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> res=construct_permutation(k); int sz=res.size(); for (long long j=0; j<cnt; j++) res.push_back(j+sz); return res; } if (k%3==0) { long long cnt=0; while (k%3==0) { k/=3; cnt++; } if (k==1) { vector<int> res; for (long long i=0; i<cnt; i++) { res.push_back(i*2+1); res.push_back(i*2); } return res; } vector<int> res=construct_permutation(k); int sz=res.size(); for (long long j=0; j<cnt; j++) { res.push_back(j*2+1+sz); res.push_back(j*2+sz); } return res; } if (k%5==0) { long long cnt=0; while (k%5==0) { k/=5; cnt++; } if (k==1) { vector<int> res; for (long long i=0; i<cnt; i++) { res.push_back(i*4+3); res.push_back(i*4+2); res.push_back(i*4+1); res.push_back(i*4); } return res; } vector<int> res=construct_permutation(k); int sz=res.size(); for (long long j=0; j<cnt; j++) { res.push_back(j*4+3+sz); res.push_back(j*4+2+sz); res.push_back(j*4+1+sz); res.push_back(j*4+sz); } return res; } for (long long i=2, m=1; ; i*=2, m++) { if (i<k && i*2>k) { vector<int> res=construct_permutation(k-i+1); for (long long j=0; j<res.size(); j++) res[j]+=m; for (long long j=0; j<m; j++) res.push_back(j); return res; } } }

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

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