Submission #525168

# Submission time Handle Problem Language Result Execution time Memory
525168 2022-02-11T01:55:11 Z vijay Park (BOI16_park) Java 11
Compilation error
0 ms 0 KB
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <array>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>


using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define smax(x, y) (x = max(x, y))
#define smin(x, y) (x = min(x, y))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)

template<typename T, unsigned long N>
istream & operator>>(istream& in, array<T, N>& arr) {
    F0R(i, N) in >> arr[i];
    return in;
}

using ll = long long;
using ld = long double;

template<typename T>
using vv = vector<vector<T>>;

using vi = vector<int>;
using ii = array<int, 2>;
using vii = vector<ii>;
using vvi = vv<int>;

using vll = vector<ll>;
using l2 = array<ll, 2>;
using vl2 = vector<l2>;
using vvll = vv<ll>;

template<typename T>
using minq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxq = priority_queue<T>;

template<typename T>
const ll M = 1000000007;

struct dsu {

    vector<int> p, sz;

    explicit dsu(int n) : p(n), sz(n, 1) {
        iota(p.begin(), p.end(), 0);
    }

    int rep(int x) {
        while (x != p[x]) x = p[x] = p[p[x]];
        return x;
    }

    // returns true if a and b are in the same set, and then unites them.
    bool unite(int a, int b) {
        a = rep(a), b = rep(b);
        if (sz[a] < sz[b]) swap(a, b);
        if (a != b) {
            p[b] = a;
            sz[a] += sz[b];
        }
        return a == b;
    }

    // returns true if a and b are in the same set.
    bool query(int a, int b) {
        return rep(a) == rep(b);
    }

    // returns the size of the set containing x
    int size(int x) {
        return sz[rep(x)];
    }
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
		// ifstream cin;
		// cin.open("test.in");

    int n, m, w, h;
    cin >> n >> m >> w >> h;
    vector<array<int, 3>> trees(n);
    F0R(i, n) cin >> trees[i];
    vector<array<int, 3>> visitors(m);
    F0R(i, m) {
        cin >> visitors[i][0] >> visitors[i][1];
        visitors[i][2] = i;
    }
    vector<tuple<ld, int, int>> edges;
    const int L = n, T = n+1, R = n+2, B = n+3;
    F0R(i, n) {
        auto[x1, y1, r1] = trees[i];
        FOR(j, i+1, n){
            auto[x2, y2, r2] = trees[j];
            edges.eb(sqrt(pow((ld)x1-x2,2) + pow((ld)y1-y2,2)) -r1 -r2, i, j);
        }
        edges.eb(x1-r1, L, i);
        edges.eb(y1-r1, T, i);
        edges.eb(w-(x1+r1), R, i);
        edges.eb(h-(y1+r1), B, i);
    }
    sort(all(edges));
    sort(all(visitors));
    int ce = 0;
    dsu d(n+4);
    set<int> disc;
    auto has_any = [&](vi v) -> bool {
        for (int x : v) if (disc.count(x) == 1) return true;
        return false;
    };
    vvi res(m);
    for (auto [r, e, resi] : visitors) {
        while (ce < edges.size() && get<0>(edges[ce]) < 2 * r) {
            d.unite(get<1>(edges[ce]), get<2>(edges[ce]));
            ++ce;
        }
        if (d.query(L, T)) disc.insert(0);
        if (d.query(T, R)) disc.insert(1);
        if (d.query(R, B)) disc.insert(2);
        if (d.query(B, L)) disc.insert(3);
        if (d.query(L, R)) disc.insert(4);
        if (d.query(T, B)) disc.insert(5);
        if (e == 1) {
            res[resi].pb(1);
            if (!has_any({0,1,5})) res[resi].pb(2);
            if (!has_any({0,2,4,5})) res[resi].pb(3);
            if (!has_any({0, 4, 3})) res[resi].pb(4);
        } else if (e == 4) {
            if (!has_any({0,3,4})) res[resi].pb(1);
            if (!has_any({4,5,1,3})) res[resi].pb(2);
            if (!has_any({3,2,5})) res[resi].pb(3);
            res[resi].pb(4);
        } else if (e == 3) {
            if (!has_any({0,2,4,5})) res[resi].pb(1);
            if (!has_any({2,1,4})) res[resi].pb(2);
            res[resi].pb(3);
            if (!has_any({2,3,5})) res[resi].pb(4);
        }else if (e == 2) {
            if (!has_any({0,1,5})) res[resi].pb(1);
            res[resi].pb(2);
            if (!has_any({1,2,4})) res[resi].pb(3);
            if (!has_any({4,5,1,3})) res[resi].pb(4);
        }
    }
    F0R(i, m) {
        for (int x : res[i]) cout << x;
        cout << '\n';
    }
}

Compilation message

park.java:2: error: illegal character: '#'
#include <algorithm>
^
park.java:2: error: class, interface, or enum expected
#include <algorithm>
         ^
park.java:3: error: illegal character: '#'
#include <bitset>
^
park.java:4: error: illegal character: '#'
#include <complex>
^
park.java:5: error: illegal character: '#'
#include <deque>
^
park.java:6: error: illegal character: '#'
#include <exception>
^
park.java:7: error: illegal character: '#'
#include <fstream>
^
park.java:8: error: illegal character: '#'
#include <functional>
^
park.java:9: error: illegal character: '#'
#include <iomanip>
^
park.java:10: error: illegal character: '#'
#include <ios>
^
park.java:11: error: illegal character: '#'
#include <iosfwd>
^
park.java:12: error: illegal character: '#'
#include <iostream>
^
park.java:13: error: illegal character: '#'
#include <istream>
^
park.java:14: error: illegal character: '#'
#include <array>
^
park.java:15: error: illegal character: '#'
#include <iterator>
^
park.java:16: error: illegal character: '#'
#include <limits>
^
park.java:17: error: illegal character: '#'
#include <list>
^
park.java:18: error: illegal character: '#'
#include <locale>
^
park.java:19: error: illegal character: '#'
#include <map>
^
park.java:20: error: illegal character: '#'
#include <memory>
^
park.java:21: error: illegal character: '#'
#include <new>
^
park.java:22: error: illegal character: '#'
#include <numeric>
^
park.java:23: error: illegal character: '#'
#include <ostream>
^
park.java:24: error: illegal character: '#'
#include <queue>
^
park.java:25: error: illegal character: '#'
#include <set>
^
park.java:26: error: illegal character: '#'
#include <sstream>
^
park.java:27: error: illegal character: '#'
#include <stack>
^
park.java:28: error: illegal character: '#'
#include <stdexcept>
^
park.java:29: error: illegal character: '#'
#include <streambuf>
^
park.java:30: error: illegal character: '#'
#include <string>
^
park.java:31: error: illegal character: '#'
#include <typeinfo>
^
park.java:32: error: illegal character: '#'
#include <utility>
^
park.java:33: error: illegal character: '#'
#include <valarray>
^
park.java:34: error: illegal character: '#'
#include <vector>
^
park.java:39: error: illegal character: '#'
#define all(x) (x).begin(), (x).end()
^
park.java:39: error: class, interface, or enum expected
#define all(x) (x).begin(), (x).end()
        ^
park.java:40: error: illegal character: '#'
#define pb push_back
^
park.java:41: error: illegal character: '#'
#define eb emplace_back
^
park.java:42: error: illegal character: '#'
#define smax(x, y) (x = max(x, y))
^
park.java:43: error: illegal character: '#'
#define smin(x, y) (x = min(x, y))
^
park.java:45: error: illegal character: '#'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
^
park.java:45: error: class, interface, or enum expected
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
                                       ^
park.java:45: error: class, interface, or enum expected
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
                                                ^
park.java:46: error: illegal character: '#'
#define F0R(i, a) FOR(i,0,a)
^
park.java:47: error: illegal character: '#'
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
^
park.java:47: error: class, interface, or enum expected
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
                                         ^
park.java:47: error: class, interface, or enum expected
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
                                                   ^
park.java:48: error: illegal character: '#'
#define R0F(i, a) ROF(i,0,a)
^
park.java:53: error: class, interface, or enum expected
    return in;
    ^
park.java:54: error: class, interface, or enum expected
}
^
park.java:57: error: class, interface, or enum expected
using ld = long double;
^
park.java:59: error: class, interface, or enum expected
template<typename T>
^
park.java:62: error: class, interface, or enum expected
using vi = vector<int>;
^
park.java:63: error: class, interface, or enum expected
using ii = array<int, 2>;
^
park.java:64: error: class, interface, or enum expected
using vii = vector<ii>;
^
park.java:65: error: class, interface, or enum expected
using vvi = vv<int>;
^
park.java:67: error: class, interface, or enum expected
using vll = vector<ll>;
^
park.java:68: error: class, interface, or enum expected
using l2 = array<ll, 2>;
^
park.java:69: error: class, interface, or enum expected
using vl2 = vector<l2>;
^
park.java:70: error: class, interface, or enum expected
using vvll = vv<ll>;
^
park.java:72: error: class, interface, or enum expected
template<typename T>
^
park.java:74: error: class, interface, or enum expected
template<typename T>
^
park.java:77: error: class, interface, or enum expected
template<typename T>
^
park.java:80: error: class, interface, or enum expected
struct dsu {
^
park.java:84: error: class, interface, or enum expected
    explicit dsu(int n) : p(n), sz(n, 1) {
    ^
park.java:86: error: class, interface, or enum expected
    }
    ^
park.java:90: error: class, interface, or enum expected
        return x;
        ^
park.java:91: error: class, interface, or enum expected
    }
    ^
park.java:96: error: class, interface, or enum expected
        if (sz[a] < sz[b]) swap(a, b);
        ^
park.java:97: error: class, interface, or enum expected
        if (a != b) {
        ^
park.java:99: error: class, interface, or enum expected
            sz[a] += sz[b];
            ^
park.java:100: error: class, interface, or enum expected
        }
        ^
park.java:102: error: class, interface, or enum expected
    }
    ^
park.java:107: error: class, interface, or enum expected
    }
    ^
park.java:112: error: class, interface, or enum expected
    }
    ^
park.java:115: error: class, interface, or enum expected
int main() {
^
park.java:117: error: class, interface, or enum expected
    cin.tie(0);
    ^
park.java:121: error: class, interface, or enum expected
    int n, m, w, h;
    ^
park.java:122: error: class, interface, or enum expected
    cin >> n >> m >> w >> h;
    ^
park.java:123: error: class, interface, or enum expected
    vector<array<int, 3>> trees(n);
    ^
park.java:124: error: class, interface, or enum expected
    F0R(i, n) cin >> trees[i];
    ^
park.java:125: error: class, interface, or enum expected
    vector<array<int, 3>> visitors(m);
    ^
park.java:126: error: class, interface, or enum expected
    F0R(i, m) {
    ^
park.java:128: error: class, interface, or enum expected
        visitors[i][2] = i;
        ^
park.java:129: error: class, interface, or enum expected
    }
    ^
park.java:131: error: class, interface, or enum expected
    const int L = n, T = n+1, R = n+2, B = n+3;
    ^
park.java:132: error: class, interface, or enum expected
    F0R(i, n) {
    ^
park.java:134: error: class, interface, or enum expected
        FOR(j, i+1, n){
        ^
park.java:136: error: class, interface, or enum expected
            edges.eb(sqrt(pow((ld)x1-x2,2) + pow((ld)y1-y2,2)) -r1 -r2, i, j);
            ^
park.java:137: error: class, interface, or enum expected
        }
        ^
park.java:139: error: class, interface, or enum expected
        edges.eb(y1-r1, T, i);
        ^
park.java:140: error: class, interface, or enum expected
        edges.eb(w-(x1+r1), R, i);
        ^
park.java:141: error: class, interface, or enum expected
        edges.eb(h-(y1+r1), B, i);
        ^
park.java:142: error: class, interface, or enum expected
    }
    ^
park.java:144: error: class, interface, or enum expected
    sort(all(visitors));
    ^
park.java:145: error: class, interface, or enum expected
    int ce = 0;
    ^
park.java:146: error: class, interface, or enum expected
    dsu d(n+4);
    ^
park.java:147: error: class, interface, or enum expected
    set<int> disc;
    ^
park.java:148: error: class, interface, or enum expected
    auto has_any = [&](vi v) -> bool {
    ^
park.java:150: error: class, interface, or enum expected
        return false;
        ^
100 errors