Submission #1207068

#TimeUsernameProblemLanguageResultExecution timeMemory
1207068LucasLeAncient Machine 2 (JOI23_ancient2)C++20
37 / 100
37 ms556 KiB
#include <bits/stdc++.h>
#include "ancient2.h"

template<typename T>
bool minimize(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool maximize(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

const int MOD = 998244353;

template<typename T>
void add(T &x, T y) {
    x += y;
    if (x >= MOD) x -= MOD;
    if (x < 0) x += MOD;
}

template<typename T>
T bin_pow(T x, T y) {
    T res = 1;
    while (y) {
        if (y & 1)
            res = 1ll * res * x % MOD;
        x = 1ll * x * x % MOD;
        y >>= 1;
    }
    return res;
}

int divi(int x, int y) {
    return x * bin_pow(y, MOD - 2) % MOD;
}

#define fi first
#define se second
#define pii std::pair<int, int>
#define ld long double

std::string Solve(int n) {
    std::string ans = "";
    for (int i = 0; i < 500; ++i) {
        std::vector<int> a(i + 3), b(i + 3);
        for (int j = 0; j < i; ++j) {
            a[j] = j + 1;
            b[j] = j + 1;
        }
        a[i] = i + 1;
        b[i] = i + 2;
        a[i + 1] = i + 1;
        b[i + 1] = i + 1;
        a[i + 2] = i + 2;
        b[i + 2] = i + 2;
        int val = Query(i + 3, a, b);
        if (val == i + 1) ans += "0";
        else ans += "1";
    }
    for (int i = 0; i < 500; ++i) {
        std::vector<int> a(501), b(501);
        for (int j = 0; j < 500; ++j) {
            a[j] = (j + 1) % 500;
            b[j] = a[j];
        }
        a[500] = (b[500] = 500);
        if (ans[i] == '0') b[i] = 500;
        else a[i] = 500;
        int val = Query(501, a, b);
        if (val == 500) {
            if (ans[i] == '0') ans += "1";
            else ans += "0";
        } else {
            ans += ans[i];
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...