36322023-03-01 12:28:26norbertvidaAutókódoláscpp17Accepted 50/503ms3760 KiB
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {

    iostream::sync_with_stdio(0);
    cin.tie(0);

    lli N;
    cin >> N;

    vector<bool> elozo(64, 0), kov(64, 0);
    int i = 63;
    while(N) {
        elozo[i] = kov[i] = N & 1;
        N >>= 1;
        i--;
    }

    bool nincs_elozo = prev_permutation(elozo.begin(), elozo.end());
    next_permutation(kov.begin(), kov.end());

    lli kovval = 0, elozoval = 0;
    for(int i = 0; i < 64; i++) {
        kovval = (kovval << 1) ^ kov[i];
        elozoval = (elozoval << 1) ^ elozo[i];
    }

    cout << (nincs_elozo ? elozoval : -1) << "\n" << kovval << "\n";

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/03ms2016 KiB
3Accepted2/22ms2236 KiB
4Accepted2/23ms2332 KiB
5Accepted2/22ms2416 KiB
6Accepted2/23ms2544 KiB
7Accepted2/23ms2772 KiB
8Accepted4/43ms2844 KiB
9Accepted4/43ms2968 KiB
10Accepted4/43ms3048 KiB
11Accepted4/43ms3156 KiB
12Accepted4/43ms3284 KiB
13Accepted4/42ms3380 KiB
14Accepted4/43ms3664 KiB
15Accepted4/43ms3524 KiB
16Accepted4/43ms3668 KiB
17Accepted4/43ms3760 KiB