QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#431776#3501. Jailsnpmrnhlol5 364ms88728kbC++147.7kb2024-06-06 04:15:422024-06-06 04:15:43

Judging History

你现在查看的是最新测评结果

  • [2024-06-06 04:15:43]
  • 评测
  • 测评结果:5
  • 用时:364ms
  • 内存:88728kb
  • [2024-06-06 04:15:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 12e4;
const int S = 5*N;
const int logN = 20;
int t;
vector <int> e[N];
vector <int> e2[S];
int deg[S];
int n,m;
int ls[S],rs[S];
queue <int> q;
int cnt = 0;
int root1;
int root2;
int sub[N];
int dpth[N];
int cnt2 = 0;
int st[N],st2[N];
int starts[N],endz[N];
int top[N];
int p1[N],p2[N];
int su[N],sw[N];
int pr[N];
int rmq[N][logN];
void build1(int l = 0,int r = n - 1,int node = 0){
    if(l != r){
        int mij = (l + r)/2;
        if(l != mij)ls[node] = cnt++;
        else ls[node] = p1[mij];
        if(mij + 1 != r)rs[node] = cnt++;
        else rs[node] = p1[mij + 1];
        e2[node].push_back(ls[node]);
        e2[node].push_back(rs[node]);
        build1(l,mij,ls[node]);
        build1(mij + 1,r,rs[node]);
    }
}
void build2(int l = 0,int r = n - 1,int node = 0){
    if(l != r){
        int mij = (l + r)/2;
        if(l != mij)ls[node] = cnt++;
        else ls[node] = p2[mij];
        if(mij + 1 != r)rs[node] = cnt++;
        else rs[node] = p2[mij + 1];
        e2[ls[node]].push_back(node);
        e2[rs[node]].push_back(node);
        build2(l,mij,ls[node]);
        build2(mij + 1,r,rs[node]);
    }
}
void dfs(int node, int p){
    pr[node] = p;
    sub[node] = 1;
    if(p == -1)dpth[node] = 0;
    else dpth[node] = dpth[p] + 1;
    for(auto i:e[node]){
        if(i == p)continue;
        dfs(i, node);
        sub[node]+=sub[i];
    }
    int mxid = -1;
    for(int i = 0;i < e[node].size();i++){
        if(e[node][i] == p)continue;
        if(mxid == -1 || sub[e[node][mxid]] < sub[e[node][i]]){
            mxid = i;
        }
    }
    if(mxid != -1){
        swap(e[node][mxid],e[node][0]);
    }
    for(int i = 0;i < e[node].size();i++){
        if(e[node][i] == p){
            swap(e[node][i],e[node].back());
            e[node].pop_back();
            break;
        }
    }
}
int last[N],first[N];
int laen[N],firen[N];
int rp1[N],rp2[N];
int cnt3 = 0,cnt4 = 0;
void dfs2(int node, int p){
    //cout<<node<<' '<<p<<'\n';
    st[node] = cnt2++;
    st2[cnt2 - 1] = node;
    bool ok = 0;
    if(starts[node] != -1){
        rp1[node] = cnt3++;
        p1[cnt3 - 1] = starts[node];
    }
    if(endz[node] != -1){
        rp2[node] = cnt4++;
        p2[cnt4 - 1] = endz[node];
    }
    if(starts[node] != -1){
        first[node] = node;
    }else if(top[node] == node){
        first[node] = -1;
    }else{
        first[node] = first[p];
    }
    if(endz[node] != -1){
        firen[node] = node;
    }else if(top[node] == node){
        firen[node] = -1;
    }else{
        firen[node] = firen[p];
    }
    for(auto i:e[node]){
        if(i == p)continue;
        if(!ok){
            top[i] = top[node];
        }else{
            top[i] = i;
        }
        dfs2(i, node);
        ok = 1;
    }
    if(starts[node] != -1){
        last[node] = node;
    }else if(!e[node].empty()){
        last[node] = last[e[node][0]];
    }else{
        last[node] = -1;
    }
    if(endz[node] != -1){
        laen[node] = node;
    }else if(!e[node].empty()){
        laen[node] = laen[e[node][0]];
    }else{
        laen[node] = -1;
    }
}
void updstart(int ql,int qr,int id,int l = 0,int r = m - 1,int node = root1){
    assert(ql <= qr);
    if(ql <= l && r <= qr){
        e2[id].push_back(node);
    }else{
        int mij = (l + r)/2;
        if(qr <= mij){
            updstart(ql,qr,id,l,mij,ls[node]);
        }else if(mij + 1 <= ql){
            updstart(ql,qr,id,mij + 1,r,rs[node]);
        }else{
            updstart(ql,qr,id,l,mij,ls[node]);
            updstart(ql,qr,id,mij + 1,r,rs[node]);
        }
    }
}
void updends(int ql,int qr,int id,int l = 0,int r = m - 1,int node = root2){
    assert(ql <= qr);
    if(ql <= l && r <= qr){
        e2[node].push_back(id);
    }else{
        int mij = (l + r)/2;
        if(qr <= mij){
            updends(ql,qr,id,l,mij,ls[node]);
        }else if(mij + 1 <= ql){
            updends(ql,qr,id,mij + 1,r,rs[node]);
        }else{
            updends(ql,qr,id,l,mij,ls[node]);
            updends(ql,qr,id,mij + 1,r,rs[node]);
        }
    }
}
int prog(int u,int w){
    int df = dpth[w] - dpth[u] - 1;
    if(df < 0)return pr[u];
    for(int i = logN - 1;i >= 0;i--){
        if(df>>i&1){
            df-=(1<<i);
            w = rmq[w][i];
        }
    }
    if(pr[w] == u)return w;
    return pr[u];
}
void addstarts(int u,int w,int id){
    u = prog(u,w);
    //cout<<u<<' '<<w<<'\n';
    while(top[u] != top[w]){
        if(dpth[top[u]] > dpth[top[w]])swap(u,w);
        if(first[top[w]] != -1 && last[w] != -1 && rp1[last[w]] <= rp1[first[top[w]]]){
            //cout<<last[w]<<' '<<first[top[w]]<<' '<<id<<"skflasfjk\n";
            updstart(rp1[last[w]],rp1[first[top[w]]],id);
        }
        w = pr[top[w]];
    }
    if(dpth[u] > dpth[w])swap(u,w);
    if(first[w] != -1 && last[u] != -1 && rp1[last[u]] <= rp1[first[w]]){
        //cout<<last[u]<<' '<<first[w]<<' '<<id<<"skflasfjk\n";
        updstart(rp1[last[u]],rp1[first[w]],id);
    }
}
void addends(int u,int w,int id){
    w = prog(w,u);
    while(top[u] != top[w]){
        if(dpth[top[u]] > dpth[top[w]])swap(u,w);
        if(firen[top[w]] != -1 && laen[w] != -1 && rp2[laen[u]] <= rp2[firen[top[w]]]){
            updends(rp2[laen[w]],rp2[firen[top[w]]],id);
        }
        w = pr[top[w]];
    }
    if(dpth[u] > dpth[w])swap(u,w);
    if(firen[w] != -1 && laen[u] != -1 && rp2[laen[u]] <= rp2[firen[w]]){
        updends(rp2[laen[u]],rp2[firen[w]],id);
    }
}
bool topsort(){
    int nr = 0;
    for(int i = 0;i < cnt;i++){
        deg[i] = 0;
    }
    for(int i = 0;i < cnt;i++){
        for(auto j:e2[i]){
            deg[j]++;
        }
    }
    for(int i = 0;i < cnt;i++){
        if(deg[i] == 0)q.push(i);
    }
    while(!q.empty()){
        int x = q.front();
        nr++;
        q.pop();
        for(auto i:e2[x]){
            deg[i]--;
            if(deg[i] == 0){
                q.push(i);
            }
        }
    }
    return nr == cnt;
}
vector <pair<int,int>> dbg;
void solve(){
    cnt3 = cnt4 = 0;
    cin>>n;
    for(int i = 0;i < n - 1;i++){
        int u,w;
        cin>>u>>w;
        u--;w--;
        e[w].push_back(u);
        e[u].push_back(w);
        if(t == 8){
            dbg.push_back({u,w});
        }
    }
    for(int i = 0;i < n;i++){
        starts[i] = -1;
        endz[i] = -1;
    }
    cin>>m;
    for(int i = 0;i < m;i++){
        int u,w;
        cin>>u>>w;
        u--;w--;
        starts[u] = i;
        endz[w] = i;
        su[i] = u;
        sw[i] = w;
    }
    cnt2 = 0;
    top[0] = 0;
    dfs(0, -1);
    dfs2(0, -1);
    cnt = m;
    root1 = cnt++;
    build1(0,m - 1,cnt - 1);
    root2 = cnt++;
    build2(0,m - 1,cnt - 1);
    /*for(int i = 0;i < n;i++){
        for(auto j:e2[i]){
            cout<<"edge:"<<i<<' '<<j<<'\n';
        }
    }*/
    for(int i = 0;i < n;i++){
        rmq[i][0] = pr[i];
    }
    for(int j = 1;j < logN;j++){
        for(int i = 0;i < n;i++){
            rmq[i][j] = rmq[rmq[i][j - 1]][j - 1];
        }
    }
    for(int i = 0;i < m;i++){
        int u = su[i];
        int w = sw[i];
        addstarts(u,w,i);
        addends(u,w,i);
    }
    bool ok = topsort();
    if(ok){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    for(int i = 0;i < n;i++){
        e[i].clear();
    }
    for(int i = 0;i < cnt;i++){
        e2[i].clear();
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 4ms
memory: 38808kb

input:

1
2
1 2
2
1 2
2 1

output:

No

result:

ok single line: 'No'

Test #2:

score: 5
Accepted
time: 7ms
memory: 36408kb

input:

462
120
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

output:

No
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
No
No
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
No
Yes
No
No
No
Ye...

result:

ok 462 lines

Test #3:

score: 5
Accepted
time: 11ms
memory: 35828kb

input:

1000
120
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 1000 lines

Test #4:

score: 5
Accepted
time: 0ms
memory: 35116kb

input:

20
250
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
Yes

result:

ok 20 lines

Test #5:

score: 5
Accepted
time: 2ms
memory: 33080kb

input:

20
250
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes

result:

ok 20 lines

Test #6:

score: 5
Accepted
time: 8ms
memory: 33652kb

input:

20
250
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes

result:

ok 20 lines

Test #7:

score: 5
Accepted
time: 21ms
memory: 39748kb

input:

20
6000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes

result:

ok 20 lines

Test #8:

score: 5
Accepted
time: 30ms
memory: 57712kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes

result:

ok single line: 'Yes'

Test #9:

score: 5
Accepted
time: 8ms
memory: 38928kb

input:

1000
21
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
4
1 2
7 4
15 8
17 12
21
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
7
1 2
3 4
5 8
7 10
9 14
15 18
17 20
21
1 2
2 3
3 4
4 5
5 6
6 7...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 1000 lines

Test #10:

score: 5
Accepted
time: 23ms
memory: 37160kb

input:

1000
120
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 1000 lines

Test #11:

score: 5
Accepted
time: 57ms
memory: 65136kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes

result:

ok single line: 'Yes'

Test #12:

score: 5
Accepted
time: 68ms
memory: 65580kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Test #13:

score: 5
Accepted
time: 135ms
memory: 70280kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Test #14:

score: 5
Accepted
time: 364ms
memory: 88728kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Test #15:

score: 5
Accepted
time: 71ms
memory: 67864kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes

result:

ok single line: 'Yes'

Test #16:

score: 5
Accepted
time: 94ms
memory: 69892kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes

result:

ok single line: 'Yes'

Test #17:

score: 5
Accepted
time: 72ms
memory: 68860kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

Yes

result:

ok single line: 'Yes'

Test #18:

score: 5
Accepted
time: 72ms
memory: 68848kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Test #19:

score: 5
Accepted
time: 86ms
memory: 72828kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Test #20:

score: 5
Accepted
time: 41ms
memory: 64028kb

input:

1
120000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

No

result:

ok single line: 'No'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 5
Accepted
time: 4ms
memory: 33348kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
3 23
1 24
24 25
25 26
5 26
1 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
7 42
2 43
43 44
44 45
45 46
4 46
2 47
47 48
48 49
49 50
50 51
51 52
52 53
53 54
54 55
12 55
2 56
56 57
57 58
58 59
59 ...

output:

No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
Yes
Yes

result:

ok 20 lines

Test #22:

score: 5
Accepted
time: 0ms
memory: 38632kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
3 23
1 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
5 32
1 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
7 41
2 42
42 43
43 44
44 45
45 46
46 47
4 47
2 48
48 49
49 50
50 51
51 52
52 53
53 54
12 54
2 55
55 56
56 57
57 58
58 59
14 ...

output:

Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 20 lines

Test #23:

score: 5
Accepted
time: 5ms
memory: 36484kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
3 24
1 25
25 26
26 27
27 28
28 29
29 30
30 31
5 31
1 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
7 39
2 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
4 48
2 49
49 50
50 51
51 52
52 53
53 54
54 55
55 56
56 57
57 58
12 58
2 59
59 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No

result:

ok 20 lines

Test #24:

score: 5
Accepted
time: 8ms
memory: 36416kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
3 20
1 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
5 31
1 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
7 49
2 50
50 51
51 52
52 53
53 54
54 55
55 56
56 57
57 58
4 58
2 59
59 60
60...

output:

No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 20 lines

Test #25:

score: 5
Accepted
time: 2ms
memory: 37048kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
3 31
1 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
5 39
1 40
40 41
41 42
42 43
43 44
44 45
7 45
2 46
46 47
47 48
48 49
49 50
50 51
4 51
2 52
52 53
53 54
54 55
55 56
56 57
57 58
58 59
59 60
12...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 20 lines

Test #26:

score: 5
Accepted
time: 0ms
memory: 38800kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
3 20
1 21
21 22
22 23
23 24
24 25
25 26
26 27
5 27
1 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
7 37
2 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
4 46
2 47
47 48
12 48
2 49
49 50
50 51
14 51
3 52
52 53
53 54
54 55
55 56
56 57
57 58
58 5...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 20 lines

Test #27:

score: 5
Accepted
time: 0ms
memory: 38456kb

input:

20
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
3 21
1 22
22 23
23 24
24 25
5 25
1 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
7 39
2 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
4 47
2 48
48 49
49 50
50 51
51 52
52 53
53 54
54 55
55 56
12 56
2 57
57 58
58 59
59 ...

output:

Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes

result:

ok 20 lines

Test #28:

score: 5
Accepted
time: 0ms
memory: 35884kb

input:

17
250
1 15
15 16
16 17
17 18
18 19
19 20
20 21
3 21
1 22
22 23
23 24
24 25
25 26
26 27
27 28
5 28
1 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
7 39
2 40
40 41
41 42
4 42
2 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
53 54
12 54
2 55
55 56
56 57
57 58
58 59
59 ...

output:

Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes

result:

ok 17 lines

Test #29:

score: 5
Accepted
time: 4ms
memory: 36948kb

input:

20
4
1 2
1 3
1 4
2
1 4
4 1
250
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 ...

output:

No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes

result:

ok 20 lines

Test #30:

score: 0
Wrong Answer
time: 0ms
memory: 38360kb

input:

20
7
1 2
1 3
2 4
2 5
3 6
3 7
2
1 2
2 1
250
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
2...

output:

No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes

result:

wrong answer 2nd lines differ - expected: 'No', found: 'Yes'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Runtime Error

Test #66:

score: 0
Runtime Error

input:

1000
10
1 2
2 3
1 4
4 5
4 6
4 7
2 8
8 9
3 10
2
5 4
1 9
10
1 2
1 3
1 4
4 5
4 6
3 7
3 8
2 9
6 10
2
2 9
1 5
10
1 2
2 3
1 4
4 5
4 6
2 7
3 8
2 9
1 10
2
10 2
7 5
10
1 2
1 3
1 4
2 5
1 6
3 7
2 8
7 9
2 10
2
10 5
2 7
10
1 2
1 3
1 4
3 5
5 6
3 7
7 8
1 9
8 10
2
6 7
1 2
10
1 2
1 3
3 4
2 5
4 6
3 7
1 8
4 9
1 10
2
1...

output:


result:


Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%