Submission #912264

# Submission time Handle Problem Language Result Execution time Memory
912264 2024-01-19T09:18:05 Z TienDungz Permutation (APIO22_perm) C++17
Compilation error
0 ms 0 KB
#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

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;
      |             ^
/usr/bin/ld: /tmp/ccqVoGlC.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccj9yMEz.o:perm.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqVoGlC.o: in function `main':
grader.cpp:(.text.startup+0x240): undefined reference to `construct_permutation(long long)'
collect2: error: ld returned 1 exit status