Submission #916434

#TimeUsernameProblemLanguageResultExecution timeMemory
916434Jakub_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) { long long MAX = 300; vector <int> v; vector <bool> B; int R = n%3; int r[200]; n /= 3; if(R)v.push_back(R); while (n) { if(n < 4) { if(n < 2)break; if (n % 4 == 3) v.push_back(1); v.push_back(MAX); MAX--; break; } if (n % 4 == 1) v.push_back(1); if (n % 4 == 3) v.push_back(3); v.push_back(MAX); MAX--; if (n % 4 == 2) v.push_back(1); v.push_back(MAX); MAX--; n /= 4; } v.push_back(1); v.push_back(2); reverse(v.begin() , v.end()); for(int i = 0 ; i < v.size() ; i++) { V.push_back({v[i],-i}); } sort(V.begin() , V.end()); long long 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:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i = 0 ; i < v.size() ; i++)
      |                     ~~^~~~~~~~~~
perm.cpp:54: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]
   54 |     for(int i = 0 ; i < V.size() ;i++)
      |                     ~~^~~~~~~~~~
perm.cpp:61: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]
   61 |     for(int i = 0 ; i < V.size() ; i++)
      |                     ~~^~~~~~~~~~
perm.cpp: In function 'int main()':
perm.cpp:80:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         for(int i= 0 ; i < k.size() ; i++)
      |                        ~~^~~~~~~~~~
perm.cpp:73:21: warning: unused variable 'm' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                     ^
perm.cpp:73:24: warning: unused variable 'f' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                        ^
perm.cpp:73:27: warning: unused variable 'xa' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                           ^~
perm.cpp:73:31: warning: unused variable 'ya' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                               ^~
perm.cpp:73:35: warning: unused variable 'xb' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                                   ^~
perm.cpp:73:39: warning: unused variable 'yb' [-Wunused-variable]
   73 |     long long t, n, m, f, xa, ya, xb, yb;
      |                                       ^~
/usr/bin/ld: /tmp/ccBcQGat.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccE16sEv.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status