QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#276734#4175. 虔诚的墓主人SoyTony100 ✓55ms12792kbC++142.5kb2023-12-06 10:11:532023-12-06 10:11:54

Judging History

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

  • [2023-12-06 10:11:54]
  • 评测
  • 测评结果:100
  • 用时:55ms
  • 内存:12792kb
  • [2023-12-06 10:11:53]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int maxn=1e5+10;
const int maxm=1e6+10;
const ll mod=2147483648;
const int base=1e8;
const ull base1=233;
const ull base2=19260817;
const int maxxn=0x7fffffff;
const int minxn=-0x7fffffff;
const db inf=1e13;
const db eps=1e-8;
inline ll read(){
    ll x=0,w=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
    while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*w;
}
int n,m,w,k;
int x[maxn],y[maxn];
int fac[maxn][15],cnt[maxn][2];
pair<int,int> p[maxn];
struct BIT{
    int num[maxn];
    inline int lowbit(int x){
        return x&(-x);
    }
    inline void update(int x,int k){
        k%=mod;
        while(x<=w){
            num[x]=(num[x]+k)%mod;
            x+=lowbit(x);
        }
    }
    inline int query(int x){
        int res=0;
        while(x){
            res=(res+num[x])%mod;
            x-=lowbit(x);
        }
        return res;
    }
}tree;
int ans;
int cntw[maxn];
int main(){
    n=read(),m=read(),w=read();
    for(int i=1;i<=w;i++){
        p[i].first=x[i]=read(),p[i].second=y[i]=read();
    }
    k=read();
    fac[0][0]=1;
    for(int i=1;i<=w;i++){
        fac[i][0]=1;
        for(int j=1;j<=k;j++){
            fac[i][j]=(fac[i-1][j-1]+fac[i-1][j])%mod;
        }
    }
    sort(x+1,x+w+1);
    sort(y+1,y+w+1);
    for(int i=1;i<=w;i++){
        p[i].first=lower_bound(x+1,x+w+1,p[i].first)-x;
        p[i].second=lower_bound(y+1,y+w+1,p[i].second)-y;
        cnt[p[i].first][0]++,cnt[p[i].second][1]++;
    }
    sort(p+1,p+w+1);
    int cntn,cnts=1;
    for(int i=1;i<w;i++){
        if(p[i].first==p[i-1].first) cnts++;
        else cnts=1;
        cntn=cnt[p[i].first][0]-cnts;
        if(cntn){
            int num=(tree.query(p[i+1].second-1)-tree.query(p[i].second)%mod+mod)%mod;
            ans=(ans+fac[cntn][k]*fac[cnts][k]%mod*num)%mod;
        }
        cntw[p[i].second]++;
        int num1=fac[cntw[p[i].second]][k]*fac[cnt[p[i].second][1]-cntw[p[i].second]][k]%mod;
        int num2=(tree.query(p[i].second)-tree.query(p[i].second-1)%mod+mod)%mod;
        tree.update(p[i].second,((num1-num2)%mod+mod)%mod);
    }
    printf("%lld\n",(ans%mod+mod)%mod);
    return 0;
}

详细

Test #1:

score: 4
Accepted
time: 1ms
memory: 5636kb

input:

4 10
30
3 3
2 6
2 2
1 6
4 10
3 5
4 6
1 5
3 4
4 5
4 3
3 6
2 1
1 1
2 0
3 7
1 0
4 7
2 4
4 4
1 10
0 7
3 10
4 9
0 1
4 2
3 8
0 5
4 1
3 9
1

output:

24

result:

ok single line: '24'

Test #2:

score: 4
Accepted
time: 1ms
memory: 5872kb

input:

20 4
50
14 3
11 4
10 2
19 4
5 0
15 3
11 0
11 1
12 4
4 0
15 4
3 3
6 1
12 0
18 4
17 0
13 2
1 4
8 0
13 4
0 1
0 4
20 0
19 2
20 2
14 4
6 3
17 4
7 2
9 2
12 3
2 4
14 1
9 4
8 2
18 2
8 1
15 0
17 3
2 1
6 4
19 0
3 0
1 2
14 2
7 4
10 1
3 4
5 4
19 1
2

output:

0

result:

ok single line: '0'

Test #3:

score: 4
Accepted
time: 1ms
memory: 5700kb

input:

30 30
500
27 1
8 8
1 23
28 11
6 25
19 12
10 1
8 2
4 15
10 19
20 15
22 18
21 29
5 19
20 6
22 29
0 22
14 29
7 16
14 10
14 8
15 27
20 29
10 7
13 15
25 15
5 26
2 23
23 12
10 5
24 0
27 5
11 8
0 7
27 21
24 2
14 6
27 3
11 26
13 13
6 8
20 11
11 0
3 30
24 27
16 0
12 23
8 30
17 15
3 12
30 16
8 14
28 16
29 2
2...

output:

590442372

result:

ok single line: '590442372'

Test #4:

score: 4
Accepted
time: 1ms
memory: 5736kb

input:

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

output:

1585972577

result:

ok single line: '1585972577'

Test #5:

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

input:

333 333
10000
147 158
89 199
162 302
162 250
282 73
141 44
192 4
281 304
225 32
280 326
37 136
26 314
162 240
39 33
242 132
251 6
143 122
179 202
164 100
66 118
110 74
318 297
199 75
84 14
245 33
261 246
87 183
233 48
60 191
331 22
117 271
153 208
256 102
269 249
175 63
85 47
171 117
82 278
177 15
2...

output:

1133287428

result:

ok single line: '1133287428'

Test #6:

score: 4
Accepted
time: 36ms
memory: 11204kb

input:

500 500
80000
107 481
29 206
398 389
375 194
202 168
375 183
234 171
25 313
203 287
185 85
350 113
247 40
71 329
478 57
211 284
342 186
220 349
20 227
288 326
399 41
92 469
463 119
139 372
366 331
419 302
384 204
175 429
342 46
190 304
367 97
12 260
395 151
29 363
487 390
363 233
68 243
462 303
429 ...

output:

762581168

result:

ok single line: '762581168'

Test #7:

score: 4
Accepted
time: 45ms
memory: 12508kb

input:

1000 1000
100000
329 892
946 314
583 628
727 880
734 135
508 992
510 67
479 967
490 192
802 100
616 646
608 58
708 730
229 483
928 183
614 502
584 318
240 965
273 57
127 859
760 320
878 781
760 42
788 551
382 963
928 958
783 195
738 229
869 405
193 300
472 857
723 282
576 678
997 472
470 589
239 316...

output:

1134444325

result:

ok single line: '1134444325'

Test #8:

score: 4
Accepted
time: 44ms
memory: 12552kb

input:

1000 1000
100000
883 734
77 622
314 892
304 943
163 483
938 172
732 44
903 607
377 553
946 639
497 703
249 64
810 29
378 895
944 950
985 450
328 863
198 581
983 487
837 909
73 806
750 424
423 637
809 179
719 976
694 118
71 864
726 148
14 110
969 619
153 792
329 116
309 490
590 758
883 701
532 909
42...

output:

387454971

result:

ok single line: '387454971'

Test #9:

score: 4
Accepted
time: 32ms
memory: 11012kb

input:

4 100000
80000
1 10329
3 73869
3 80659
2 95136
2 60644
4 63574
1 41805
0 18513
0 3626
2 64075
4 87149
0 95099
0 86515
2 31670
0 88394
1 48584
0 2783
4 918
1 87612
0 17349
0 9729
4 91632
0 5061
1 99060
1 1453
2 84729
0 91887
2 12873
0 67478
1 76814
0 56037
3 50985
4 29104
0 60459
2 58319
2 68916
2 80...

output:

619813848

result:

ok single line: '619813848'

Test #10:

score: 4
Accepted
time: 37ms
memory: 11820kb

input:

100000 4
100000
7404 1
25988 0
1207 0
1843 4
71020 0
70606 2
4090 4
64930 4
86069 2
37453 3
93197 2
49093 1
10686 3
74228 1
40394 4
34790 1
80868 3
37980 3
49189 0
86097 4
51253 2
22417 4
16622 4
77580 2
34192 4
56841 4
78516 1
29896 1
21764 2
3811 2
42336 1
58532 0
28633 2
36006 0
25058 1
47940 1
2...

output:

1511076953

result:

ok single line: '1511076953'

Test #11:

score: 4
Accepted
time: 44ms
memory: 12500kb

input:

10000 10000
100000
8885 7919
6193 9365
3471 8490
6703 4356
1051 1952
354 9591
7329 5361
6652 4847
7796 3557
7851 2360
8007 5254
6762 167
8094 6864
3824 9876
2456 3221
7620 3929
6870 5149
6590 3560
5527 1729
7417 4044
4572 6389
3856 699
7711 4073
5912 1326
2017 1006
1131 2742
1569 2554
2769 2110
9292...

output:

1009797864

result:

ok single line: '1009797864'

Test #12:

score: 4
Accepted
time: 18ms
memory: 9160kb

input:

123456 654321
50000
85711 201995
19989 64921
101945 386171
24071 491321
19674 554739
109147 376518
5430 147976
12701 250365
109571 597237
119241 328663
3744 191968
113484 612529
100280 511307
31581 99690
9844 406318
63258 171061
66707 108456
22835 291706
6748 2213
113971 14418
14366 590160
43955 189...

output:

1559168346

result:

ok single line: '1559168346'

Test #13:

score: 4
Accepted
time: 53ms
memory: 12604kb

input:

888888 888888
100000
679872 351491
838451 474060
253596 314794
785248 814668
119690 887464
166784 645347
313663 229842
418701 492517
680606 414042
435007 222099
641128 197041
547255 548974
680606 395667
878656 41273
794761 449853
356362 140142
780876 574637
485517 503106
554044 148561
277853 69059
7...

output:

1919193137

result:

ok single line: '1919193137'

Test #14:

score: 4
Accepted
time: 40ms
memory: 12608kb

input:

20 1000000
100000
17 469532
11 586890
1 993454
19 197903
5 731655
19 704609
3 592798
12 969487
14 371058
4 266699
19 125525
11 660367
10 220160
5 638505
9 213861
0 497977
14 48456
12 710667
19 847103
12 681658
11 527494
6 459601
8 785054
3 920432
16 807492
20 272512
7 117221
1 471509
2 263539
4 3253...

output:

1496223421

result:

ok single line: '1496223421'

Test #15:

score: 4
Accepted
time: 53ms
memory: 12792kb

input:

1000000 1000000
100000
94799 802737
533648 656973
105064 148974
705194 860484
162594 551722
324732 901076
606643 288570
405422 436750
167042 231831
28124 226164
906516 961962
918850 412426
354220 295439
738032 88274
551858 896902
975785 189123
533607 492801
42227 959097
727274 90999
166592 676114
27...

output:

1179646382

result:

ok single line: '1179646382'

Test #16:

score: 4
Accepted
time: 24ms
memory: 12176kb

input:

1000000000 1000000000
98304
30000 10000
30000 20000
30000 81950000
30000 81960000
40000 10000
40000 20000
40000 81950000
40000 81960000
50000 10000
50000 20000
50000 81950000
50000 81960000
60000 10000
60000 20000
60000 81950000
60000 81960000
70000 10000
70000 20000
70000 81950000
70000 81960000
80...

output:

0

result:

ok single line: '0'

Test #17:

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

input:

1000000000 1000000000
16000
9684000 10000000
10316000 10000000
10000000 9684000
10000000 10316000
9684079 10000000
10315921 10000000
10000000 9684079
10000000 10315921
9684158 10000000
10315842 10000000
10000000 9684158
10000000 10315842
9684237 10000000
10315763 10000000
10000000 9684237
10000000 1...

output:

605028352

result:

ok single line: '605028352'

Test #18:

score: 4
Accepted
time: 54ms
memory: 12504kb

input:

2000000 2000000
100000
440596 866969
561227 1474471
1091358 976098
312202 146907
186899 748539
597568 1384655
1255437 502058
128209 1599753
1801125 1424383
558451 465232
1018747 1913634
1100265 1440239
869545 186582
1130073 1901252
1457341 21008
1056416 1035935
952750 1863125
1195357 1183787
1963627...

output:

889183411

result:

ok single line: '889183411'

Test #19:

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

input:

110999889 110999889
10000
48999951 52666614
29666637 66333267
53999946 100666566
53999946 83333250
93999906 24333309
46999953 14666652
63999936 1333332
93666573 101333232
74999925 10666656
93333240 108666558
12333321 45333288
8666658 104666562
53999946 79999920
12999987 10999989
80666586 43999956
83...

output:

704285933

result:

ok single line: '704285933'

Test #20:

score: 4
Accepted
time: 49ms
memory: 12608kb

input:

10000000 10000000
100000
829241 4803531
9586922 1072398
9680033 6088592
4799299 1564488
7075962 4174747
3067483 8107713
7343632 167483
6821468 3962046
2514056 6392587
7432420 8906558
3292441 9661018
7553449 2868033
8898051 933916
2324111 7113773
9351118 3806685
7517856 5058351
5413919 1362707
586995...

output:

1093872297

result:

ok single line: '1093872297'

Test #21:

score: 4
Accepted
time: 40ms
memory: 11788kb

input:

100000000 100000000
90000
13972922 42109268
37772355 34642710
23349611 74188486
66881685 4377627
37480831 40257702
8785725 33188261
99982590 88786852
7927246 26073113
35340027 55900681
25976729 29642358
50055100 96136563
48703626 79103443
17289342 85224964
75585060 78465725
59191907 71425402
5315469...

output:

1969797402

result:

ok single line: '1969797402'

Test #22:

score: 4
Accepted
time: 46ms
memory: 12484kb

input:

100000000 100000000
100000
95241601 4627685
22254203 72927891
30214125 28078497
97990863 53667137
43949475 11498524
36521592 16571707
15358413 33691553
78922031 54782335
58977654 57726769
81466755 24254260
55092120 22635301
99712035 48048442
85729419 85934584
66583639 27295031
16339568 57497856
8415...

output:

1006167171

result:

ok single line: '1006167171'

Test #23:

score: 4
Accepted
time: 26ms
memory: 8848kb

input:

1000000000 1000000000
50000
395731770 370155511
76638628 294094460
570710649 541973791
283217037 748545126
733862663 82036590
349186909 74956785
887828963 654414953
521978390 491487230
671915864 99056573
797616141 880364858
89989546 176076706
167364037 527523880
735085933 850361634
339438874 6631257...

output:

267662481

result:

ok single line: '267662481'

Test #24:

score: 4
Accepted
time: 45ms
memory: 12608kb

input:

1000000000 1000000000
100000
422047348 940423505
336051265 768946115
254361204 767003953
87569841 588082601
596148725 295441339
527370249 422676295
500061067 184558752
169962923 485393755
765869948 688327118
720880589 680256319
727417592 8632919
877493403 96769065
393717060 16518812
997460422 655833...

output:

342316083

result:

ok single line: '342316083'

Test #25:

score: 4
Accepted
time: 55ms
memory: 12608kb

input:

1000000000 1000000000
100000
182188725 505782153
776759010 1601966
55300724 775739486
387617433 556640670
734828107 154067887
46077627 795764946
94172881 598007483
663749891 61755568
521304701 347616521
597547367 367369
688897159 215963433
824259598 678157855
25075477 850833093
587083886 288823799
4...

output:

901837817

result:

ok single line: '901837817'