Submission #1029459

# Submission time Handle Problem Language Result Execution time Memory
1029459 2024-07-20T22:44:34 Z vjudge1 CATS (NOI14_cats) C++17
0 / 25
45 ms 6228 KB
#include "bits/stdc++.h"
using namespace std;
vector<long long> _1 = {0, 1, 1, 0};
vector<long long> _2 = {0, 1, 1, 0, 1, 0, 0, 1};
vector<long long> _3 = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};
vector<long long> _4 = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0};
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long q, x, l, n;
    cin>>q;
    while(q--){
        cin>>x>>l>>n;
        long long Izquierda = 0;
        long long Derecha = l;
        long long Mejor = 0;
        while(1){
            long long Promedio = (Izquierda + Derecha) / 2;
            if(Promedio * 2 * n < l){
                Izquierda = Promedio + 1;
            } else {
                Derecha = Promedio - 1;
                Mejor = Promedio;
            }
            if(Izquierda >= Derecha + 1) break;
        }
        long long Respuesta = Mejor * 2 * n;
        bool Sufridor = Mejor + 1 - n == l;
        if(Mejor % 2 == 1 and !Sufridor){
            x--;
            x %= 4;
            cout<<Respuesta + _1[x]<<"\n";
        } else if(Mejor % 2 == 0 and !Sufridor){
            x--;
            x %= 8;
            cout<<Respuesta + _2[x]<<"\n";
        } else if(Mejor % 2 == 1 and Sufridor){
            x--;
            x %= 32;
            cout<<Respuesta + _3[x]<<"\n";
        } else {
            x--;
            x %= 64;
            cout<<Respuesta + _4[x]<<"\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 6228 KB Output isn't correct
2 Halted 0 ms 0 KB -