QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#578935#9310. Permutation Counting 4HanoistRE 47ms1524kbC++141.1kb2024-09-20 23:06:502024-09-20 23:06:50

Judging History

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

  • [2024-09-20 23:06:50]
  • 评测
  • 测评结果:RE
  • 用时:47ms
  • 内存:1524kb
  • [2024-09-20 23:06:50]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<utility>
#include<cassert>
using namespace std;
inline int read(){
    int x = 0,f = 1;
    char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9'){
        x = (x << 3) + (x << 1) + (c ^ 48);
        c = getchar();
    }
    return x * f;
}
const int N = 2e3 + 11;
int n,p[N];
inline int find(int x){
    if(x == p[x]) return x;
    return p[x] = find(p[x]);
}
inline void merge(int x,int y){
    int xx = find(x),yy = find(y);
    if(xx == yy) return;
    p[yy] = xx;
}
inline int check(){
    int i,x = find(1);
    for(i = 2;i <= n + 1;i++){
        if(find(i) != x) return 0;
    }
    return 1;
}
int main(){
    int t,i,x,y;
    t = read();
    while(t--){
        n = read();
        for(i = 1;i <= n + 1;i++) p[i] = i;
        for(i = 1;i <= n;i++){
            x = read(),y = read();
            merge(x,y + 1);
        }
        printf("%d\n",check());
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1512kb

input:

4
5
1 2
1 5
1 2
1 2
2 2
5
1 1
2 4
2 3
5 5
3 4
5
3 5
1 2
3 4
3 5
3 3
5
1 5
1 4
4 5
5 5
1 2

output:

0
1
0
0

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 39ms
memory: 1524kb

input:

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

output:

1
1
0
0
1
0
1
1
0
1
1
0
0
0
0
0
1
0
1
0
0
1
0
0
0
1
0
1
0
0
0
0
1
0
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
0
1
1
0
0
0
0
0
0
1
0
1
1
0
1
1
1
0
1
0
1
0
0
0
1
1
1
0
0
1
1
1
1
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
1
0
0
1
0
1
1
...

result:

ok 66725 tokens

Test #3:

score: 0
Accepted
time: 40ms
memory: 1496kb

input:

6655
155
28 58
68 100
6 47
98 109
11 133
38 153
73 118
126 153
24 43
71 118
109 135
6 104
40 101
24 139
100 136
135 136
40 148
70 117
92 124
63 64
45 55
16 128
65 86
20 49
126 138
30 141
127 146
21 155
49 139
27 34
39 145
20 53
12 41
3 107
38 78
106 109
61 102
20 99
134 135
23 99
10 69
105 113
36 75...

output:

0
0
1
1
0
1
0
0
1
1
0
1
1
1
0
0
1
1
1
0
1
0
1
0
1
0
0
1
1
0
1
0
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
0
1
0
0
0
0
0
1
1
0
1
0
1
0
1
0
1
0
0
1
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
1
0
0
0
0
0
1
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
1
1
0
0
0
0
...

result:

ok 6655 tokens

Test #4:

score: 0
Accepted
time: 47ms
memory: 1520kb

input:

666
1967
396 1664
818 1954
564 805
1106 1322
568 1687
853 1482
153 1092
566 670
154 562
114 1372
574 1879
482 1083
499 1566
2 1384
291 1947
122 1714
1277 1900
740 1024
887 1478
146 254
944 1807
574 1193
225 1933
43 1278
1017 1482
958 1180
86 1230
1658 1679
980 1542
1044 1127
762 989
1128 1567
552 17...

output:

0
0
0
0
1
1
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
1
1
1
0
0
0
0
1
1
0
0
1
0
1
0
1
0
0
1
0
0
1
0
0
0
0
0
1
1
0
1
1
1
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
0
1
0
1
1
0
1
0
0
1
1
1
1
1
0
1
1
1
0
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
1
0
0
1
1
1
1
1
0
0
1
1
0
0
1
0
0
1
0
1
1
0
1
1
1
1
1
1
0
0
0
0
1
1
0
...

result:

ok 666 tokens

Test #5:

score: -100
Runtime Error

input:

67
12220
945 3456
3457 11698
945 3023
945 10249
945 6035
3457 12211
3024 9082
6554 10249
3179 11698
945 2449
3457 6897
945 3625
4115 9082
3626 11593
2450 3525
3526 5410
3179 5606
5607 8510
5607 8159
1908 9082
6898 9270
3457 4922
6669 9082
2936 10249
2936 9009
1796 5410
4923 10474
2450 5488
3526 6232...

output:


result: