제출 #574681

#제출 시각아이디문제언어결과실행 시간메모리
574681WongChun1234순열 (APIO22_perm)C++17
100 / 100
3 ms340 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; int pos[100]; vector<int> ret,pres; void add(int newpos){ for (auto &i:ret) if (i>=newpos) i++; ret.push_back(newpos); memset(pos,-1,sizeof(pos)); for (int i=0;i<ret.size();i++) pos[ret[i]]=i; } vector<int> construct_permutation(ll k){ memset(pos,-1,sizeof(pos)); ret.clear(); pres.clear(); while (k){ pres.push_back(k%4); k/=4; } reverse(pres.begin(),pres.end()); if (pres[0]==1){ }else if (pres[0]==2){ add(0); }else if (pres[0]==3){ add(0); add(0); } for (int i=1;i<pres.size();i++){ if (pres[i]==0){ add(ret.size()); add(ret.size()); }else if (pres[i]==1){ add(ret.size()); add(ret.size()); add(0); }else if (pres[i]==2){ add(ret.size()); add(0); add(ret.size()); }else if ((pos[0]==-1)||(pos[1]==-1)||(pos[1]>pos[0])){ add(ret.size()); add(0); add(ret.size()); add(0); }else{ add(ret.size()); add(ret.size()); add(2); } } return ret; }

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

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