# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
362939 | 2021-02-04T18:57:38 Z | songc | Joker (BOI20_joker) | C++14 | 2000 ms | 14552 KB |
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define Mup(a,x) a=max(a, x) #define mup(a,x) a=min(a, x) #define all(v) v.begin(),v.end() #define lb lower_bound #define INF (1ll<<60) #define MOD 1'000'000'007 using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, M, Q; int U[202020], V[202020]; int P[404040], R[202020]; vector<pii> rb; int rt(int u){ if (P[u] < 0) return u; return rt(P[u]); } void uni(int u, int v){ u = rt(u), v = rt(v); if (u == v) return; if (P[u] > P[v]) swap(u, v); rb.pb(pii(u, P[u])); rb.pb(pii(v, P[v])); P[u] += P[v], P[v] = u; } void undo(){ pii t = rb.back(); rb.pop_back(); P[t.fi] = t.se; } void dnc(int s, int e, int r){ if (s > e) return; int m=s+e>>1, rs=rb.size(); for (int i=max(s,1); i<=m; i++){ uni(U[i], V[i]+N); uni(U[i]+N, V[i]); if (rt(U[i]) == rt(U[i]+N)){ for (int j=m; j<=e; j++) R[j] = r; while (rb.size()>rs) undo(); dnc(s, m-1, r); return; } } int rr=rb.size(); for (int i=r-1; i>s; i--){ uni(U[i], V[i]+N); uni(U[i]+N, V[i]); if (rt(U[i]) == rt(U[i]+N)){R[m] = i; break;} } while (rb.size()>rr) undo(); dnc(m+1, e, r); while (rb.size()>rs) undo(); for (int i=r-1; i>=max(R[i],1); i--){ uni(U[i], V[i]+N); uni(U[i]+N, V[i]); if (rt(U[i]) == rt(U[i]+N)){ for (int j=s; j<m; j++) R[j] = R[m]; return; } } dnc(s, m-1, R[m]); } int main(){ scanf("%d %d %d", &N, &M, &Q); for (int i=1; i<=M; i++) scanf("%d %d", &U[i], &V[i]); for (int i=1; i<=2*N; i++) P[i] = -1; dnc(0, M-1, M+1); while (Q--){ int l, r; scanf("%d %d", &l, &r); puts(r<R[l-1]?"YES":"NO"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 236 ms | 11348 KB | Output is correct |
4 | Correct | 297 ms | 14552 KB | Output is correct |
5 | Execution timed out | 2094 ms | 14296 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |