제출 #642545

#제출 시각아이디문제언어결과실행 시간메모리
642545danikoynov순열 (APIO22_perm)C++17
100 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector < int > construct_permutation(ll k) { vector < ll > dig; while(k > 0) { dig.push_back(k % 4); k /= 4; } reverse(dig.begin(), dig.end()); vector < int > v; if (dig[0] == 2) v.push_back(0); else if (dig[0] == 3) { v.push_back(1); v.push_back(0); } /**for (int i = 0; i < dig.size(); i ++) cout << dig[i] << " "; cout << endl;*/ for (int i = 1; i < dig.size(); i ++) { if (dig[i] == 0) { int mx = v.size(); v.push_back(mx); mx ++; v.push_back(mx); } else if (dig[i] == 1) { int mx = v.size(); for (int j = 0; j < v.size(); j ++) v[j] ++; mx ++; v.push_back(mx); mx ++; v.push_back(mx); v.push_back(0); } else if (dig[i] == 2) { int mx = v.size(); for (int j = 0; j < v.size(); j ++) v[j] ++; mx ++; v.push_back(mx); v.push_back(0); mx ++; v.push_back(mx); } else if (dig[i] == 3) { bool fd = false, tf = false; for (int j = 0; j < v.size(); j ++) { if (v[j] == 1) fd = true; if (v[j] == 0) { if (fd) tf = true; break; } } if (tf) { int mx = v.size(); for (int j = 0; j < v.size(); j ++) if (v[j] > 1) v[j] ++; mx ++; v.push_back(mx); mx ++; v.push_back(mx); v.push_back(2); } else { int mx = v.size(); for (int j = 0; j < v.size(); j ++) v[j] += 2; mx += 2; v.push_back(mx); mx ++; v.push_back(1); v.push_back(mx); v.push_back(0); } } } /**for (int i = 0; i < v.size(); i ++) cout << v[i] << " "; cout << endl;*/ return v; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(ll)':
perm.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 1; i < dig.size(); i ++)
      |                     ~~^~~~~~~~~~~~
perm.cpp:40:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             for (int j = 0; j < v.size(); j ++)
      |                             ~~^~~~~~~~~~
perm.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for (int j = 0; j < v.size(); j ++)
      |                             ~~^~~~~~~~~~
perm.cpp:64:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             for (int j = 0; j < v.size(); j ++)
      |                             ~~^~~~~~~~~~
perm.cpp:80:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |                 for (int j = 0; j < v.size(); j ++)
      |                                 ~~^~~~~~~~~~
perm.cpp:92:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |                 for (int j = 0; j < v.size(); j ++)
      |                                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...