답안 #689320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689320 2023-01-28T07:09:16 Z zeroesandones Joker (BOI20_joker) C++17
컴파일 오류
0 ms 0 KB
    #include "bits/stdc++.h"
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef vector<ll> vi;
    typedef pair<ll, ll> pi;
     
    #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
    #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
    #define nl "\n"
    #define sp " "
     
    #define all(x) (x).begin(), (x).end()
    #define sc second
    #define fr first
    #define pb emplace_back
     
    struct UFDS {
        vi link, sz, len;
        int n;
     
        UFDS(int N) {
            init(N);
        }
     
        void init(int N) {
            n = N;
            link = vi(n);
            iota(all(link), 0);
            sz = vi(n, 1);
            len = vi(n, 0);
        }
     
        pi find(ll x) {
            if(link[x] == x)
                return {x, 0};
            pi val = find(link[x]);
            link[x] = val.fr;
            len[x] = (len[x] + val.sc) % 2;
            return {link[x], len[x]};
        }
     
        void unite(ll a, ll b) {
            pi A = find(a);
            pi B = find(b);
            if(A.fr == B.fr) return;
            if(sz[A.fr] < sz[B.fr]) swap(A, B);
     
            link[B.fr] = A.fr;
            len[B.fr] = (1 + A.sc + B.sc) % 2;
            sz[A.fr] += sz[B.fr];
        }
     
        bool same(ll a, ll b){
            return (find(a) == find(b));
        }
    };
     
    void solve()
    {
        ll n, m, q;
        cin >> n >> m >> q;
     
        vector<pi> e(m + 1);
        FOR(i, 1, m + 1) {
            cin >> e[i].fr >> e[i].sc;
        }
     
        UFDS uf(n + 1);
     
        vector<pi> query[201];
        FOR(i, 0, q) {
            ll l, r;
            cin >> l >> r;
            query[l].pb(r, i);
        }
        vector<bool> ans(q, false);
     
        FOR(i, 0, 201) {
            sort(all(query[i]), [&](pi x, pi y) {
                    return x.fr > y.fr;
                    });
        }
     
        FOR(T, 1, 201) {
            bool cyc = false;
            uf.init(n + 1);
            FOR(i, 1, min(T + 1, m + 1)) {
                if(uf.same(e[i].fr, e[i].sc)) {
                    pi A = uf.find(e[i].fr);
                    pi B = uf.find(e[i].sc);
                    if(A.sc == B.sc) {
                        cyc = true;
                    }
                } else {
                    uf.unite(e[i].fr, e[i].sc);
                }
            }
            ll r = m;
            for(auto i : query[T]) {
                while(r > i.fr) {
                    if(uf.same(e[r].fr, e[r].sc)) {
                        pi A = uf.find(e[r].fr);
                        pi B = uf.find(e[r].sc);
                        if(A.sc == B.sc) {
                            cyc = true;
                        }
                    } else {
                        uf.unite(e[r].fr, e[r].sc);
                    }
                    --r;
                }
                ans[i.sc] = cyc;
            }
        }
     
        for(auto i : ans) {
            cout << (i ? "YES" : "NO") << nl;
        }
    }
     
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
     
        ll t = 1;
        // cin >> t;
        while (t--)
        {
            solve();
        }
    }

Compilation message

Joker.cpp:3:5: error: extended character   is not valid in an identifier
    3 |      
      |     ^
Joker.cpp:8:5: error: extended character   is not valid in an identifier
    8 |      
      |     ^
Joker.cpp:13:5: error: extended character   is not valid in an identifier
   13 |      
      |     ^
Joker.cpp:18:5: error: extended character   is not valid in an identifier
   18 |      
      |     ^
Joker.cpp:22:5: error: extended character   is not valid in an identifier
   22 |      
      |     ^
Joker.cpp:26:5: error: extended character   is not valid in an identifier
   26 |      
      |     ^
Joker.cpp:34:5: error: extended character   is not valid in an identifier
   34 |      
      |     ^
Joker.cpp:43:5: error: extended character   is not valid in an identifier
   43 |      
      |     ^
Joker.cpp:49:5: error: extended character   is not valid in an identifier
   49 |      
      |     ^
Joker.cpp:54:5: error: extended character   is not valid in an identifier
   54 |      
      |     ^
Joker.cpp:59:5: error: extended character   is not valid in an identifier
   59 |      
      |     ^
Joker.cpp:64:5: error: extended character   is not valid in an identifier
   64 |      
      |     ^
Joker.cpp:69:5: error: extended character   is not valid in an identifier
   69 |      
      |     ^
Joker.cpp:71:5: error: extended character   is not valid in an identifier
   71 |      
      |     ^
Joker.cpp:79:5: error: extended character   is not valid in an identifier
   79 |      
      |     ^
Joker.cpp:85:5: error: extended character   is not valid in an identifier
   85 |      
      |     ^
Joker.cpp:117:5: error: extended character   is not valid in an identifier
  117 |      
      |     ^
Joker.cpp:122:5: error: extended character   is not valid in an identifier
  122 |      
      |     ^
Joker.cpp:127:5: error: extended character   is not valid in an identifier
  127 |      
      |     ^
Joker.cpp:3:5: error: '\U000000a0' does not name a type
    3 |      
      |     ^
Joker.cpp:6:20: error: 'll' was not declared in this scope; did you mean 'ld'?
    6 |     typedef vector<ll> vi;
      |                    ^~
      |                    ld
Joker.cpp:6:22: error: template argument 1 is invalid
    6 |     typedef vector<ll> vi;
      |                      ^
Joker.cpp:6:22: error: template argument 2 is invalid
Joker.cpp:7:18: error: 'll' was not declared in this scope; did you mean 'ld'?
    7 |     typedef pair<ll, ll> pi;
      |                  ^~
      |                  ld
Joker.cpp:7:22: error: 'll' was not declared in this scope; did you mean 'ld'?
    7 |     typedef pair<ll, ll> pi;
      |                      ^~
      |                      ld
Joker.cpp:7:24: error: template argument 1 is invalid
    7 |     typedef pair<ll, ll> pi;
      |                        ^
Joker.cpp:7:24: error: template argument 2 is invalid
Joker.cpp:8:5: error: '\U000000a0' does not name a type
    8 |      
      |     ^
Joker.cpp:59:5: error: '\U000000a0' does not name a type
   59 |      
      |     ^
Joker.cpp:122:5: error: '\U000000a0' does not name a type
  122 |      
      |     ^