QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372171#8049. Equal Sumsucup-team3215AC ✓2462ms360420kbC++202.2kb2024-03-31 01:32:512024-03-31 01:32:52

Judging History

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

  • [2024-03-31 01:32:52]
  • 评测
  • 测评结果:AC
  • 用时:2462ms
  • 内存:360420kb
  • [2024-03-31 01:32:51]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC target "avx512dq,avx512bw,avx512vl,avx512vbmi,avx512vbmi2,bmi,abm,bmi2"
#include "immintrin.h"
#pragma GCC optimize "O3"

using namespace std;

constexpr int N = 500, S = (N + 1) * 512, mod = 998244353, B0 = 16, B1 = 16, B08 = B0 * 8;

vector<int> cx[N];

int cy[B0 * 8][S];

void wconv(const int* a, int sz, int* b, int l, int r) {
  uint32_t s = 0;
  for (int i = 0; i < l; ++i) b[i] = 0;
  for (int i = l; i < min(r, sz + l); ++i) b[i] = (s += a[i - l]) %= mod;
  for (int i = r; i < sz + l; ++i) s += a[i - l] + mod - a[i - r], b[i] = s -= (s >= 2 * mod? 2 * mod: s >= mod? mod: 0);
  for (int i = sz + l; i < r; ++i) b[i] = s;
  for (int i = max(r, sz + l); i < sz + r - 1; ++i) b[i] = (s += mod - a[i - r]) %= mod;
}

alignas(64) uint64_t ty[B1 * B08];
alignas(64) uint64_t ans[512][512];

array<int, 2> lrx[N], lry[N];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m; cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> lrx[i][0] >> lrx[i][1], ++lrx[i][1];
  for (int i = 0; i < m; ++i) cin >> lry[i][0] >> lry[i][1], ++lry[i][1];
  for (int i = 0; i < n; ++i) {
    cx[i].resize(N * (i + 1) + B1);
    wconv(i? &cx[i - 1][0]: &(const int&)1, N * i + 1, &cx[i][0], lrx[i][0], lrx[i][1]);
  }
  using v8u64 = __attribute((vector_size(64))) uint64_t;
  for (int I = 0; I < m; I += B08) {
    for (int i = I; i < min(I + B08, m); ++i) wconv(i? &cy[(i + B08 - 1) % B08][0]: &(const int&)1, N * i + 1, &cy[i % B08][0], lry[i][0], lry[i][1]);
    for (int K = 0; K <= (I + B08) * N; K += B1) {
      for (int i = 0; i < B08; ++i)
      for (int k = 0; k < B1; ++k) ty[i + B08 * k] = cy[i][K + k];
      for (int j = max(0, (K + N - 1) / N - 1); j < n; ++j) {
        v8u64 x[B1]{};
        for (int k = 0; k < B1; ++k) x[k] += cx[j][K + k];
        for (int i = 0; i < B0; ++i) {
          for (int k = 0; k < B1; ++k) (v8u64&)ans[j][I + i * 8] += (v8u64)_mm512_mul_epu32((__m512i&)x[k], (__m512i&)ty[i + k * B0 << 3]);
          (v8u64&)ans[j][I + i * 8] -= ((v8u64&)ans[j][I + i * 8] >> 30) * mod;
        }
      }
    }
  }
  for (int j = 0; j < n; ++j, cout << '\n')
  for (int i = 0; i < m; ++i) cout << ans[j][i] % mod << ' ';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 3760kb

input:

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

output:

2 0 0 
3 4 4 

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 2415ms
memory: 360372kb

input:

500 500
19 458
1 480
7 485
50 461
12 476
15 461
48 466
40 453
46 467
9 458
27 478
26 472
46 459
29 490
6 500
17 487
48 484
28 472
28 459
25 480
4 491
29 481
36 460
2 491
44 499
22 473
20 458
4 483
27 471
2 496
11 461
43 450
2 478
37 466
15 459
42 482
7 451
19 455
2 453
47 475
48 450
1 474
46 471
9 4...

output:

411 79401 9145270 673005095 180581065 984223118 586589234 293043270 404363796 865361724 665487988 118838806 926189944 226338288 521479857 808644951 786041288 340769021 177100 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #3:

score: 0
Accepted
time: 2349ms
memory: 360356kb

input:

500 500
36 457
29 497
27 469
21 497
12 498
35 496
40 478
47 497
45 451
34 488
5 500
22 453
6 462
17 491
3 482
12 468
37 461
27 476
45 470
37 491
49 498
45 485
29 455
8 478
25 493
48 491
2 496
40 493
10 485
22 455
18 475
42 450
8 464
39 498
28 497
18 455
13 492
44 471
39 478
40 481
37 459
37 486
38 4...

output:

410 67896 5410240 335246275 482170226 913746165 370327287 785404079 322053982 763512109 721728384 612084387 267089167 247309721 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #4:

score: 0
Accepted
time: 2392ms
memory: 360388kb

input:

500 500
14 454
10 476
22 452
18 488
4 463
12 495
31 472
19 464
20 476
10 467
44 485
6 496
31 474
39 461
45 483
1 496
25 471
47 462
23 463
42 494
2 481
5 465
41 468
4 496
49 498
24 472
18 500
7 497
2 493
15 491
10 463
31 466
7 469
50 483
46 478
19 458
2 481
20 455
22 485
20 455
45 486
16 469
21 495
5...

output:

441 96580 10039316 711563490 841935541 132520335 384371932 889484040 482637692 883143772 885148661 571513373 992796968 47082194 1307504 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #5:

score: 0
Accepted
time: 2359ms
memory: 360364kb

input:

500 500
4 480
6 477
36 454
25 450
38 458
50 464
47 458
1 479
46 485
26 494
10 478
2 480
23 463
35 453
7 454
33 479
44 496
17 471
27 487
36 473
43 497
32 476
22 490
25 496
50 479
4 456
49 456
26 497
2 450
46 496
27 455
32 459
50 495
22 491
15 484
14 488
39 484
1 463
13 483
38 499
35 468
45 453
32 468...

output:

471 108433 16539764 292114332 355294571 926046361 659177551 39453824 529783563 221351807 826151817 498533391 891430723 97219089 48882128 5311735 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 250000 numbers

Test #6:

score: 0
Accepted
time: 2292ms
memory: 360352kb

input:

500 500
43 451
14 483
4 497
14 485
6 485
5 475
10 490
22 467
42 492
21 500
2 464
16 494
14 460
45 498
6 487
39 479
40 455
42 452
24 465
47 493
47 489
33 450
38 453
26 492
14 473
15 464
24 495
38 459
24 486
20 484
50 490
31 454
21 470
17 456
1 494
46 488
19 470
50 470
4 460
25 487
20 463
4 451
50 493...

output:

409 89162 8789000 491134490 623734175 365970533 223879607 360062656 147167272 222184069 514225818 592269397 267978286 652587298 178132946 5311735 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #7:

score: 0
Accepted
time: 2309ms
memory: 360364kb

input:

500 500
7 474
40 477
4 450
2 467
24 493
23 500
37 476
8 462
48 454
14 500
24 471
30 458
47 472
12 482
33 480
4 457
43 496
14 458
3 453
2 488
32 483
27 476
1 478
38 477
39 482
22 476
30 466
20 452
48 491
16 484
32 450
5 471
19 466
15 494
22 497
7 457
28 462
35 478
5 483
12 496
14 495
10 461
33 471
38...

output:

445 95266 12085216 891881376 822602426 628274758 777305802 720102318 584565217 344805696 719285527 962838807 38728957 237533998 133972150 285609131 565722720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #8:

score: 0
Accepted
time: 2330ms
memory: 360420kb

input:

500 500
40 469
34 468
14 460
23 491
50 487
4 478
27 487
29 485
7 482
40 488
4 453
30 453
10 464
7 477
50 455
13 473
29 467
41 457
20 485
29 457
45 461
6 483
37 499
30 451
24 491
30 482
9 467
18 492
23 463
25 490
3 461
42 466
12 451
14 454
6 487
33 500
33 492
5 488
49 452
42 463
34 477
25 465
46 493
...

output:

425 79003 9585345 673005095 166390422 312570528 382836489 657074927 891491975 222184069 637806782 379313566 471700636 436538635 376444469 790552202 699660129 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 250000 numbers

Test #9:

score: 0
Accepted
time: 2323ms
memory: 360364kb

input:

500 500
29 460
24 466
22 489
41 452
37 476
45 496
10 481
28 497
16 462
13 500
7 497
38 477
12 470
38 455
1 464
1 461
42 482
41 479
35 494
34 496
20 486
4 484
37 484
42 483
40 464
3 494
2 469
23 496
42 490
46 490
1 499
43 466
23 467
13 450
29 461
9 450
13 486
44 495
24 475
35 481
44 495
20 496
46 456...

output:

432 81003 9511040 658029065 210103247 157666582 911617106 139298029 394317956 942022131 132310594 949626827 397291702 827047093 542880657 13037895 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 250000 numbers

Test #10:

score: 0
Accepted
time: 2336ms
memory: 360364kb

input:

500 500
37 486
47 452
43 485
12 489
33 457
41 477
48 451
46 471
23 491
3 496
25 472
30 493
38 473
24 478
17 477
10 485
4 455
45 473
39 494
11 490
45 459
38 452
4 500
43 461
6 484
24 464
38 452
45 472
47 497
10 493
46 494
18 482
45 500
26 450
1 483
35 458
50 497
40 489
36 456
2 498
9 487
20 479
41 47...

output:

427 98226 12975676 196463462 258622537 453526973 901311823 584108635 114036479 448310004 182637702 246235809 818487751 385016335 315415866 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 250000 numbers

Test #11:

score: 0
Accepted
time: 2360ms
memory: 360384kb

input:

500 500
6 488
11 482
18 465
15 482
24 500
45 462
12 470
44 462
37 468
3 475
10 456
47 452
16 467
48 470
10 463
9 451
26 468
43 453
50 498
37 488
2 474
39 480
10 456
8 485
39 453
24 497
6 481
37 457
36 493
34 488
23 472
50 457
27 475
18 453
36 451
15 468
13 452
18 471
26 489
19 474
29 500
39 472
48 4...

output:

437 87153 10586800 744617 776616085 219865658 11667831 253804241 276378294 195939520 774230261 389813264 982059869 291850838 281913196 120767384 883852143 635936961 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 250000 numbers

Test #12:

score: 0
Accepted
time: 2462ms
memory: 359520kb

input:

499 500
5 497
6 494
4 491
5 492
7 497
2 495
8 494
3 491
9 495
3 496
9 497
8 490
6 500
4 491
6 490
9 496
3 490
2 495
7 492
4 494
9 494
4 494
4 496
7 496
9 491
1 490
10 498
1 496
9 500
6 500
10 498
2 492
8 490
10 498
6 493
1 499
8 497
10 498
9 494
5 492
6 497
9 497
6 492
9 492
10 496
9 493
1 499
4 496...

output:

492 119316 19250136 243105014 640259429 848017016 967479743 49685914 88145869 832148397 30876722 1398353 430300916 946263737 959886182 814780656 842820257 851356460 725192293 653152937 171714960 38586424 354934143 179039285 691583334 292858116 924240829 942890381 17716633 70051478 600806382 85421878...

result:

ok 249500 numbers

Test #13:

score: 0
Accepted
time: 2338ms
memory: 355228kb

input:

495 499
3 493
4 499
6 493
7 498
4 493
8 496
8 496
1 494
7 493
10 495
1 491
10 495
7 491
7 499
8 493
6 490
1 496
10 490
2 494
3 493
6 493
5 490
7 496
5 493
9 492
2 496
5 496
5 500
1 493
8 499
4 497
6 498
4 499
8 493
3 494
2 490
6 496
1 497
5 497
8 499
4 498
8 495
1 497
1 490
9 497
6 499
2 490
1 493
6...

output:

486 117855 18896570 243105014 498103446 288895653 869907239 731058819 348958708 846266690 601172751 881333656 414211605 200965223 685846017 658884484 832411088 155603293 345398839 916499158 768292862 810285565 553123425 768278573 468641963 649236052 587548408 684588651 112307655 969837483 707495282 ...

result:

ok 247005 numbers

Test #14:

score: 0
Accepted
time: 2376ms
memory: 359360kb

input:

500 496
7 403
40 458
40 409
86 414
54 464
1 436
96 484
79 431
90 497
8 460
89 475
97 483
96 437
76 490
64 422
79 496
49 442
25 451
40 496
88 459
15 450
85 414
72 418
83 407
6 445
44 473
65 497
90 438
94 474
68 407
1 439
42 402
54 481
28 412
97 439
72 450
78 461
20 407
58 477
33 470
68 445
54 403
48 ...

output:

370 60726 5616324 261630670 367803058 938693299 232384977 763859516 576315935 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 248000 numbers

Test #15:

score: 0
Accepted
time: 2337ms
memory: 358616kb

input:

499 497
118 399
25 370
50 271
193 468
47 287
67 488
109 387
55 372
81 442
16 429
199 429
19 421
137 273
107 495
245 451
217 370
42 347
85 288
236 310
226 437
205 311
15 460
128 440
36 444
179 481
203 389
203 355
212 407
221 416
210 343
89 296
124 405
165 282
131 334
113 374
20 327
175 314
185 433
39...

output:

87 1953 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 248003 numbers

Test #16:

score: 0
Accepted
time: 2283ms
memory: 352444kb

input:

494 492
207 238
118 361
121 225
458 481
14 404
50 188
20 217
147 336
51 373
228 395
382 402
158 396
58 68
173 467
371 468
86 104
302 372
261 410
128 312
52 181
152 266
22 497
40 115
207 319
18 45
256 405
28 339
72 434
153 155
117 243
186 300
69 174
258 485
200 425
306 308
22 154
17 237
470 472
341 4...

output:

32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 243048 numbers

Extra Test:

score: 0
Extra Test Passed