Submission #912262

#TimeUsernameProblemLanguageResultExecution timeMemory
912262TienDungzPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; ll MOD = 1e9+7; double eps = 1e-12; #define fi first #define se second #define INF 2e18 #define int long long int t, n; int pre[201]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cin >> t; while (t--) { bool ok = true; cin >> n; vector<int> res; int cnt = 0; int p = 0; for (int j = 60; j >= 0; j--) { int m = 1LL << j; if (n - m >= 0) { n -=m; if (ok) { ok = false; for (int i = 1; i <= j; i++) { res.push_back(2 * i); } p = j; } else { res.push_back(2 * j + 1); } } } cout << res.size() << '\n'; for (int i = 0; i < res.size(); i++) { cout << res[i] << ' '; } cout << '\n'; } }

Compilation message (stderr)

perm.cpp: In function 'int main()':
perm.cpp:47:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int i = 0; i < res.size(); i++) {
      |                         ~~^~~~~~~~~~~~
perm.cpp:28:13: warning: unused variable 'cnt' [-Wunused-variable]
   28 |         int cnt = 0;
      |             ^~~
perm.cpp:29:13: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   29 |         int p = 0;
      |             ^
perm.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
perm.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc1ELLuq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccuj6KCo.o:perm.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc1ELLuq.o: in function `main':
grader.cpp:(.text.startup+0x240): undefined reference to `construct_permutation(long long)'
collect2: error: ld returned 1 exit status