QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383390#4633. Coprime MatricesSlongodAC ✓4ms4324kbC++14986b2024-04-09 12:20:342024-04-09 12:20:34

Judging History

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

  • [2024-04-09 12:20:34]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:4324kb
  • [2024-04-09 12:20:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
namespace Slongod{
const int N = 505;
int n , m , x , y , w , now , a[N][N];

void main()
{
    cin >> n >> m >> x >> y >> w; now = 1;
    for (int j = 1; j <= m; j += 2) {
        for (int i = 1; i <= n; i += 2) {
            if (i == n and j == m){a[i][j] = now; now++;}
            else if (i == n){a[i][j] = now; a[i][j+1] = now + 1; now += 2;}
            else if (j == m){a[i][j] = now; a[i+1][j] = now + 1; now += 2;}
            else{a[i][j] = now; a[i][j+1] = now + 1; a[i+1][j+1] = now + 2; a[i+1][j] = now + 3; now += 4;}
        }
    } w = (w - a[x][y]); cout << "Yes\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cout << (a[i][j] + w + n * m - 1) % (n * m) + 1;
            if (j != m){cout << ' ';}
        } if (i != n){cout << '\n';}
    }
}
}int main()
{
    ios :: sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    return Slongod :: main(),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

3 3 2 1 3

output:

Yes
9 1 6
3 2 7
4 5 8

result:

ok OK, Accepted.

Test #2:

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

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

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

input:

8 3 4 2 9

output:

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

result:

ok OK, Accepted.

Test #4:

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

input:

7 6 7 2 28

output:

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

result:

ok OK, Accepted.

Test #5:

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

input:

6 8 1 2 7

output:

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

result:

ok OK, Accepted.

Test #6:

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

input:

8 8 7 3 56

output:

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

result:

ok OK, Accepted.

Test #7:

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

input:

2 4 2 1 8

output:

Yes
5 6 1 2
8 7 4 3

result:

ok OK, Accepted.

Test #8:

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

input:

6 6 4 2 17

output:

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

result:

ok OK, Accepted.

Test #9:

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

input:

8 6 3 1 33

output:

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

result:

ok OK, Accepted.

Test #10:

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

input:

2 8 2 4 15

output:

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

result:

ok OK, Accepted.

Test #11:

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

input:

295 280 79 198 74034

output:

Yes
16057 16058 16647 16648 17237 17238 17827 17828 18417 18418 19007 19008 19597 19598 20187 20188 20777 20778 21367 21368 21957 21958 22547 22548 23137 23138 23727 23728 24317 24318 24907 24908 25497 25498 26087 26088 26677 26678 27267 27268 27857 27858 28447 28448 29037 29038 29627 29628 30217 30...

result:

ok OK, Accepted.

Test #12:

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

input:

300 26 55 17 3020

output:

Yes
5912 5913 6512 6513 7112 7113 7712 7713 512 513 1112 1113 1712 1713 2312 2313 2912 2913 3512 3513 4112 4113 4712 4713 5312 5313
5915 5914 6515 6514 7115 7114 7715 7714 515 514 1115 1114 1715 1714 2315 2314 2915 2914 3515 3514 4115 4114 4715 4714 5315 5314
5916 5917 6516 6517 7116 7117 7716 7717 ...

result:

ok OK, Accepted.

Test #13:

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

input:

288 282 125 58 43649

output:

Yes
27272 27273 27848 27849 28424 28425 29000 29001 29576 29577 30152 30153 30728 30729 31304 31305 31880 31881 32456 32457 33032 33033 33608 33609 34184 34185 34760 34761 35336 35337 35912 35913 36488 36489 37064 37065 37640 37641 38216 38217 38792 38793 39368 39369 39944 39945 40520 40521 41096 41...

result:

ok OK, Accepted.

Test #14:

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

input:

128 299 59 164 38067

output:

Yes
17214 17215 17470 17471 17726 17727 17982 17983 18238 18239 18494 18495 18750 18751 19006 19007 19262 19263 19518 19519 19774 19775 20030 20031 20286 20287 20542 20543 20798 20799 21054 21055 21310 21311 21566 21567 21822 21823 22078 22079 22334 22335 22590 22591 22846 22847 23102 23103 23358 23...

result:

ok OK, Accepted.

Test #15:

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

input:

300 300 286 253 60209

output:

Yes
74038 74039 74638 74639 75238 75239 75838 75839 76438 76439 77038 77039 77638 77639 78238 78239 78838 78839 79438 79439 80038 80039 80638 80639 81238 81239 81838 81839 82438 82439 83038 83039 83638 83639 84238 84239 84838 84839 85438 85439 86038 86039 86638 86639 87238 87239 87838 87839 88438 88...

result:

ok OK, Accepted.

Test #16:

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

input:

240 77 171 56 15870

output:

Yes
2569 2570 3049 3050 3529 3530 4009 4010 4489 4490 4969 4970 5449 5450 5929 5930 6409 6410 6889 6890 7369 7370 7849 7850 8329 8330 8809 8810 9289 9290 9769 9770 10249 10250 10729 10730 11209 11210 11689 11690 12169 12170 12649 12650 13129 13130 13609 13610 14089 14090 14569 14570 15049 15050 1552...

result:

ok OK, Accepted.

Test #17:

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

input:

165 141 69 107 11237

output:

Yes
16876 16877 17206 17207 17536 17537 17866 17867 18196 18197 18526 18527 18856 18857 19186 19187 19516 19517 19846 19847 20176 20177 20506 20507 20836 20837 21166 21167 21496 21497 21826 21827 22156 22157 22486 22487 22816 22817 23146 23147 211 212 541 542 871 872 1201 1202 1531 1532 1861 1862 21...

result:

ok OK, Accepted.

Test #18:

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

input:

300 200 106 195 36560

output:

Yes
38149 38150 38749 38750 39349 39350 39949 39950 40549 40550 41149 41150 41749 41750 42349 42350 42949 42950 43549 43550 44149 44150 44749 44750 45349 45350 45949 45950 46549 46550 47149 47150 47749 47750 48349 48350 48949 48950 49549 49550 50149 50150 50749 50750 51349 51350 51949 51950 52549 52...

result:

ok OK, Accepted.

Test #19:

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

input:

247 46 55 25 776

output:

Yes
6102 6103 6596 6597 7090 7091 7584 7585 8078 8079 8572 8573 9066 9067 9560 9561 10054 10055 10548 10549 11042 11043 174 175 668 669 1162 1163 1656 1657 2150 2151 2644 2645 3138 3139 3632 3633 4126 4127 4620 4621 5114 5115 5608 5609
6105 6104 6599 6598 7093 7092 7587 7586 8081 8080 8575 8574 9069...

result:

ok OK, Accepted.

Test #20:

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

input:

18 300 15 168 2858

output:

Yes
5241 5242 5277 5278 5313 5314 5349 5350 5385 5386 21 22 57 58 93 94 129 130 165 166 201 202 237 238 273 274 309 310 345 346 381 382 417 418 453 454 489 490 525 526 561 562 597 598 633 634 669 670 705 706 741 742 777 778 813 814 849 850 885 886 921 922 957 958 993 994 1029 1030 1065 1066 1101 110...

result:

ok OK, Accepted.

Test #21:

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

input:

300 58 71 22 15741

output:

Yes
9600 9601 10200 10201 10800 10801 11400 11401 12000 12001 12600 12601 13200 13201 13800 13801 14400 14401 15000 15001 15600 15601 16200 16201 16800 16801 17400 1 600 601 1200 1201 1800 1801 2400 2401 3000 3001 3600 3601 4200 4201 4800 4801 5400 5401 6000 6001 6600 6601 7200 7201 7800 7801 8400 8...

result:

ok OK, Accepted.

Test #22:

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

input:

290 262 3 217 58080

output:

Yes
71416 71417 71996 71997 72576 72577 73156 73157 73736 73737 74316 74317 74896 74897 75476 75477 76 77 656 657 1236 1237 1816 1817 2396 2397 2976 2977 3556 3557 4136 4137 4716 4717 5296 5297 5876 5877 6456 6457 7036 7037 7616 7617 8196 8197 8776 8777 9356 9357 9936 9937 10516 10517 11096 11097 11...

result:

ok OK, Accepted.

Test #23:

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

input:

231 272 226 145 45674

output:

Yes
11959 11960 12421 12422 12883 12884 13345 13346 13807 13808 14269 14270 14731 14732 15193 15194 15655 15656 16117 16118 16579 16580 17041 17042 17503 17504 17965 17966 18427 18428 18889 18890 19351 19352 19813 19814 20275 20276 20737 20738 21199 21200 21661 21662 22123 22124 22585 22586 23047 23...

result:

ok OK, Accepted.

Test #24:

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

input:

300 116 15 107 32192

output:

Yes
364 365 964 965 1564 1565 2164 2165 2764 2765 3364 3365 3964 3965 4564 4565 5164 5165 5764 5765 6364 6365 6964 6965 7564 7565 8164 8165 8764 8765 9364 9365 9964 9965 10564 10565 11164 11165 11764 11765 12364 12365 12964 12965 13564 13565 14164 14165 14764 14765 15364 15365 15964 15965 16564 1656...

result:

ok OK, Accepted.

Test #25:

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

input:

126 300 67 285 17771

output:

Yes
19655 19656 19907 19908 20159 20160 20411 20412 20663 20664 20915 20916 21167 21168 21419 21420 21671 21672 21923 21924 22175 22176 22427 22428 22679 22680 22931 22932 23183 23184 23435 23436 23687 23688 23939 23940 24191 24192 24443 24444 24695 24696 24947 24948 25199 25200 25451 25452 25703 25...

result:

ok OK, Accepted.

Test #26:

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

input:

231 117 51 40 8557

output:

Yes
26705 26706 140 141 602 603 1064 1065 1526 1527 1988 1989 2450 2451 2912 2913 3374 3375 3836 3837 4298 4299 4760 4761 5222 5223 5684 5685 6146 6147 6608 6609 7070 7071 7532 7533 7994 7995 8456 8457 8918 8919 9380 9381 9842 9843 10304 10305 10766 10767 11228 11229 11690 11691 12152 12153 12614 12...

result:

ok OK, Accepted.

Test #27:

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

input:

300 124 203 13 3245

output:

Yes
36441 36442 37041 37042 441 442 1041 1042 1641 1642 2241 2242 2841 2842 3441 3442 4041 4042 4641 4642 5241 5242 5841 5842 6441 6442 7041 7042 7641 7642 8241 8242 8841 8842 9441 9442 10041 10042 10641 10642 11241 11242 11841 11842 12441 12442 13041 13042 13641 13642 14241 14242 14841 14842 15441 ...

result:

ok OK, Accepted.

Test #28:

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

input:

62 146 44 52 331

output:

Yes
6197 6198 6321 6322 6445 6446 6569 6570 6693 6694 6817 6818 6941 6942 7065 7066 7189 7190 7313 7314 7437 7438 7561 7562 7685 7686 7809 7810 7933 7934 8057 8058 8181 8182 8305 8306 8429 8430 8553 8554 8677 8678 8801 8802 8925 8926 9049 9050 121 122 245 246 369 370 493 494 617 618 741 742 865 866 ...

result:

ok OK, Accepted.

Test #29:

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

input:

40 52 22 17 1571

output:

Yes
888 889 968 969 1048 1049 1128 1129 1208 1209 1288 1289 1368 1369 1448 1449 1528 1529 1608 1609 1688 1689 1768 1769 1848 1849 1928 1929 2008 2009 8 9 88 89 168 169 248 249 328 329 408 409 488 489 568 569 648 649 728 729 808 809
891 890 971 970 1051 1050 1131 1130 1211 1210 1291 1290 1371 1370 14...

result:

ok OK, Accepted.

Test #30:

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

input:

300 300 23 278 19171

output:

Yes
26326 26327 26926 26927 27526 27527 28126 28127 28726 28727 29326 29327 29926 29927 30526 30527 31126 31127 31726 31727 32326 32327 32926 32927 33526 33527 34126 34127 34726 34727 35326 35327 35926 35927 36526 36527 37126 37127 37726 37727 38326 38327 38926 38927 39526 39527 40126 40127 40726 40...

result:

ok OK, Accepted.

Test #31:

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

input:

271 253 159 69 51872

output:

Yes
33128 33129 33670 33671 34212 34213 34754 34755 35296 35297 35838 35839 36380 36381 36922 36923 37464 37465 38006 38007 38548 38549 39090 39091 39632 39633 40174 40175 40716 40717 41258 41259 41800 41801 42342 42343 42884 42885 43426 43427 43968 43969 44510 44511 45052 45053 45594 45595 46136 46...

result:

ok OK, Accepted.

Test #32:

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

input:

124 259 8 165 20677

output:

Yes
326 327 574 575 822 823 1070 1071 1318 1319 1566 1567 1814 1815 2062 2063 2310 2311 2558 2559 2806 2807 3054 3055 3302 3303 3550 3551 3798 3799 4046 4047 4294 4295 4542 4543 4790 4791 5038 5039 5286 5287 5534 5535 5782 5783 6030 6031 6278 6279 6526 6527 6774 6775 7022 7023 7270 7271 7518 7519 77...

result:

ok OK, Accepted.

Test #33:

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

input:

300 179 80 58 9660

output:

Yes
46402 46403 47002 47003 47602 47603 48202 48203 48802 48803 49402 49403 50002 50003 50602 50603 51202 51203 51802 51803 52402 52403 53002 53003 53602 53603 502 503 1102 1103 1702 1703 2302 2303 2902 2903 3502 3503 4102 4103 4702 4703 5302 5303 5902 5903 6502 6503 7102 7103 7702 7703 8302 8303 89...

result:

ok OK, Accepted.

Test #34:

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

input:

97 95 71 13 1081

output:

Yes
8992 8993 9186 9187 165 166 359 360 553 554 747 748 941 942 1135 1136 1329 1330 1523 1524 1717 1718 1911 1912 2105 2106 2299 2300 2493 2494 2687 2688 2881 2882 3075 3076 3269 3270 3463 3464 3657 3658 3851 3852 4045 4046 4239 4240 4433 4434 4627 4628 4821 4822 5015 5016 5209 5210 5403 5404 5597 5...

result:

ok OK, Accepted.

Test #35:

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

input:

288 300 233 151 62807

output:

Yes
19143 19144 19719 19720 20295 20296 20871 20872 21447 21448 22023 22024 22599 22600 23175 23176 23751 23752 24327 24328 24903 24904 25479 25480 26055 26056 26631 26632 27207 27208 27783 27784 28359 28360 28935 28936 29511 29512 30087 30088 30663 30664 31239 31240 31815 31816 32391 32392 32967 32...

result:

ok OK, Accepted.

Test #36:

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

input:

300 259 206 73 42316

output:

Yes
20305 20306 20905 20906 21505 21506 22105 22106 22705 22706 23305 23306 23905 23906 24505 24506 25105 25106 25705 25706 26305 26306 26905 26906 27505 27506 28105 28106 28705 28706 29305 29306 29905 29906 30505 30506 31105 31106 31705 31706 32305 32306 32905 32906 33505 33506 34105 34106 34705 34...

result:

ok OK, Accepted.

Test #37:

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

input:

149 295 129 201 30873

output:

Yes
817 818 1115 1116 1413 1414 1711 1712 2009 2010 2307 2308 2605 2606 2903 2904 3201 3202 3499 3500 3797 3798 4095 4096 4393 4394 4691 4692 4989 4990 5287 5288 5585 5586 5883 5884 6181 6182 6479 6480 6777 6778 7075 7076 7373 7374 7671 7672 7969 7970 8267 8268 8565 8566 8863 8864 9161 9162 9459 946...

result:

ok OK, Accepted.

Test #38:

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

input:

121 252 57 39 17402

output:

Yes
12692 12693 12934 12935 13176 13177 13418 13419 13660 13661 13902 13903 14144 14145 14386 14387 14628 14629 14870 14871 15112 15113 15354 15355 15596 15597 15838 15839 16080 16081 16322 16323 16564 16565 16806 16807 17048 17049 17290 17291 17532 17533 17774 17775 18016 18017 18258 18259 18500 18...

result:

ok OK, Accepted.

Test #39:

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

input:

300 37 136 22 4789

output:

Yes
9619 9620 10219 10220 10819 10820 319 320 919 920 1519 1520 2119 2120 2719 2720 3319 3320 3919 3920 4519 4520 5119 5120 5719 5720 6319 6320 6919 6920 7519 7520 8119 8120 8719 8720 9319
9622 9621 10222 10221 10822 10821 322 321 922 921 1522 1521 2122 2121 2722 2721 3322 3321 3922 3921 4522 4521 5...

result:

ok OK, Accepted.

Test #40:

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

input:

300 300 298 186 66405

output:

Yes
10611 10612 11211 11212 11811 11812 12411 12412 13011 13012 13611 13612 14211 14212 14811 14812 15411 15412 16011 16012 16611 16612 17211 17212 17811 17812 18411 18412 19011 19012 19611 19612 20211 20212 20811 20812 21411 21412 22011 22012 22611 22612 23211 23212 23811 23812 24411 24412 25011 25...

result:

ok OK, Accepted.