75932024-01-09 23:53:43TuruTamasAutókódoláscpp17Partially correct 48/503ms4140 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
ifstream in_file("minta/be1.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
    ios::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;

ll N;

int main() {
    INTHENAMEOFGOD
    input >> N;
    bitset bits = bitset<64>(N);
    bool big = false, small = false;
    ll r_b = -1, r_s = -1;
    for (int i = 0; i < 63; i++) {
        if (!small && !bits[i] && bits[i+1]) {
            small = true;
            bitset b = bits;
            b[i] = true;
            b[i+1] = false;
            r_s = b.to_ullong();
        }
        if (!big && bits[i] && !bits[i+1]) {
            big = true;
            bitset b = bits;
            b[i] = false;
            b[i+1] = true;
            size_t first = b._Find_first();
            bitset mask = (b >> i) << i;
            b <<= 64-i;
            b >>= 64-i+first;
            b |= mask;
            r_b = b.to_ullong();
        }
    }
    cout << r_s << "\n" << r_b << endl;
}
SubtaskSumTestVerdictTimeMemory
base48/50
1Accepted0/03ms1892 KiB
2Accepted0/03ms2268 KiB
3Accepted2/23ms2388 KiB
4Accepted2/23ms2552 KiB
5Partially correct1/23ms2728 KiB
6Partially correct1/23ms2944 KiB
7Accepted2/23ms3056 KiB
8Accepted4/43ms3120 KiB
9Accepted4/43ms3252 KiB
10Accepted4/43ms3464 KiB
11Accepted4/43ms3708 KiB
12Accepted4/43ms3756 KiB
13Accepted4/43ms4140 KiB
14Accepted4/43ms4136 KiB
15Accepted4/43ms4128 KiB
16Accepted4/43ms4028 KiB
17Accepted4/43ms3904 KiB