QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801434#3155. Rampartmodwwe100 ✓1421ms269660kbC++233.8kb2024-12-06 23:46:122024-12-06 23:46:12

Judging History

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

  • [2024-12-06 23:46:12]
  • 评测
  • 测评结果:100
  • 用时:1421ms
  • 内存:269660kb
  • [2024-12-06 23:46:12]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const int  mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
    if(x+y>=mod2) x-=mod2;
    if(x+y<0)x+=mod2;
    return x+y;
}
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    ll a;
    int  b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int el = 19;
main()
{
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    ///  cin>>s1;
    // modwwe
    phongbeo();
//   checktime
}
int dl[4001];
int dr[4001];
bool c[4001][4001];
vector<int> v[4002];
int b[4001][4001];
int a[4001][4001];
struct skibidi
{
    int bit[4001];
    void upd(int x,int y)
    {
        for(x; x; x-=x&-x)
            bit[x]+=y;
    }
    int get(int x)
    {
        int s=0;
        for(x; x<=n; x+=x&-x)
            s+=bit[x];
        return s;
    }
    void reset()
    {
        for(int i=1; i<=n; i++)
            bit[i]=0;
    }
} fen;
void phongbeo()
{
    cin>>n>>m>>lim>>k;
    for(int i=1; i<=k; i++)
        cin>>l>>r,c[l][r]=1;
    for(int i=1; i<=n; i++)
        dr[i]=m+1;
    for(int i=1; i<=m; i++)
        dl[i]=n+1;
/// build .###
///       #xx#
///       #xx#
///       #xx.
    for(int i=n; i>=1; --i)
        for(int j=m; j>=1; --j)
        {
            if(c[i][j])
            {
                dl[j]=min(dl[j],i);
                dr[i]=min(dr[i],j);
            }
            s4=min(dl[j]-i,dr[i]-j);
            a[i][j]=-1;
            if(i+s4<=n&&j+s4<=m)
                a[i][j]=s4;
        }
    for(int i=1; i<=n; i++)
        dr[i]=0;
    for(int i=1; i<=m; i++)
        dl[i]=0;
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j)
        {
            if(c[i][j])
            {
                dl[j]=max(dl[j],i);
                dr[i]=max(dr[i],j);
            }
            b[i][j]=i-min(i-dl[j],j-dr[i])+1;
        }
    s4=0;
    for(int f=1-n; f<=m-1; f++)
    {
        for(int  i=max(1ll,1-f); i<=n; i++)
        {
            int j=f+i;
            if(f+i>=1&&f+i<=m)
            {
                fen.upd(i,1);
                if(a[i][j]!=-1)
                {
                    v[i+a[i][j]].pb(i);
                }
            }
            for(auto x:v[i])
                fen.upd(x,-1);
            vector<int>().swap(v[i]);
            if(j>=1&&j<=m)
            {
                if(i-b[i][j]+1>=lim)
                {
                    s4+=fen.get(b[i][j]);
                    s4-=fen.get(i-lim+2);
                }
            }
        }
        fen.reset();
    }
    cout<<s4;
}

詳細信息

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 3ms
memory: 18112kb

input:

100 100 3 5
22 33
65 31
68 54
19 4
22 20

output:

302000

result:

ok single line: '302000'

Test #2:

score: 4
Accepted
time: 2ms
memory: 12216kb

input:

100 500 3 10
15 419
94 462
9 312
93 429
90 255
76 63
53 278
62 406
34 240
91 410

output:

2199220

result:

ok single line: '2199220'

Test #3:

score: 4
Accepted
time: 3ms
memory: 42704kb

input:

500 100 3 10
250 18
487 48
99 12
76 85
104 57
163 2
417 4
131 47
210 13
385 73

output:

2199220

result:

ok single line: '2199220'

Test #4:

score: 4
Accepted
time: 11ms
memory: 40952kb

input:

500 500 3 10
92 146
343 196
140 370
137 121
101 172
90 337
194 211
92 72
316 319
301 428

output:

40345812

result:

ok single line: '40345812'

Test #5:

score: 4
Accepted
time: 7ms
memory: 40556kb

input:

500 498 3 30
499 99
390 150
66 77
188 319
310 193
64 450
190 337
36 195
330 442
302 203
123 122
11 295
404 422
235 366
395 458
123 229
219 270
65 196
334 232
266 392
381 5
486 439
215 417
91 381
405 431
73 236
392 374
138 358
269 142
269 228

output:

38532790

result:

ok single line: '38532790'

Test #6:

score: 4
Accepted
time: 12ms
memory: 38804kb

input:

495 500 3 300
185 483
81 341
12 137
486 327
333 377
193 165
418 336
368 360
252 264
242 427
113 150
219 280
145 121
26 283
354 16
84 125
189 340
495 234
168 367
276 340
287 219
456 497
466 217
325 122
136 352
259 495
121 220
156 210
300 164
290 292
317 187
440 127
178 343
8 408
353 352
86 280
90 58
...

output:

23833983

result:

ok single line: '23833983'

Test #7:

score: 4
Accepted
time: 22ms
memory: 42928kb

input:

500 500 3 2985
70 65
359 273
220 427
108 419
365 407
486 282
329 270
3 162
317 284
254 286
262 1
156 148
256 162
106 152
203 236
316 88
443 180
81 109
203 396
60 456
304 445
205 78
373 139
498 308
209 312
15 76
212 467
479 323
320 20
448 186
327 93
50 212
174 499
43 187
332 213
213 150
75 157
462 18...

output:

4414528

result:

ok single line: '4414528'

Test #8:

score: 4
Accepted
time: 23ms
memory: 42820kb

input:

500 500 3 82384
424 8
179 259
438 192
488 174
300 9
457 427
365 347
294 425
438 19
272 240
12 293
207 492
308 452
419 263
18 94
91 423
227 398
166 2
5 32
15 390
280 187
299 405
30 481
279 412
453 302
233 254
163 321
335 188
349 404
85 59
299 436
362 214
62 69
308 211
441 117
198 404
335 418
14 263
3...

output:

12398

result:

ok single line: '12398'

Subtask #2:

score: 16
Accepted

Test #9:

score: 16
Accepted
time: 31ms
memory: 71068kb

input:

1000 1000 3 5
540 51
345 36
206 452
93 337
371 37

output:

330297682

result:

ok single line: '330297682'

Test #10:

score: 16
Accepted
time: 634ms
memory: 266252kb

input:

4000 3995 3 10
3654 2302
3667 3620
3437 2281
2979 3515
1174 2310
2116 3725
994 1116
3993 3292
1350 1524
2419 1172

output:

21215902199

result:

ok single line: '21215902199'

Test #11:

score: 16
Accepted
time: 486ms
memory: 256732kb

input:

3877 4000 1038 10
3295 1215
2522 131
317 3330
3434 1115
2670 2121
2357 3768
1730 729
1754 1013
584 2700
1155 2744

output:

8097425420

result:

ok single line: '8097425420'

Test #12:

score: 16
Accepted
time: 329ms
memory: 260048kb

input:

4000 4000 2575 10
1891 2586
376 2154
3787 638
1942 1766
2271 2473
3926 583
558 112
2221 1493
570 655
482 1469

output:

962438267

result:

ok single line: '962438267'

Test #13:

score: 16
Accepted
time: 610ms
memory: 264192kb

input:

4000 4000 3 10
1521 590
1375 3082
3320 2756
1193 2246
1478 498
2902 348
139 118
2134 2600
1401 882
1060 3752

output:

21255236432

result:

ok single line: '21255236432'

Test #14:

score: 16
Accepted
time: 677ms
memory: 262164kb

input:

4000 4000 3 7
1784 564
3215 1597
1257 880
1326 289
550 3215
405 3381
1393 683

output:

21272453522

result:

ok single line: '21272453522'

Test #15:

score: 16
Accepted
time: 618ms
memory: 255976kb

input:

4000 4000 3 1
996 2685

output:

21302819564

result:

ok single line: '21302819564'

Subtask #3:

score: 80
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 80
Accepted
time: 24ms
memory: 118356kb

input:

4000 50 10 432
1414 44
2581 34
3003 40
3367 44
1877 11
3218 17
1205 27
462 18
3184 8
200 9
2533 21
1587 42
1583 10
3070 22
2547 11
1171 38
3483 33
577 28
2315 50
365 50
1862 17
167 48
3191 24
1245 21
715 14
3147 3
239 14
2697 16
3602 6
1002 1
313 31
1395 12
2445 40
365 18
3275 39
2373 43
599 40
3353...

output:

2831645

result:

ok single line: '2831645'

Test #17:

score: 80
Accepted
time: 3ms
memory: 14400kb

input:

50 4000 9 389
1 458
26 185
15 466
34 904
29 2831
28 1349
18 712
47 2840
32 2334
30 3002
3 1010
34 3481
12 1954
14 2267
23 3061
26 2695
13 2401
17 18
9 2682
50 3518
23 1879
1 2848
4 20
18 2575
35 2641
39 343
19 2273
18 3718
3 1269
47 3315
50 525
11 893
50 3329
27 271
16 1193
4 1
48 2552
9 1050
39 119...

output:

3042790

result:

ok single line: '3042790'

Test #18:

score: 80
Accepted
time: 661ms
memory: 266924kb

input:

4000 4000 3 10
64 863
1165 34
537 2371
3039 597
3461 3734
297 1455
3523 1254
2542 2264
1604 2860
2529 183

output:

21260398563

result:

ok single line: '21260398563'

Test #19:

score: 80
Accepted
time: 650ms
memory: 269328kb

input:

4000 4000 30 100
3612 3092
565 715
3252 1154
1110 3926
2005 502
1005 517
1085 939
878 3772
3187 1844
1216 3307
2196 14
3382 1637
1098 1541
963 1560
3934 352
2640 1332
230 2239
3616 1650
1056 719
2043 482
2028 1453
2626 909
2596 2997
517 257
1533 1957
845 975
2623 1511
105 1570
2833 3562
372 3620
360...

output:

20372820510

result:

ok single line: '20372820510'

Test #20:

score: 80
Accepted
time: 850ms
memory: 268444kb

input:

4000 4000 26 1000
1336 78
2858 3184
3215 2014
3101 3308
2410 2876
430 2681
1322 386
1265 361
3863 1627
31 2824
3938 2048
2867 3100
1361 3285
2788 1374
1469 1354
2437 541
2534 662
1331 2044
1455 3746
3237 3967
627 3389
338 651
3032 468
2565 3911
2397 2905
510 739
2046 1944
2156 3806
2856 1178
3524 24...

output:

16479380786

result:

ok single line: '16479380786'

Test #21:

score: 80
Accepted
time: 1421ms
memory: 269384kb

input:

4000 3904 51 9997
869 3341
2920 1643
1576 979
667 1244
163 1078
1992 1838
3275 1820
1515 2575
3906 697
3263 2587
1717 3146
2566 1352
2630 2217
2276 1181
3504 3372
2492 1313
3940 3546
295 1739
2809 2990
2614 412
3796 771
3776 3399
2825 157
1580 3002
447 1505
2934 2668
2404 1718
372 1375
516 2987
85 2...

output:

4279361283

result:

ok single line: '4279361283'

Test #22:

score: 80
Accepted
time: 1350ms
memory: 252240kb

input:

3736 4000 43 99651
3472 814
86 3720
3345 570
2028 1570
1211 2527
3524 814
2454 3080
1066 3794
1341 818
1660 3895
2070 298
2622 3388
2661 987
543 2300
3019 3937
60 3277
2677 454
2948 3955
1425 595
3430 121
973 3985
281 157
3688 3680
569 3859
2753 2644
3330 1633
522 1267
3377 2157
2188 1741
1841 531
4...

output:

176456200

result:

ok single line: '176456200'

Test #23:

score: 80
Accepted
time: 731ms
memory: 268248kb

input:

4000 4000 27 100
537 1243
2266 497
3477 3187
1252 1752
2593 2843
2232 2011
1839 3332
2937 3071
530 923
3001 3142
3135 1271
389 150
627 3037
2125 1997
1521 2763
1701 852
3970 349
2383 2230
3549 2355
2540 1392
3217 329
3370 3127
1328 3285
2688 2252
3764 197
1441 3873
2047 3393
1946 2827
550 844
853 97...

output:

20404565199

result:

ok single line: '20404565199'

Test #24:

score: 80
Accepted
time: 731ms
memory: 269520kb

input:

4000 4000 8 1000
2959 130
2485 2228
481 3337
527 166
3720 81
1910 400
1214 1505
1488 2057
2861 1229
3491 3735
3412 1965
3808 2221
3382 150
1105 1046
1911 400
550 1456
2028 42
1744 3102
2030 39
2034 1370
3896 3231
2412 1758
2816 1701
1996 3846
3838 149
1141 3346
2811 81
498 2676
3413 1965
577 1643
31...

output:

18910198447

result:

ok single line: '18910198447'

Test #25:

score: 80
Accepted
time: 722ms
memory: 267428kb

input:

3980 4000 8 1300
2658 3508
1549 2760
2211 191
3496 3113
1866 800
2214 1120
291 108
95 1863
1401 156
1956 146
3350 1192
1550 2759
1123 3927
2364 2206
3048 2759
3303 2257
2717 612
2361 2208
2843 1334
2693 1517
2422 3207
1527 3941
1126 3930
527 23
2715 308
1106 3535
2656 3508
1029 3956
2627 1847
2226 1...

output:

18278609255

result:

ok single line: '18278609255'

Test #26:

score: 80
Accepted
time: 936ms
memory: 269660kb

input:

4000 4000 51 10000
1571 1790
1904 245
2535 2879
2533 1766
3666 3313
38 2476
1917 1568
371 1376
41 3963
249 721
278 2124
550 3403
1816 2653
2892 3209
2242 1043
782 804
1724 937
42 2479
276 2988
3659 1906
2888 3203
3126 81
127 2870
64 24
1815 3530
2451 1347
3197 2484
1076 2532
2880 3205
2298 140
43 39...

output:

13919498872

result:

ok single line: '13919498872'

Test #27:

score: 80
Accepted
time: 1104ms
memory: 269452kb

input:

4000 4000 43 99451
589 2380
2923 1104
2155 3439
1044 2976
1665 2526
3918 763
1091 1876
26 1801
809 3058
3738 1894
3103 2959
1117 3297
800 3617
1332 3749
3908 766
1913 683
1375 3286
3912 787
589 2393
1380 1580
3907 785
392 2053
3058 2313
3059 211
338 2843
3755 2011
3747 1874
3804 1788
345 1343
372 20...

output:

7535450007

result:

ok single line: '7535450007'

Extra Test:

score: 0
Extra Test Passed