Submission #916983

#TimeUsernameProblemLanguageResultExecution timeMemory
916983Jakub_WozniakPermutation (APIO22_perm)C++17
Compilation error
0 ms0 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 = 300; 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(2); v.push_back(1); v.push_back(1); } else { v.push_back(2); v.push_back(1); v.push_back(2); } akt = 3; } while(akt+1 < B.size()) { v.push_back(MAX); MAX++; v.push_back(MAX); MAX++; if(B[akt]*2+B[akt+1])v.push_back(B[akt]*2+B[akt+1]); akt += 2; } if(akt < B.size()) { v.push_back(MAX); MAX++; if(B[akt])v.push_back(B[akt]); } 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; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t, n, m, f, xa, ya, xb, yb; cin >> t; while (t--) { cin >> n; vector <int> k = construct_permutation(n); cout << k.size() << '\n'; for(int i= 0 ; i < k.size() ; i++) { cout << k[i] << ' '; } cout << '\n'; } return 0; }

Compilation message (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:59:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if(akt < B.size())
      |        ~~~~^~~~~~~~~~
perm.cpp:69:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for(int i = 0 ; i < v.size() ; i++)
      |                     ~~^~~~~~~~~~
perm.cpp:76: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]
   76 |     for(int i = 0 ; i < V.size() ;i++)
      |                     ~~^~~~~~~~~~
perm.cpp:83: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]
   83 |     for(int i = 0 ; i < V.size() ; i++)
      |                     ~~^~~~~~~~~~
perm.cpp: In function 'int main()':
perm.cpp:102:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |         for(int i= 0 ; i < k.size() ; i++)
      |                        ~~^~~~~~~~~~
perm.cpp:95:21: warning: unused variable 'm' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                     ^
perm.cpp:95:24: warning: unused variable 'f' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                        ^
perm.cpp:95:27: warning: unused variable 'xa' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                           ^~
perm.cpp:95:31: warning: unused variable 'ya' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                               ^~
perm.cpp:95:35: warning: unused variable 'xb' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                                   ^~
perm.cpp:95:39: warning: unused variable 'yb' [-Wunused-variable]
   95 |     long long t, n, m, f, xa, ya, xb, yb;
      |                                       ^~
/usr/bin/ld: /tmp/cc0nx2pt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPfGX6w.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status