Submission #768324

#TimeUsernameProblemLanguageResultExecution timeMemory
768324DylanSmithXOR (IZhO12_xor)Java
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x),end(x) #define lb(x,y) lower_bound(all(x),y)-begin(x) mt19937 rng; typedef struct node { int l, r; int mn; node() { l = r = -1; mn = INT_MAX; } } node; vector<node> tree(1); int add(int n) { int cur = 0; for (int i = 29; i >= 0; i--) { if ((n & 1 << i) == 0) { if (tree[cur].l == -1) { tree[cur].l = sz(tree); tree.emplace_back(); } cur = tree[cur].l; } else { if (tree[cur].r == -1) { tree[cur].r = sz(tree); tree.emplace_back(); } cur = tree[cur].r; } } return cur; } void solve() { int N, K; cin >> N >> K; vector<int> arr(N); for (int i = 0; i < N; i++) cin >> arr[i]; tree[add(0)].mn = -1; vector<int> pre(N); for (int i = 0; i < N; i++) { pre[i] = arr[i]; pre[i] ^= i == 0 ? 0 : pre[i - 1]; int u = add(pre[i]); tree[u].mn = min(tree[u].mn, i); } for (int i = sz(tree) - 1; i >= 0; i--) { if (tree[i].l != -1) tree[i].mn = min(tree[i].mn, tree[tree[i].l].mn); if (tree[i].r != -1) tree[i].mn = min(tree[i].mn, tree[tree[i].r].mn); } vector<int> res = {0, 0}; for (int i = 0; i < N; i++) { int cur = 0; int mn = INT_MAX; for (int j = 29; j >= 0; j--) { if (cur == -1) continue; if ((K & 1 << j) == 0) { if ((pre[i] & 1 << j) == 0) { if (tree[cur].r != -1) mn = min(mn, tree[tree[cur].r].mn); cur = tree[cur].l; } else { if (tree[cur].l != -1) mn = min(mn, tree[tree[cur].l].mn); cur = tree[cur].r; } } else { if ((pre[i] & 1 << j) == 0) { cur = tree[cur].r; } else { cur = tree[cur].l; } } } if (cur != -1) mn = min(mn, tree[cur].mn); if (mn == INT_MAX) continue; if (mn < i) { if (i - mn > res[1]) { res = {mn, i - mn}; } } } cout << (res[0] + 2) << " " << res[1] << "\n"; } void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); rng = mt19937(chrono::steady_clock::now().time_since_epoch().count()); setIO("c"); solve(); return 0; }

Compilation message (stderr)

xor.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
xor.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
xor.java:5: error: class, interface, or enum expected
typedef long long ll;
^
xor.java:7: error: illegal character: '#'
#define pb push_back
^
xor.java:7: error: class, interface, or enum expected
#define pb push_back
        ^
xor.java:8: error: illegal character: '#'
#define sz(x) (int)x.size()
^
xor.java:9: error: illegal character: '#'
#define all(x) begin(x),end(x)
^
xor.java:10: error: illegal character: '#'
#define lb(x,y) lower_bound(all(x),y)-begin(x)
^
xor.java:14: error: class, interface, or enum expected
typedef struct node {
^
xor.java:15: error: class, interface, or enum expected
    int l, r; int mn;
              ^
xor.java:16: error: class, interface, or enum expected
    node() {
    ^
xor.java:17: error: class, interface, or enum expected
        l = r = -1; mn = INT_MAX;
                    ^
xor.java:18: error: class, interface, or enum expected
    }
    ^
xor.java:21: error: class, interface, or enum expected
vector<node> tree(1);
^
xor.java:23: error: class, interface, or enum expected
int add(int n) {
^
xor.java:25: error: class, interface, or enum expected
    for (int i = 29; i >= 0; i--) {
    ^
xor.java:25: error: class, interface, or enum expected
    for (int i = 29; i >= 0; i--) {
                     ^
xor.java:25: error: class, interface, or enum expected
    for (int i = 29; i >= 0; i--) {
                             ^
xor.java:29: error: class, interface, or enum expected
                tree.emplace_back();
                ^
xor.java:30: error: class, interface, or enum expected
            }
            ^
xor.java:32: error: class, interface, or enum expected
        } else {
        ^
xor.java:35: error: class, interface, or enum expected
                tree.emplace_back();
                ^
xor.java:36: error: class, interface, or enum expected
            }
            ^
xor.java:38: error: class, interface, or enum expected
        }
        ^
xor.java:41: error: class, interface, or enum expected
}
^
xor.java:44: error: class, interface, or enum expected
    int N, K; cin >> N >> K;
              ^
xor.java:45: error: class, interface, or enum expected
    vector<int> arr(N);
    ^
xor.java:46: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) cin >> arr[i];
    ^
xor.java:46: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) cin >> arr[i];
                    ^
xor.java:46: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) cin >> arr[i];
                           ^
xor.java:47: error: class, interface, or enum expected
    tree[add(0)].mn = -1;
    ^
xor.java:48: error: class, interface, or enum expected
    vector<int> pre(N);
    ^
xor.java:49: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
    ^
xor.java:49: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
                    ^
xor.java:49: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
                           ^
xor.java:51: error: class, interface, or enum expected
        pre[i] ^= i == 0 ? 0 : pre[i - 1];
        ^
xor.java:52: error: class, interface, or enum expected
        int u = add(pre[i]);
        ^
xor.java:53: error: class, interface, or enum expected
        tree[u].mn = min(tree[u].mn, i);
        ^
xor.java:54: error: class, interface, or enum expected
    }
    ^
xor.java:55: error: class, interface, or enum expected
    for (int i = sz(tree) - 1; i >= 0; i--) {
                               ^
xor.java:55: error: class, interface, or enum expected
    for (int i = sz(tree) - 1; i >= 0; i--) {
                                       ^
xor.java:57: error: class, interface, or enum expected
        if (tree[i].r != -1) tree[i].mn = min(tree[i].mn, tree[tree[i].r].mn);
        ^
xor.java:58: error: class, interface, or enum expected
    }
    ^
xor.java:60: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
    ^
xor.java:60: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
                    ^
xor.java:60: error: class, interface, or enum expected
    for (int i = 0; i < N; i++) {
                           ^
xor.java:62: error: class, interface, or enum expected
        int mn = INT_MAX;
        ^
xor.java:63: error: class, interface, or enum expected
        for (int j = 29; j >= 0; j--) {
        ^
xor.java:63: error: class, interface, or enum expected
        for (int j = 29; j >= 0; j--) {
                         ^
xor.java:63: error: class, interface, or enum expected
        for (int j = 29; j >= 0; j--) {
                                 ^
xor.java:65: error: class, interface, or enum expected
            if ((K & 1 << j) == 0) {
            ^
xor.java:68: error: class, interface, or enum expected
                    cur = tree[cur].l;
                    ^
xor.java:69: error: class, interface, or enum expected
                } else {
                ^
xor.java:71: error: class, interface, or enum expected
                    cur = tree[cur].r;
                    ^
xor.java:72: error: class, interface, or enum expected
                }
                ^
xor.java:76: error: class, interface, or enum expected
                } else {
                ^
xor.java:78: error: class, interface, or enum expected
                }
                ^
xor.java:82: error: class, interface, or enum expected
        if (mn == INT_MAX) continue;
        ^
xor.java:83: error: class, interface, or enum expected
        if (mn < i) {
        ^
xor.java:86: error: class, interface, or enum expected
            }
            ^
xor.java:90: error: class, interface, or enum expected
}
^
xor.java:94: error: class, interface, or enum expected
    freopen((s + ".out").c_str(), "w", stdout);
    ^
xor.java:95: error: class, interface, or enum expected
}
^
xor.java:99: error: class, interface, or enum expected
    cin.tie(nullptr);
    ^
xor.java:100: error: class, interface, or enum expected
    rng = mt19937(chrono::steady_clock::now().time_since_epoch().count());
    ^
xor.java:102: error: class, interface, or enum expected
    setIO("c");
    ^
xor.java:103: error: class, interface, or enum expected
    solve();
    ^
xor.java:105: error: class, interface, or enum expected
    return 0;
    ^
xor.java:106: error: class, interface, or enum expected
}
^
69 errors