QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572849#9310. Permutation Counting 4SakuyamaidAC ✓333ms11320kbC++205.2kb2024-09-18 16:34:592024-09-18 16:34:59

Judging History

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

  • [2024-09-18 16:34:59]
  • 评测
  • 测评结果:AC
  • 用时:333ms
  • 内存:11320kb
  • [2024-09-18 16:34:59]
  • 提交

answer

// buxiangwanla
// 你紫名觉得是我的锅,那就是我的锅,为什么你知道吗?因为紫名说的话,就像是一个癌症晚期患者说的话一样。
// 他都已经这样了,你为什么不顺从他呢?你总要给人最后一段时间一个好的回忆吧,最后的时光里。
// 因为紫名这个段位很尴尬,紫名橙名再往上一点,grandmaster,可能说,欸,有点实力,能操作一下。
// 紫名往下,绿名,蓝名,啊,人家是纯属玩游戏的,因为太垃圾了,自己也知道自己没什么实力。
// 但紫名,上不去下不来的这个段位,他觉得,蓝名的人不配跟他一起玩儿,对吧?蓝名是最垃圾的。
// 但是呢他想上去,他又上不去,所以这个分段是最尴尬的,没办法,卡在这里了。
// 想操作,又操作不起来,掉下去吧,他又觉得不值得,对吧,我好不容易从蓝名打到紫名了,我为什么还要掉下去呢?
// 这个人说优越狗越说越起劲,为什么他会这么说?因为他是紫名。
// 他觉得你比我段位高,你说的任何话都是优越,我并不管你说的有没有道理。
// 我紫名,我最猛,我WF2017我上我能夺冠,那打比赛全是sb。你比我段位高你说话就是放屁,这就是这种人的想法。但是呢,他的想法是对的,为什么呢?
// 因为他癌症晚期。没办法,我同意,对不起,我优越了。可能是我膨胀了,不好意思啊,我膨胀了。我紫名是没操作,难道我就看不懂谁背锅吗?
// 不是,如果你看得懂的话,就不会在这里抬杠了,对吧。

// If you Blue Name think it's my fault, it's my fault. Do you know why? Because what Blue Name says is like something a terminal cancer patient would say.
// He's already like that. Why don't you just go along with it? You always have to give someone a good memory for the last period of time, right? In the last time.
// Because the blue name of this rating is very awkward, blue name purple name a little further up, master, may say, hey, a little strength, can operate a little.
// Blue name down, green name, ah, people are purely playing the game, because it is too trash, they also know that they do not have much strength.
// But the blue name, can't go up or down in this rating, he thinks, the green name of the person does not deserve to play with him, right? Green name is the most trash.
// But he wants to go up, he can not go up, so this rating is the most embarrassing, no way, stuck here.
// I want to solve, but I can not solve the problems, fall down, he also think it is not worth it, right, it is not easy for me to fight from the green name to the blue name, why do I have to fall down?
// This person said superior dog the more he said the more energized, why would he say so? Because he's blue.
// He thinks you are higher than me, anything you say is superior, I don't care if what you say makes sense or not.
// I'm not sure if there's any truth in what you're saying, but I'm not sure if there's any truth in what you're saying, and I'm not sure if there's any truth in what you're saying, and I'm not sure if there's any truth in what you're saying. But then, his idea is right, why?
// Because he has terminal cancer. No way, I agree. I'm sorry, I'm superior. Maybe I'm bloated. I'm sorry, I'm bloated. My blue name is no operation. Can't I see who's taking the fall?
// No, if you could see it, you wouldn't be here carrying the can, would you.
// 
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ULL;
using LL = long long;

mt19937_64 rd(time(0));
constexpr int N = 3e5 + 5, mod = 998244353;
constexpr double eps = 1e-8;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

#define fi first
#define se second
#define int long long
#define lowbit(x) (x & (-x))
#define PII pair<int, int>
#define mid ((l + r) >> 1)

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int ksm(int a, int b){
    a %= mod;
    int res = 1;
    while(b){
        if(b & 1)res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int n, m;
void Sakuya()
{
    cin >> n;
    vector<int>fa(n + 2);
    for(int i = 1; i <= n + 1; ++ i)fa[i] = i;
    bool flag = true;

    auto find = [&](auto self, int x) -> int{
        if(fa[x] != x)return fa[x] = self(self, fa[x]);
        return fa[x];
    };

    auto check = [&](int x) -> int{
        return find(find, x);
    };

    auto merge = [&](int x, int y) -> void{
        int xx = find(find, x);
        int yy = find(find, y);
        fa[xx] = yy;
    };

    for(int i = 1; i <= n; ++ i){
        int l, r;
        cin >> l >> r;
        r += 1;
        if(check(l) != check(r)){
            merge(l, r);
        }else {
            flag = false;
        }
    }

    if(flag)cout << 1 << "\n";
    else cout << 0 << "\n";
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    for (cin >> T; T -- ; )
        Sakuya();

}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3704kb

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: 87ms
memory: 3712kb

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: 85ms
memory: 3732kb

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: 100ms
memory: 3888kb

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: 0
Accepted
time: 111ms
memory: 3836kb

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:

1
1
0
1
1
1
0
0
0
1
0
0
0
0
1
1
1
1
1
0
0
0
0
1
1
0
0
1
0
0
1
0
1
1
0
1
1
0
0
1
1
0
1
1
0
0
0
0
1
0
1
1
0
1
1
1
0
1
1
0
0
1
1
1
1
0
1

result:

ok 67 tokens

Test #6:

score: 0
Accepted
time: 127ms
memory: 5312kb

input:

6
189286
20378 70057
112636 186453
18829 100288
79275 115176
63489 100397
91394 117835
82935 156201
139293 142914
73817 98058
45394 109570
29456 122157
137106 187436
155188 173045
78214 89538
128432 165866
151755 155927
10312 86728
127548 136028
27985 151840
67594 139392
116691 134229
83762 102392
2...

output:

0
0
1
1
1
0

result:

ok 6 tokens

Test #7:

score: 0
Accepted
time: 333ms
memory: 11248kb

input:

1
1000000
94615 809894
94615 262270
762901 809894
762901 765167
94615 555380
94615 515529
473424 762900
262271 698085
36290 809894
294342 809894
473424 706007
94615 725798
725799 966460
602080 966460
51014 762900
338866 473423
93158 338865
28544 698085
416220 966460
6640 555380
215959 698085
253649 ...

output:

1

result:

ok "1"

Test #8:

score: 0
Accepted
time: 286ms
memory: 11092kb

input:

1
1000000
25927 931541
549663 947731
435323 484750
320537 420368
154427 330335
204649 698863
119951 619271
299655 485176
266828 632738
621134 818227
529143 683026
134580 498562
513579 586797
184440 719755
258499 785336
546208 853976
407308 494237
176985 846562
79646 969633
297019 505247
65287 287869...

output:

0

result:

ok "0"

Test #9:

score: 0
Accepted
time: 279ms
memory: 11116kb

input:

1
1000000
708148 839950
121329 290905
510828 569312
437062 892947
18749 896294
40631 125586
207243 247889
51468 93552
440810 694824
29877 145371
453173 456834
215578 649145
278488 353906
492636 676255
590863 913302
23982 765827
558855 973649
259253 402361
415102 552772
283526 306361
586620 693138
27...

output:

0

result:

ok "0"

Test #10:

score: 0
Accepted
time: 317ms
memory: 11168kb

input:

1
1000000
282918 797950
797951 915225
615399 915225
457486 615398
321702 797950
414142 797950
86620 414141
86620 388932
86620 998765
440839 457485
86620 448168
99138 998765
414142 494939
333492 448168
99138 597241
895799 915225
111714 615398
414142 906877
80369 321701
797951 979896
457486 535578
333...

output:

1

result:

ok "1"

Test #11:

score: 0
Accepted
time: 281ms
memory: 11184kb

input:

1
1000000
831328 870733
206720 363737
918611 979445
89822 488412
396737 611744
354139 765908
486638 518418
296801 990821
187722 808282
80742 649459
738441 819473
242541 441310
158310 764373
110901 879938
204155 274087
119096 414236
296080 877904
523676 628788
492136 579838
599930 731872
14581 265820...

output:

0

result:

ok "0"

Test #12:

score: 0
Accepted
time: 315ms
memory: 11188kb

input:

1
1000000
250412 737666
737667 993185
861375 993185
721908 993185
209954 721907
737667 789700
435283 737666
164916 209953
149936 861374
209954 559650
69081 250411
298411 721907
173631 861374
57828 298410
435283 892327
863076 892327
283363 298410
3290 721907
789701 949793
559651 985187
3290 755642
32...

output:

1

result:

ok "1"

Test #13:

score: 0
Accepted
time: 279ms
memory: 11164kb

input:

1
1000000
318973 779919
438410 978223
455585 723466
308013 977990
263871 538496
86744 501121
72052 419373
15911 268439
499883 527765
679230 868802
330840 803740
380942 392943
65937 674331
288146 672318
694032 909594
213386 345973
452124 929529
262584 931207
24900 750763
254895 600549
851295 950130
1...

output:

0

result:

ok "0"

Test #14:

score: 0
Accepted
time: 284ms
memory: 11116kb

input:

1
1000000
239440 968541
377517 869195
530856 816462
232729 422351
11399 612034
430469 766063
401926 402352
522675 872089
478392 926439
146525 555357
543387 701528
402678 760896
712375 818266
21282 619683
352812 426092
289076 482125
874816 973856
53811 333775
218802 267228
65809 292143
676521 982871
...

output:

0

result:

ok "0"

Test #15:

score: 0
Accepted
time: 279ms
memory: 11300kb

input:

1
1000000
499131 501875
7544 495774
133830 316225
13323 142112
218559 877222
137527 418509
138614 248102
84060 395886
345499 494655
166777 315709
373952 878560
734659 950965
38749 967905
699108 701549
135426 572760
136007 898008
666899 950808
547838 553056
702428 943307
386478 629552
564870 694439
6...

output:

0

result:

ok "0"

Test #16:

score: 0
Accepted
time: 280ms
memory: 11320kb

input:

1
1000000
20752 494590
443015 633649
748804 831912
498508 583322
25172 224797
198063 709209
265567 760531
169111 263603
88340 150378
683819 685360
816602 953394
3949 336072
512193 890817
198122 812621
30617 612527
721756 877615
291877 727436
540881 917775
131459 714576
413668 542545
142171 778729
37...

output:

0

result:

ok "0"

Extra Test:

score: 0
Extra Test Passed