제출 #929136

#제출 시각아이디문제언어결과실행 시간메모리
929136Joshua_AnderssonJoker (BOI20_joker)C++14
0 / 100
2045 ms6800 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll const int inf = int(1e18); typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> p2; #define rep(i, high) for (int i = 0; i < high; i++) #define repp(i, low, high) for (int i = low; i < high; i++) #define repe(i, container) for (auto& i : container) #define sz(container) ((int)container.size()) inline void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } struct UF { vi size; vi par; vi parity; UF(int n) : size(n, 1), parity(n), par(n) { rep(i, n)par[i] = i; } int find(int x) { return x == par[x] ? x : find(par[x]); } int getparity(int x) { return x == par[x] ? parity[x] : parity[x] ^ getparity(par[x]); } bool oddcycle(int a, int b) { return getparity(a) == getparity(b); } void merge(int a, int b) { a = find(a); b = find(b); if (size[a] < size[b]) swap(a, b); if (a != b) { parity[b] ^= parity[a]; size[a] += size[b]; par[b] = a; } } }; signed main() { fast(); int n, m, q; cin >> n >> m >> q; vector<p2> edgelist; rep(i, m) { int a, b; cin >> a >> b; a--; b--; edgelist.emplace_back(a, b); } while (q--) { int l, r; cin >> l >> r; l--; r--; UF uf(n); bool any = 0; rep(i, l) { int a, b; tie(a, b) = edgelist[i]; if (uf.find(a)==uf.find(b)) any |= uf.oddcycle(a, b); uf.merge(a, b); } repp(i, r+1, m) { int a, b; tie(a, b) = edgelist[i]; if (uf.find(a) == uf.find(b)) any |= uf.oddcycle(a, b); uf.merge(a, b); } cout << (any ? "YES" : "NO") << "\n"; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Joker.cpp: In constructor 'UF::UF(ll)':
Joker.cpp:25:5: warning: 'UF::parity' will be initialized after [-Wreorder]
   25 |  vi parity;
      |     ^~~~~~
Joker.cpp:24:5: warning:   'vi UF::par' [-Wreorder]
   24 |  vi par;
      |     ^~~
Joker.cpp:27:2: warning:   when initialized here [-Wreorder]
   27 |  UF(int n) : size(n, 1), parity(n), par(n)
      |  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...