# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
689311 |
2023-01-28T06:38:40 Z |
saayan007 |
Joker (BOI20_joker) |
C++17 |
|
3 ms |
4948 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;
#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const ll mxn = 2e5L + 1;
ll n, m, q;
vpl adj[mxn];
bool vis[mxn] = {};
ll dep[mxn] = {};
struct UFDS {
vl sz;
vl lnk;
vl ene;
UFDS(ll N) {
sz = vl(N, 1);
lnk = vl(N);
iota(all(lnk), 0);
ene = vl(N, -1);
}
ll find(ll a) {
if(a == lnk[a]) {
return a;
}
return lnk[a] = find(lnk[a]);
}
bool same(ll a, ll b) {
return find(a) == find(b);
}
ll unite(ll a, ll b) {
if(a == -1)
return b;
if(b == -1)
return a;
a = find(a);
b = find(b);
if(a == b)
return a;
if(sz[a] < sz[b])
swap(a, b);
lnk[b] = a;
sz[a] += sz[b];
return a;
}
bool makeEne(ll a, ll b) {
a = find(a);
b = find(b);
if(a == b) {
return 0;
}
if(ene[a] == b) {
return 1;
}
ll c = ene[a];
ll d = ene[b];
a = unite(a, d);
b = unite(b, c);
ene[a] = b;
ene[b] = a;
return 1;
}
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> q;
pl edge[m + 1];
fur(i, 1, m) {
cin >> edge[i].fr >> edge[i].sc;
}
UFDS uf(n + 1);
ll odd_if = m + 1;
ruf(i, m, 1) {
if(!uf.makeEne(edge[i].fr, edge[i].sc)) {
odd_if = i;
break;
}
}
while(q--) {
ll l, r;
cin >> l >> r;
cout << (l <= odd_if ? "YES" : "NO") << nl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |