제출 #916998

#제출 시각아이디문제언어결과실행 시간메모리
916998Jakub_Wozniak순열 (APIO22_perm)C++17
100 / 100
2 ms504 KiB
#include <bits/stdc++.h> using namespace std; vector <pair<int,int>> V; vector<int> construct_permutation(long long n) { if(n == 2)return {0}; if(n == 3)return {1,0}; if(n == 4)return {0,1}; long long MAX = 900 , MIN = 0; vector <int> v; vector <int> B; long long akt = 0; int r[200]; while(n) { B.push_back(n%2); n/=2; } reverse(B.begin() , B.end()); if(B[1] == 1) { v.push_back(2); v.push_back(1); akt = 2; } else { if(B[2] == 0) { v.push_back(100); v.push_back(2); v.push_back(1); } else { v.push_back(2); v.push_back(100); v.push_back(1); } akt = 3; } while(akt+1 < B.size()) { v.push_back(MAX); MAX++; if(B[akt]*2+B[akt+1] == 2){v.push_back(MIN);MIN--;} v.push_back(MAX); MAX++; if(B[akt]*2+B[akt+1] == 1){v.push_back(MIN);MIN--;} if(B[akt]*2+B[akt+1] == 3){v.push_back(MIN+3);} akt += 2; } if(akt < B.size()) { v.push_back(MAX); MAX++; if(B[akt])v.push_back(MIN); } for(int i = 0 ; i < v.size() ; i++) { V.push_back({v[i],-i}); } sort(V.begin() , V.end()); akt = 0; for(int i = 0 ; i < V.size() ;i++) { r[-V[i].second] = akt; akt++; } for(int i = 0 ; i < V.size() ; i++) { v[i] = r[i]; } V.clear(); return v; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:49:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     while(akt+1 < B.size())
      |           ~~~~~~^~~~~~~~~~
perm.cpp:61:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     if(akt < B.size())
      |        ~~~~^~~~~~~~~~
perm.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for(int i = 0 ; i < v.size() ; i++)
      |                     ~~^~~~~~~~~~
perm.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for(int i = 0 ; i < V.size() ;i++)
      |                     ~~^~~~~~~~~~
perm.cpp:85:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for(int i = 0 ; i < V.size() ; i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...