Submission #366043

#TimeUsernameProblemLanguageResultExecution timeMemory
366043idk321Synchronization (JOI13_synchronization)Java
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100005; vector<int> adj[N]; array<int, 2> edge[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; edge[i] = {x, y}; } vector<int> change(m); for (int i = 0; i < m; i++) cin >> change[i]; bool exist[N] = {}; set<array<int, 4>> s; for (int i = 1; i <= n; i++) { s.insert({i, i, i, i}); } for (int i = 0; i < m; i++) { int e = change[i]; int a = edge[e][0]; int b = edge[e][1]; if (exist[e]) { auto it = s.upper_bound({b, N, N, N}); it--; auto cur = *it; s.erase(it); s.insert({cur[0], a, cur[2], cur[3]}); s.insert({b, cur[1], cur[2], cur[3]}); } else { auto it1 = s.upper_bound({a, N, N, N}); it1--; auto it2 = s.upper_bound({b, N, N, N}); it2--; auto ar1 = *it1; auto ar2 = *it2; s.erase(it1); s.erase(it2); s.insert({ar1[0], ar2[1], min(ar1[2], ar2[2]), max(ar1[3], ar2[3])}); } exist[e] = !exist[e]; } for (int q1 = 0; q1 < q; q1++) { int c; cin >> c; auto it = s.upper_bound({c, N, N, N}); it--; auto cur = *it; cout << (cur[3] - cur[2] + 1) << "\n"; } } /* 6 7 6 1 2 2 3 3 4 4 5 5 6 1 1 1 3 2 2 4 1 2 3 4 5 6 */

Compilation message (stderr)

synchronization.java:2: error: illegal character: '#'
#include <bits/stdc++.h>
^
synchronization.java:2: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
synchronization.java:4: error: class, interface, or enum expected
typedef long long ll;
^
synchronization.java:6: error: class, interface, or enum expected
const int N = 100005;
^
synchronization.java:7: error: class, interface, or enum expected
vector<int> adj[N];
^
synchronization.java:8: error: class, interface, or enum expected
array<int, 2> edge[N];
^
synchronization.java:13: error: class, interface, or enum expected
int main()
^
synchronization.java:16: error: class, interface, or enum expected
    cin.tie(0);
    ^
synchronization.java:18: error: class, interface, or enum expected
    int n, m, q;
    ^
synchronization.java:19: error: class, interface, or enum expected
    cin >> n >> m >> q;
    ^
synchronization.java:20: error: class, interface, or enum expected
    for (int i = 1; i < n; i++)
    ^
synchronization.java:20: error: class, interface, or enum expected
    for (int i = 1; i < n; i++)
                    ^
synchronization.java:20: error: class, interface, or enum expected
    for (int i = 1; i < n; i++)
                           ^
synchronization.java:23: error: class, interface, or enum expected
        cin >> x >> y;
        ^
synchronization.java:24: error: class, interface, or enum expected
        edge[i] = {x, y};
        ^
synchronization.java:25: error: class, interface, or enum expected
    }
    ^
synchronization.java:28: error: class, interface, or enum expected
    for (int i = 0; i < m; i++) cin >> change[i];
    ^
synchronization.java:28: error: class, interface, or enum expected
    for (int i = 0; i < m; i++) cin >> change[i];
                    ^
synchronization.java:28: error: class, interface, or enum expected
    for (int i = 0; i < m; i++) cin >> change[i];
                           ^
synchronization.java:29: error: class, interface, or enum expected
    bool exist[N] = {};
    ^
synchronization.java:32: error: class, interface, or enum expected
    set<array<int, 4>> s;
    ^
synchronization.java:33: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++)
    ^
synchronization.java:33: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++)
                    ^
synchronization.java:33: error: class, interface, or enum expected
    for (int i = 1; i <= n; i++)
                            ^
synchronization.java:36: error: class, interface, or enum expected
    }
    ^
synchronization.java:37: error: class, interface, or enum expected
    for (int i = 0; i < m; i++)
                    ^
synchronization.java:37: error: class, interface, or enum expected
    for (int i = 0; i < m; i++)
                           ^
synchronization.java:40: error: class, interface, or enum expected
        int a = edge[e][0];
        ^
synchronization.java:41: error: class, interface, or enum expected
        int b = edge[e][1];
        ^
synchronization.java:42: error: class, interface, or enum expected
        if (exist[e])
        ^
synchronization.java:45: error: class, interface, or enum expected
            it--;
            ^
synchronization.java:46: error: class, interface, or enum expected
            auto cur = *it;
            ^
synchronization.java:47: error: class, interface, or enum expected
            s.erase(it);
            ^
synchronization.java:48: error: class, interface, or enum expected
            s.insert({cur[0], a, cur[2], cur[3]});
            ^
synchronization.java:49: error: class, interface, or enum expected
            s.insert({b, cur[1], cur[2], cur[3]});
            ^
synchronization.java:51: error: class, interface, or enum expected
        } else
        ^
synchronization.java:54: error: class, interface, or enum expected
            it1--;
            ^
synchronization.java:55: error: class, interface, or enum expected
            auto it2 = s.upper_bound({b, N, N, N});
            ^
synchronization.java:56: error: class, interface, or enum expected
            it2--;
            ^
synchronization.java:57: error: class, interface, or enum expected
            auto ar1 = *it1;
            ^
synchronization.java:58: error: class, interface, or enum expected
            auto ar2 = *it2;
            ^
synchronization.java:59: error: class, interface, or enum expected
            s.erase(it1);
            ^
synchronization.java:60: error: class, interface, or enum expected
            s.erase(it2);
            ^
synchronization.java:61: error: class, interface, or enum expected
            s.insert({ar1[0], ar2[1], min(ar1[2], ar2[2]), max(ar1[3], ar2[3])});
            ^
synchronization.java:62: error: class, interface, or enum expected
        }
        ^
synchronization.java:64: error: class, interface, or enum expected
    }
    ^
synchronization.java:66: error: class, interface, or enum expected
    for (int q1 = 0; q1 < q; q1++)
                     ^
synchronization.java:66: error: class, interface, or enum expected
    for (int q1 = 0; q1 < q; q1++)
                             ^
synchronization.java:70: error: class, interface, or enum expected
        cin >> c;
        ^
synchronization.java:71: error: class, interface, or enum expected
        auto it = s.upper_bound({c, N, N, N});
        ^
synchronization.java:72: error: class, interface, or enum expected
        it--;
        ^
synchronization.java:73: error: class, interface, or enum expected
        auto cur = *it;
        ^
synchronization.java:74: error: class, interface, or enum expected
        cout << (cur[3] - cur[2] + 1) << "\n";
        ^
synchronization.java:75: error: class, interface, or enum expected
    }
    ^
54 errors