fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 1000010;
  6. const long long MOD = 1e14 + 7;
  7.  
  8. int n, m, q;
  9. long long edge[N];
  10. long long hashValue[N];
  11.  
  12. int main (int argc, char const *argv[]) {
  13. scanf("%d %d", &n, &m);
  14. for (int i = 1; i <= n; ++i) {
  15. hashValue[i] = (rand() * 1LL * rand()) % MOD;
  16. }
  17. for (int i = 1; i <= m; ++i) {
  18. int u, v;
  19. scanf("%d %d", &u, &v);
  20. edge[i] = hashValue[u] ^ hashValue[v];
  21. }
  22. for (int i = 1; i <= m; ++i) {
  23. edge[i] ^= edge[i - 1];
  24. }
  25. scanf("%d", &q);
  26. for (int i = 1; i <= q; ++i) {
  27. int l, r;
  28. scanf("%d %d", &l, &r);
  29. puts(edge[r] ^ edge[l - 1] ? "No" : "Yes");
  30. }
  31. return 0;
  32. }
  33.  
  34.  
Success #stdin #stdout 0s 30864KB
stdin
4 6
1 2
3 1
2 3
4 1
2 4
1 2
3
1 3
2 4
1 6
stdout
Yes
No
Yes