Submission #124990

# Submission time Handle Problem Language Result Execution time Memory
124990 2019-07-04T09:56:55 Z Touubs CATS (NOI14_cats) C++17
0 / 25
574 ms 6236 KB
#include <bits/stdc++.h>
using namespace std;
#define dout if(false) cout
#define int unsigned long long

void testcase() {
    int X, L, N;
    cin >> X >> L >> N;
    int originalX = X;

    int level = L/(2*N) + 1;
    dout << "level: " << level << endl;

    int counterPerIter = 1 << level;
    int flipPerIter = 2 * counterPerIter - 1;

    int iterations = X / counterPerIter;
    int flips = iterations & 1;

    X = X % counterPerIter;

    dout << "counterPerIter: " << counterPerIter << endl;
    dout << "flipPerIter: " << flipPerIter << endl;

    while (counterPerIter > 0 && X != 0) {
        dout << "while" << endl;
        dout << "counterPerIter: " << counterPerIter << endl;
        dout << "flipPerIter: " << flipPerIter << endl;
        dout << "flips: " << flips << endl << endl;
        if (counterPerIter <= X) {
            X -= counterPerIter;
            flips = flips ^ 1;
        } else {
        }
        counterPerIter = counterPerIter >> 1;
        flipPerIter = flipPerIter >> 1;
        level--;
    }

    dout << endl << "end. flips: " << flips << endl;
    int min = (L/(2*N) + 1) * (2*N);
    cout << ((min | ((~flips) & 1)) ^ ((~originalX) & 1)) << endl;
}

signed main() {
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        testcase();
    }
    
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 574 ms 6236 KB Output isn't correct
2 Halted 0 ms 0 KB -