Submission #1093646

# Submission time Handle Problem Language Result Execution time Memory
1093646 2024-09-27T07:28:05 Z duyhoanho Joker (BOI20_joker) C++17
14 / 100
2000 ms 8256 KB
#include<bits/stdc++.h>
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
using namespace std;
const int N = 2e5+10;
int n,m,p[N],sz[N],lz[N],q;
pii ad[N];
int pa(int v,int &c)
{
  c ^= lz[v];
  if(p[v] == v) return v;
  return pa(p[v] , c);
}
void join(int a,int b)
{
  int ca = 0;
  int cb = 0;
  a = pa(a,ca);
  b = pa(b,cb);
  if(a != b)
  {
    if(sz[a] < sz[b]) swap(a,b);
    sz[a] += sz[b];
    p[b] = a;
    if(ca == cb) lz[b] = 1;
  }
}
bool check(int a,int b)
{
  int ca = 0;
  int cb = 0;
  a = pa(a,ca);
  b = pa(b,cb);
  if(a == b && ca == cb) return true;
  return false;
}
bool qu(int l,int r)
{
  forinc(i,1,n)
  {
    sz[i] = 1;
    p[i] = i;
    lz[i] = 0;
  }
  for(int i=1;i<=m;i++)
  {
    if(l<=i && i<=r) continue;
    if(check(ad[i].fi , ad[i].se)) return true;
    join(ad[i].fi , ad[i].se);
  }
  return false;
}
int32_t main()
{
    if(fopen("task.inp","r"))
    {
        freopen("task.inp","r",stdin);
        freopen("task.out","w",stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>q;
    forinc(i,1,m)
    {
        int x,y;
        cin>>x>>y;
        ad[i] = {x,y};
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<< (qu(l,r) ? "YES\n" : "NO\n");
    }


}

Compilation message

Joker.cpp: In function 'int32_t main()':
Joker.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen("task.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen("task.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 496 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 496 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 15 ms 344 KB Output is correct
30 Correct 19 ms 600 KB Output is correct
31 Correct 17 ms 604 KB Output is correct
32 Correct 16 ms 580 KB Output is correct
33 Correct 7 ms 348 KB Output is correct
34 Correct 14 ms 600 KB Output is correct
35 Correct 22 ms 604 KB Output is correct
36 Correct 14 ms 604 KB Output is correct
37 Correct 28 ms 600 KB Output is correct
38 Correct 27 ms 348 KB Output is correct
39 Correct 35 ms 600 KB Output is correct
40 Correct 13 ms 348 KB Output is correct
41 Correct 23 ms 584 KB Output is correct
42 Correct 13 ms 348 KB Output is correct
43 Correct 17 ms 348 KB Output is correct
44 Correct 28 ms 348 KB Output is correct
45 Correct 16 ms 604 KB Output is correct
46 Correct 19 ms 604 KB Output is correct
47 Correct 15 ms 348 KB Output is correct
48 Correct 16 ms 576 KB Output is correct
49 Correct 18 ms 512 KB Output is correct
50 Correct 28 ms 348 KB Output is correct
51 Correct 20 ms 580 KB Output is correct
52 Correct 16 ms 580 KB Output is correct
53 Correct 17 ms 348 KB Output is correct
54 Correct 21 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 2045 ms 5724 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 496 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Execution timed out 2045 ms 5724 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 496 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 15 ms 344 KB Output is correct
30 Correct 19 ms 600 KB Output is correct
31 Correct 17 ms 604 KB Output is correct
32 Correct 16 ms 580 KB Output is correct
33 Correct 7 ms 348 KB Output is correct
34 Correct 14 ms 600 KB Output is correct
35 Correct 22 ms 604 KB Output is correct
36 Correct 14 ms 604 KB Output is correct
37 Correct 28 ms 600 KB Output is correct
38 Correct 27 ms 348 KB Output is correct
39 Correct 35 ms 600 KB Output is correct
40 Correct 13 ms 348 KB Output is correct
41 Correct 23 ms 584 KB Output is correct
42 Correct 13 ms 348 KB Output is correct
43 Correct 17 ms 348 KB Output is correct
44 Correct 28 ms 348 KB Output is correct
45 Correct 16 ms 604 KB Output is correct
46 Correct 19 ms 604 KB Output is correct
47 Correct 15 ms 348 KB Output is correct
48 Correct 16 ms 576 KB Output is correct
49 Correct 18 ms 512 KB Output is correct
50 Correct 28 ms 348 KB Output is correct
51 Correct 20 ms 580 KB Output is correct
52 Correct 16 ms 580 KB Output is correct
53 Correct 17 ms 348 KB Output is correct
54 Correct 21 ms 596 KB Output is correct
55 Execution timed out 2027 ms 8256 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 496 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 15 ms 344 KB Output is correct
30 Correct 19 ms 600 KB Output is correct
31 Correct 17 ms 604 KB Output is correct
32 Correct 16 ms 580 KB Output is correct
33 Correct 7 ms 348 KB Output is correct
34 Correct 14 ms 600 KB Output is correct
35 Correct 22 ms 604 KB Output is correct
36 Correct 14 ms 604 KB Output is correct
37 Correct 28 ms 600 KB Output is correct
38 Correct 27 ms 348 KB Output is correct
39 Correct 35 ms 600 KB Output is correct
40 Correct 13 ms 348 KB Output is correct
41 Correct 23 ms 584 KB Output is correct
42 Correct 13 ms 348 KB Output is correct
43 Correct 17 ms 348 KB Output is correct
44 Correct 28 ms 348 KB Output is correct
45 Correct 16 ms 604 KB Output is correct
46 Correct 19 ms 604 KB Output is correct
47 Correct 15 ms 348 KB Output is correct
48 Correct 16 ms 576 KB Output is correct
49 Correct 18 ms 512 KB Output is correct
50 Correct 28 ms 348 KB Output is correct
51 Correct 20 ms 580 KB Output is correct
52 Correct 16 ms 580 KB Output is correct
53 Correct 17 ms 348 KB Output is correct
54 Correct 21 ms 596 KB Output is correct
55 Execution timed out 2045 ms 5724 KB Time limit exceeded
56 Halted 0 ms 0 KB -