QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#51618#4633. Coprime Matriceszzhang949#AC ✓13ms4112kbC++867b2022-10-03 03:24:522022-10-03 03:24:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-03 03:24:52]
  • 评测
  • 测评结果:AC
  • 用时:13ms
  • 内存:4112kb
  • [2022-10-03 03:24:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 310;

int ans[N][N];
int n, m, x, y, w;

int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> x >> y >> w;
  w--;

  int cnt = 0;
  for (int i = 1; i < n; i += 2) {
	for (int j = 1; j < m; j += 2) {
	  ans[i][j] = cnt++;
	  ans[i + 1][j] = cnt++;
	  ans[i + 1][j + 1] = cnt++;
	  ans[i][j + 1] = cnt++;
	}
	if (m & 1) {
	  ans[i][m] = cnt++;
	  ans[i + 1][m] = cnt++;
	}
  }
  if (n & 1) {
	for (int i = 1; i <= m; ++i) ans[n][i] = cnt++;
  }

  int c = (w - ans[x][y] + n * m) % (n * m);
  for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j) ans[i][j] = (ans[i][j] + c) % (n * m);

  cout << "Yes" << endl;
  for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j) cout << ans[i][j] + 1 << " \n"[j == m];

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3636kb

input:

3 3 2 1 3

output:

Yes
2 5 6
3 4 7
8 9 1

result:

ok OK, Accepted.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

8 3 4 2 9

output:

Yes
1 4 5
2 3 6
7 10 11
8 9 12
13 16 17
14 15 18
19 22 23
20 21 24

result:

ok OK, Accepted.

Test #4:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

7 6 7 2 28

output:

Yes
33 36 37 40 41 2
34 35 38 39 42 1
3 6 7 10 11 14
4 5 8 9 12 13
15 18 19 22 23 26
16 17 20 21 24 25
27 28 29 30 31 32

result:

ok OK, Accepted.

Test #5:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

6 8 1 2 7

output:

Yes
4 7 8 11 12 15 16 19
5 6 9 10 13 14 17 18
20 23 24 27 28 31 32 35
21 22 25 26 29 30 33 34
36 39 40 43 44 47 48 3
37 38 41 42 45 46 1 2

result:

ok OK, Accepted.

Test #6:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

8 8 7 3 56

output:

Yes
4 7 8 11 12 15 16 19
5 6 9 10 13 14 17 18
20 23 24 27 28 31 32 35
21 22 25 26 29 30 33 34
36 39 40 43 44 47 48 51
37 38 41 42 45 46 49 50
52 55 56 59 60 63 64 3
53 54 57 58 61 62 1 2

result:

ok OK, Accepted.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2 4 2 1 8

output:

Yes
7 2 3 6
8 1 4 5

result:

ok OK, Accepted.

Test #8:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

6 6 4 2 17

output:

Yes
3 6 7 10 11 14
4 5 8 9 12 13
15 18 19 22 23 26
16 17 20 21 24 25
27 30 31 34 35 2
28 29 32 33 36 1

result:

ok OK, Accepted.

Test #9:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

8 6 3 1 33

output:

Yes
21 24 25 28 29 32
22 23 26 27 30 31
33 36 37 40 41 44
34 35 38 39 42 43
45 48 1 4 5 8
46 47 2 3 6 7
9 12 13 16 17 20
10 11 14 15 18 19

result:

ok OK, Accepted.

Test #10:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

2 8 2 4 15

output:

Yes
9 12 13 16 1 4 5 8
10 11 14 15 2 3 6 7

result:

ok OK, Accepted.

Test #11:

score: 0
Accepted
time: 4ms
memory: 3892kb

input:

295 280 79 198 74034

output:

Yes
51799 51802 51803 51806 51807 51810 51811 51814 51815 51818 51819 51822 51823 51826 51827 51830 51831 51834 51835 51838 51839 51842 51843 51846 51847 51850 51851 51854 51855 51858 51859 51862 51863 51866 51867 51870 51871 51874 51875 51878 51879 51882 51883 51886 51887 51890 51891 51894 51895 51...

result:

ok OK, Accepted.

Test #12:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

300 26 55 17 3020

output:

Yes
1584 1587 1588 1591 1592 1595 1596 1599 1600 1603 1604 1607 1608 1611 1612 1615 1616 1619 1620 1623 1624 1627 1628 1631 1632 1635
1585 1586 1589 1590 1593 1594 1597 1598 1601 1602 1605 1606 1609 1610 1613 1614 1617 1618 1621 1622 1625 1626 1629 1630 1633 1634
1636 1639 1640 1643 1644 1647 1648 1...

result:

ok OK, Accepted.

Test #13:

score: 0
Accepted
time: 8ms
memory: 4092kb

input:

288 282 125 58 43649

output:

Yes
8566 8569 8570 8573 8574 8577 8578 8581 8582 8585 8586 8589 8590 8593 8594 8597 8598 8601 8602 8605 8606 8609 8610 8613 8614 8617 8618 8621 8622 8625 8626 8629 8630 8633 8634 8637 8638 8641 8642 8645 8646 8649 8650 8653 8654 8657 8658 8661 8662 8665 8666 8669 8670 8673 8674 8677 8678 8681 8682 8...

result:

ok OK, Accepted.

Test #14:

score: 0
Accepted
time: 5ms
memory: 3716kb

input:

128 299 59 164 38067

output:

Yes
20398 20401 20402 20405 20406 20409 20410 20413 20414 20417 20418 20421 20422 20425 20426 20429 20430 20433 20434 20437 20438 20441 20442 20445 20446 20449 20450 20453 20454 20457 20458 20461 20462 20465 20466 20469 20470 20473 20474 20477 20478 20481 20482 20485 20486 20489 20490 20493 20494 20...

result:

ok OK, Accepted.

Test #15:

score: 0
Accepted
time: 5ms
memory: 4008kb

input:

300 300 286 253 60209

output:

Yes
64504 64507 64508 64511 64512 64515 64516 64519 64520 64523 64524 64527 64528 64531 64532 64535 64536 64539 64540 64543 64544 64547 64548 64551 64552 64555 64556 64559 64560 64563 64564 64567 64568 64571 64572 64575 64576 64579 64580 64583 64584 64587 64588 64591 64592 64595 64596 64599 64600 64...

result:

ok OK, Accepted.

Test #16:

score: 0
Accepted
time: 2ms
memory: 3896kb

input:

240 77 171 56 15870

output:

Yes
2669 2672 2673 2676 2677 2680 2681 2684 2685 2688 2689 2692 2693 2696 2697 2700 2701 2704 2705 2708 2709 2712 2713 2716 2717 2720 2721 2724 2725 2728 2729 2732 2733 2736 2737 2740 2741 2744 2745 2748 2749 2752 2753 2756 2757 2760 2761 2764 2765 2768 2769 2772 2773 2776 2777 2780 2781 2784 2785 2...

result:

ok OK, Accepted.

Test #17:

score: 0
Accepted
time: 6ms
memory: 3800kb

input:

165 141 69 107 11237

output:

Yes
1437 1440 1441 1444 1445 1448 1449 1452 1453 1456 1457 1460 1461 1464 1465 1468 1469 1472 1473 1476 1477 1480 1481 1484 1485 1488 1489 1492 1493 1496 1497 1500 1501 1504 1505 1508 1509 1512 1513 1516 1517 1520 1521 1524 1525 1528 1529 1532 1533 1536 1537 1540 1541 1544 1545 1548 1549 1552 1553 1...

result:

ok OK, Accepted.

Test #18:

score: 0
Accepted
time: 11ms
memory: 4024kb

input:

300 200 106 195 36560

output:

Yes
15371 15374 15375 15378 15379 15382 15383 15386 15387 15390 15391 15394 15395 15398 15399 15402 15403 15406 15407 15410 15411 15414 15415 15418 15419 15422 15423 15426 15427 15430 15431 15434 15435 15438 15439 15442 15443 15446 15447 15450 15451 15454 15455 15458 15459 15462 15463 15466 15467 15...

result:

ok OK, Accepted.

Test #19:

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

input:

247 46 55 25 776

output:

Yes
9606 9609 9610 9613 9614 9617 9618 9621 9622 9625 9626 9629 9630 9633 9634 9637 9638 9641 9642 9645 9646 9649 9650 9653 9654 9657 9658 9661 9662 9665 9666 9669 9670 9673 9674 9677 9678 9681 9682 9685 9686 9689 9690 9693 9694 9697
9607 9608 9611 9612 9615 9616 9619 9620 9623 9624 9627 9628 9631 9...

result:

ok OK, Accepted.

Test #20:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

18 300 15 168 2858

output:

Yes
3723 3726 3727 3730 3731 3734 3735 3738 3739 3742 3743 3746 3747 3750 3751 3754 3755 3758 3759 3762 3763 3766 3767 3770 3771 3774 3775 3778 3779 3782 3783 3786 3787 3790 3791 3794 3795 3798 3799 3802 3803 3806 3807 3810 3811 3814 3815 3818 3819 3822 3823 3826 3827 3830 3831 3834 3835 3838 3839 3...

result:

ok OK, Accepted.

Test #21:

score: 0
Accepted
time: 1ms
memory: 4004kb

input:

300 58 71 22 15741

output:

Yes
11638 11641 11642 11645 11646 11649 11650 11653 11654 11657 11658 11661 11662 11665 11666 11669 11670 11673 11674 11677 11678 11681 11682 11685 11686 11689 11690 11693 11694 11697 11698 11701 11702 11705 11706 11709 11710 11713 11714 11717 11718 11721 11722 11725 11726 11729 11730 11733 11734 11...

result:

ok OK, Accepted.

Test #22:

score: 0
Accepted
time: 13ms
memory: 4048kb

input:

290 262 3 217 58080

output:

Yes
57124 57127 57128 57131 57132 57135 57136 57139 57140 57143 57144 57147 57148 57151 57152 57155 57156 57159 57160 57163 57164 57167 57168 57171 57172 57175 57176 57179 57180 57183 57184 57187 57188 57191 57192 57195 57196 57199 57200 57203 57204 57207 57208 57211 57212 57215 57216 57219 57220 57...

result:

ok OK, Accepted.

Test #23:

score: 0
Accepted
time: 7ms
memory: 3748kb

input:

231 272 226 145 45674

output:

Yes
47289 47292 47293 47296 47297 47300 47301 47304 47305 47308 47309 47312 47313 47316 47317 47320 47321 47324 47325 47328 47329 47332 47333 47336 47337 47340 47341 47344 47345 47348 47349 47352 47353 47356 47357 47360 47361 47364 47365 47368 47369 47372 47373 47376 47377 47380 47381 47384 47385 47...

result:

ok OK, Accepted.

Test #24:

score: 0
Accepted
time: 1ms
memory: 4112kb

input:

300 116 15 107 32192

output:

Yes
30356 30359 30360 30363 30364 30367 30368 30371 30372 30375 30376 30379 30380 30383 30384 30387 30388 30391 30392 30395 30396 30399 30400 30403 30404 30407 30408 30411 30412 30415 30416 30419 30420 30423 30424 30427 30428 30431 30432 30435 30436 30439 30440 30443 30444 30447 30448 30451 30452 30...

result:

ok OK, Accepted.

Test #25:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

126 300 67 285 17771

output:

Yes
35203 35206 35207 35210 35211 35214 35215 35218 35219 35222 35223 35226 35227 35230 35231 35234 35235 35238 35239 35242 35243 35246 35247 35250 35251 35254 35255 35258 35259 35262 35263 35266 35267 35270 35271 35274 35275 35278 35279 35282 35283 35286 35287 35290 35291 35294 35295 35298 35299 35...

result:

ok OK, Accepted.

Test #26:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

231 117 51 40 8557

output:

Yes
2628 2631 2632 2635 2636 2639 2640 2643 2644 2647 2648 2651 2652 2655 2656 2659 2660 2663 2664 2667 2668 2671 2672 2675 2676 2679 2680 2683 2684 2687 2688 2691 2692 2695 2696 2699 2700 2703 2704 2707 2708 2711 2712 2715 2716 2719 2720 2723 2724 2727 2728 2731 2732 2735 2736 2739 2740 2743 2744 2...

result:

ok OK, Accepted.

Test #27:

score: 0
Accepted
time: 4ms
memory: 3832kb

input:

300 124 203 13 3245

output:

Yes
15373 15376 15377 15380 15381 15384 15385 15388 15389 15392 15393 15396 15397 15400 15401 15404 15405 15408 15409 15412 15413 15416 15417 15420 15421 15424 15425 15428 15429 15432 15433 15436 15437 15440 15441 15444 15445 15448 15449 15452 15453 15456 15457 15460 15461 15464 15465 15468 15469 15...

result:

ok OK, Accepted.

Test #28:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

62 146 44 52 331

output:

Yes
3149 3152 3153 3156 3157 3160 3161 3164 3165 3168 3169 3172 3173 3176 3177 3180 3181 3184 3185 3188 3189 3192 3193 3196 3197 3200 3201 3204 3205 3208 3209 3212 3213 3216 3217 3220 3221 3224 3225 3228 3229 3232 3233 3236 3237 3240 3241 3244 3245 3248 3249 3252 3253 3256 3257 3260 3261 3264 3265 3...

result:

ok OK, Accepted.

Test #29:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

40 52 22 17 1571

output:

Yes
498 501 502 505 506 509 510 513 514 517 518 521 522 525 526 529 530 533 534 537 538 541 542 545 546 549 550 553 554 557 558 561 562 565 566 569 570 573 574 577 578 581 582 585 586 589 590 593 594 597 598 601
499 500 503 504 507 508 511 512 515 516 519 520 523 524 527 528 531 532 535 536 539 540 ...

result:

ok OK, Accepted.

Test #30:

score: 0
Accepted
time: 9ms
memory: 3948kb

input:

300 300 23 278 19171

output:

Yes
12016 12019 12020 12023 12024 12027 12028 12031 12032 12035 12036 12039 12040 12043 12044 12047 12048 12051 12052 12055 12056 12059 12060 12063 12064 12067 12068 12071 12072 12075 12076 12079 12080 12083 12084 12087 12088 12091 12092 12095 12096 12099 12100 12103 12104 12107 12108 12111 12112 12...

result:

ok OK, Accepted.

Test #31:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

271 253 159 69 51872

output:

Yes
11762 11765 11766 11769 11770 11773 11774 11777 11778 11781 11782 11785 11786 11789 11790 11793 11794 11797 11798 11801 11802 11805 11806 11809 11810 11813 11814 11817 11818 11821 11822 11825 11826 11829 11830 11833 11834 11837 11838 11841 11842 11845 11846 11849 11850 11853 11854 11857 11858 11...

result:

ok OK, Accepted.

Test #32:

score: 0
Accepted
time: 4ms
memory: 3736kb

input:

124 259 8 165 20677

output:

Yes
18794 18797 18798 18801 18802 18805 18806 18809 18810 18813 18814 18817 18818 18821 18822 18825 18826 18829 18830 18833 18834 18837 18838 18841 18842 18845 18846 18849 18850 18853 18854 18857 18858 18861 18862 18865 18866 18869 18870 18873 18874 18877 18878 18881 18882 18885 18886 18889 18890 18...

result:

ok OK, Accepted.

Test #33:

score: 0
Accepted
time: 1ms
memory: 4060kb

input:

300 179 80 58 9660

output:

Yes
49284 49287 49288 49291 49292 49295 49296 49299 49300 49303 49304 49307 49308 49311 49312 49315 49316 49319 49320 49323 49324 49327 49328 49331 49332 49335 49336 49339 49340 49343 49344 49347 49348 49351 49352 49355 49356 49359 49360 49363 49364 49367 49368 49371 49372 49375 49376 49379 49380 49...

result:

ok OK, Accepted.

Test #34:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

97 95 71 13 1081

output:

Yes
3622 3625 3626 3629 3630 3633 3634 3637 3638 3641 3642 3645 3646 3649 3650 3653 3654 3657 3658 3661 3662 3665 3666 3669 3670 3673 3674 3677 3678 3681 3682 3685 3686 3689 3690 3693 3694 3697 3698 3701 3702 3705 3706 3709 3710 3713 3714 3717 3718 3721 3722 3725 3726 3729 3730 3733 3734 3737 3738 3...

result:

ok OK, Accepted.

Test #35:

score: 0
Accepted
time: 4ms
memory: 4004kb

input:

288 300 233 151 62807

output:

Yes
79307 79310 79311 79314 79315 79318 79319 79322 79323 79326 79327 79330 79331 79334 79335 79338 79339 79342 79343 79346 79347 79350 79351 79354 79355 79358 79359 79362 79363 79366 79367 79370 79371 79374 79375 79378 79379 79382 79383 79386 79387 79390 79391 79394 79395 79398 79399 79402 79403 79...

result:

ok OK, Accepted.

Test #36:

score: 0
Accepted
time: 8ms
memory: 3976kb

input:

300 259 206 73 42316

output:

Yes
67035 67038 67039 67042 67043 67046 67047 67050 67051 67054 67055 67058 67059 67062 67063 67066 67067 67070 67071 67074 67075 67078 67079 67082 67083 67086 67087 67090 67091 67094 67095 67098 67099 67102 67103 67106 67107 67110 67111 67114 67115 67118 67119 67122 67123 67126 67127 67130 67131 67...

result:

ok OK, Accepted.

Test #37:

score: 0
Accepted
time: 6ms
memory: 3852kb

input:

149 295 129 201 30873

output:

Yes
36668 36671 36672 36675 36676 36679 36680 36683 36684 36687 36688 36691 36692 36695 36696 36699 36700 36703 36704 36707 36708 36711 36712 36715 36716 36719 36720 36723 36724 36727 36728 36731 36732 36735 36736 36739 36740 36743 36744 36747 36748 36751 36752 36755 36756 36759 36760 36763 36764 36...

result:

ok OK, Accepted.

Test #38:

score: 0
Accepted
time: 4ms
memory: 3616kb

input:

121 252 57 39 17402

output:

Yes
3214 3217 3218 3221 3222 3225 3226 3229 3230 3233 3234 3237 3238 3241 3242 3245 3246 3249 3250 3253 3254 3257 3258 3261 3262 3265 3266 3269 3270 3273 3274 3277 3278 3281 3282 3285 3286 3289 3290 3293 3294 3297 3298 3301 3302 3305 3306 3309 3310 3313 3314 3317 3318 3321 3322 3325 3326 3329 3330 3...

result:

ok OK, Accepted.

Test #39:

score: 0
Accepted
time: 2ms
memory: 3976kb

input:

300 37 136 22 4789

output:

Yes
10889 10892 10893 10896 10897 10900 10901 10904 10905 10908 10909 10912 10913 10916 10917 10920 10921 10924 10925 10928 10929 10932 10933 10936 10937 10940 10941 10944 10945 10948 10949 10952 10953 10956 10957 10960 10961
10890 10891 10894 10895 10898 10899 10902 10903 10906 10907 10910 10911 10...

result:

ok OK, Accepted.

Test #40:

score: 0
Accepted
time: 2ms
memory: 4112kb

input:

300 300 298 186 66405

output:

Yes
67235 67238 67239 67242 67243 67246 67247 67250 67251 67254 67255 67258 67259 67262 67263 67266 67267 67270 67271 67274 67275 67278 67279 67282 67283 67286 67287 67290 67291 67294 67295 67298 67299 67302 67303 67306 67307 67310 67311 67314 67315 67318 67319 67322 67323 67326 67327 67330 67331 67...

result:

ok OK, Accepted.