QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#347522#4633. Coprime Matricesucup-team1209AC ✓5ms6184kbC++202.5kb2024-03-09 14:07:452024-03-09 14:07:46

Judging History

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

  • [2024-03-09 14:07:46]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:6184kb
  • [2024-03-09 14:07:45]
  • 提交

answer

#include<bits/stdc++.h>
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 333
    typedef long long ll;
    typedef double db;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
    void file()
    {
        #ifdef NTFOrz
        freopen("a.in","r",stdin);
        #endif
    }
    inline void chktime()
    {
        #ifdef NTFOrz
        cerr<<clock()/1000.0<<'\n';
        #endif
    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
}
using namespace my_std;

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

int main()
{
    file();
    read(n,m,x,y,w);
    int t=1,_n=n;
    while (n>=2)
    {
        rep(i,1,m)
            if (i&1) ans[n-1][i]=t++,ans[n][i]=t++;
            else ans[n][i]=t++,ans[n-1][i]=t++;
        n-=2;
    }
    if (n) rep(i,1,m) ans[1][i]=t++;
    n=_n;
    int delta=w-ans[x][y];
    rep(i,1,n) rep(j,1,m) ans[i][j]+=delta;
    rep(i,1,n) rep(j,1,m) if (ans[i][j]<=0) ans[i][j]+=n*m; else if (ans[i][j]>n*m) ans[i][j]-=n*m;
    puts("Yes");
    rep(i,1,n) rep(j,1,m) printf("%d%c",ans[i][j]," \n"[j==m]);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5840kb

input:

3 3 2 1 3

output:

Yes
9 1 2
3 6 7
4 5 8

result:

ok OK, Accepted.

Test #2:

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

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

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

input:

8 3 4 2 9

output:

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

result:

ok OK, Accepted.

Test #4:

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

input:

7 6 7 2 28

output:

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

result:

ok OK, Accepted.

Test #5:

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

input:

6 8 1 2 7

output:

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

result:

ok OK, Accepted.

Test #6:

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

input:

8 8 7 3 56

output:

Yes
36 39 40 43 44 47 48 51
37 38 41 42 45 46 49 50
20 23 24 27 28 31 32 35
21 22 25 26 29 30 33 34
4 7 8 11 12 15 16 19
5 6 9 10 13 14 17 18
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: 3740kb

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: 0ms
memory: 3848kb

input:

6 6 4 2 17

output:

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

result:

ok OK, Accepted.

Test #9:

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

input:

8 6 3 1 33

output:

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

result:

ok OK, Accepted.

Test #10:

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

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: 0ms
memory: 4236kb

input:

295 280 79 198 74034

output:

Yes
12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12...

result:

ok OK, Accepted.

Test #12:

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

input:

300 26 55 17 3020

output:

Yes
4392 4395 4396 4399 4400 4403 4404 4407 4408 4411 4412 4415 4416 4419 4420 4423 4424 4427 4428 4431 4432 4435 4436 4439 4440 4443
4393 4394 4397 4398 4401 4402 4405 4406 4409 4410 4413 4414 4417 4418 4421 4422 4425 4426 4429 4430 4433 4434 4437 4438 4441 4442
4340 4343 4344 4347 4348 4351 4352 4...

result:

ok OK, Accepted.

Test #13:

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

input:

288 282 125 58 43649

output:

Yes
78502 78505 78506 78509 78510 78513 78514 78517 78518 78521 78522 78525 78526 78529 78530 78533 78534 78537 78538 78541 78542 78545 78546 78549 78550 78553 78554 78557 78558 78561 78562 78565 78566 78569 78570 78573 78574 78577 78578 78581 78582 78585 78586 78589 78590 78593 78594 78597 78598 78...

result:

ok OK, Accepted.

Test #14:

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

input:

128 299 59 164 38067

output:

Yes
16810 16813 16814 16817 16818 16821 16822 16825 16826 16829 16830 16833 16834 16837 16838 16841 16842 16845 16846 16849 16850 16853 16854 16857 16858 16861 16862 16865 16866 16869 16870 16873 16874 16877 16878 16881 16882 16885 16886 16889 16890 16893 16894 16897 16898 16901 16902 16905 16906 16...

result:

ok OK, Accepted.

Test #15:

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

input:

300 300 286 253 60209

output:

Yes
54904 54907 54908 54911 54912 54915 54916 54919 54920 54923 54924 54927 54928 54931 54932 54935 54936 54939 54940 54943 54944 54947 54948 54951 54952 54955 54956 54959 54960 54963 54964 54967 54968 54971 54972 54975 54976 54979 54980 54983 54984 54987 54988 54991 54992 54995 54996 54999 55000 55...

result:

ok OK, Accepted.

Test #16:

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

input:

240 77 171 56 15870

output:

Yes
10369 10372 10373 10376 10377 10380 10381 10384 10385 10388 10389 10392 10393 10396 10397 10400 10401 10404 10405 10408 10409 10412 10413 10416 10417 10420 10421 10424 10425 10428 10429 10432 10433 10436 10437 10440 10441 10444 10445 10448 10449 10452 10453 10456 10457 10460 10461 10464 10465 10...

result:

ok OK, Accepted.

Test #17:

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

input:

165 141 69 107 11237

output:

Yes
20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20...

result:

ok OK, Accepted.

Test #18:

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

input:

300 200 106 195 36560

output:

Yes
56971 56974 56975 56978 56979 56982 56983 56986 56987 56990 56991 56994 56995 56998 56999 57002 57003 57006 57007 57010 57011 57014 57015 57018 57019 57022 57023 57026 57027 57030 57031 57034 57035 57038 57039 57042 57043 57046 57047 57050 57051 57054 57055 57058 57059 57062 57063 57066 57067 57...

result:

ok OK, Accepted.

Test #19:

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

input:

247 46 55 25 776

output:

Yes
3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256
3119 3122 3123 3126 3127 3130 3131 3134 3135 3138 3139 3142 3143 3...

result:

ok OK, Accepted.

Test #20:

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

input:

18 300 15 168 2858

output:

Yes
1323 1326 1327 1330 1331 1334 1335 1338 1339 1342 1343 1346 1347 1350 1351 1354 1355 1358 1359 1362 1363 1366 1367 1370 1371 1374 1375 1378 1379 1382 1383 1386 1387 1390 1391 1394 1395 1398 1399 1402 1403 1406 1407 1410 1411 1414 1415 1418 1419 1422 1423 1426 1427 1430 1431 1434 1435 1438 1439 1...

result:

ok OK, Accepted.

Test #21:

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

input:

300 58 71 22 15741

output:

Yes
2358 2361 2362 2365 2366 2369 2370 2373 2374 2377 2378 2381 2382 2385 2386 2389 2390 2393 2394 2397 2398 2401 2402 2405 2406 2409 2410 2413 2414 2417 2418 2421 2422 2425 2426 2429 2430 2433 2434 2437 2438 2441 2442 2445 2446 2449 2450 2453 2454 2457 2458 2461 2462 2465 2466 2469 2470 2473
2359 2...

result:

ok OK, Accepted.

Test #22:

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

input:

290 262 3 217 58080

output:

Yes
58172 58175 58176 58179 58180 58183 58184 58187 58188 58191 58192 58195 58196 58199 58200 58203 58204 58207 58208 58211 58212 58215 58216 58219 58220 58223 58224 58227 58228 58231 58232 58235 58236 58239 58240 58243 58244 58247 58248 58251 58252 58255 58256 58259 58260 58263 58264 58267 58268 58...

result:

ok OK, Accepted.

Test #23:

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

input:

231 272 226 145 45674

output:

Yes
44026 44027 44028 44029 44030 44031 44032 44033 44034 44035 44036 44037 44038 44039 44040 44041 44042 44043 44044 44045 44046 44047 44048 44049 44050 44051 44052 44053 44054 44055 44056 44057 44058 44059 44060 44061 44062 44063 44064 44065 44066 44067 44068 44069 44070 44071 44072 44073 44074 44...

result:

ok OK, Accepted.

Test #24:

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

input:

300 116 15 107 32192

output:

Yes
33604 33607 33608 33611 33612 33615 33616 33619 33620 33623 33624 33627 33628 33631 33632 33635 33636 33639 33640 33643 33644 33647 33648 33651 33652 33655 33656 33659 33660 33663 33664 33667 33668 33671 33672 33675 33676 33679 33680 33683 33684 33687 33688 33691 33692 33695 33696 33699 33700 33...

result:

ok OK, Accepted.

Test #25:

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

input:

126 300 67 285 17771

output:

Yes
37003 37006 37007 37010 37011 37014 37015 37018 37019 37022 37023 37026 37027 37030 37031 37034 37035 37038 37039 37042 37043 37046 37047 37050 37051 37054 37055 37058 37059 37062 37063 37066 37067 37070 37071 37074 37075 37078 37079 37082 37083 37086 37087 37090 37091 37094 37095 37098 37099 37...

result:

ok OK, Accepted.

Test #26:

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

input:

231 117 51 40 8557

output:

Yes
14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14...

result:

ok OK, Accepted.

Test #27:

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

input:

300 124 203 13 3245

output:

Yes
28269 28272 28273 28276 28277 28280 28281 28284 28285 28288 28289 28292 28293 28296 28297 28300 28301 28304 28305 28308 28309 28312 28313 28316 28317 28320 28321 28324 28325 28328 28329 28332 28333 28336 28337 28340 28341 28344 28345 28348 28349 28352 28353 28356 28357 28360 28361 28364 28365 28...

result:

ok OK, Accepted.

Test #28:

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

input:

62 146 44 52 331

output:

Yes
6361 6364 6365 6368 6369 6372 6373 6376 6377 6380 6381 6384 6385 6388 6389 6392 6393 6396 6397 6400 6401 6404 6405 6408 6409 6412 6413 6416 6417 6420 6421 6424 6425 6428 6429 6432 6433 6436 6437 6440 6441 6444 6445 6448 6449 6452 6453 6456 6457 6460 6461 6464 6465 6468 6469 6472 6473 6476 6477 6...

result:

ok OK, Accepted.

Test #29:

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

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: 2ms
memory: 6012kb

input:

300 300 23 278 19171

output:

Yes
25216 25219 25220 25223 25224 25227 25228 25231 25232 25235 25236 25239 25240 25243 25244 25247 25248 25251 25252 25255 25256 25259 25260 25263 25264 25267 25268 25271 25272 25275 25276 25279 25280 25283 25284 25287 25288 25291 25292 25295 25296 25299 25300 25303 25304 25307 25308 25311 25312 25...

result:

ok OK, Accepted.

Test #31:

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

input:

271 253 159 69 51872

output:

Yes
23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23...

result:

ok OK, Accepted.

Test #32:

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

input:

124 259 8 165 20677

output:

Yes
21902 21905 21906 21909 21910 21913 21914 21917 21918 21921 21922 21925 21926 21929 21930 21933 21934 21937 21938 21941 21942 21945 21946 21949 21950 21953 21954 21957 21958 21961 21962 21965 21966 21969 21970 21973 21974 21977 21978 21981 21982 21985 21986 21989 21990 21993 21994 21997 21998 22...

result:

ok OK, Accepted.

Test #33:

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

input:

300 179 80 58 9660

output:

Yes
23508 23511 23512 23515 23516 23519 23520 23523 23524 23527 23528 23531 23532 23535 23536 23539 23540 23543 23544 23547 23548 23551 23552 23555 23556 23559 23560 23563 23564 23567 23568 23571 23572 23575 23576 23579 23580 23583 23584 23587 23588 23591 23592 23595 23596 23599 23600 23603 23604 23...

result:

ok OK, Accepted.

Test #34:

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

input:

97 95 71 13 1081

output:

Yes
7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7...

result:

ok OK, Accepted.

Test #35:

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

input:

288 300 233 151 62807

output:

Yes
45707 45710 45711 45714 45715 45718 45719 45722 45723 45726 45727 45730 45731 45734 45735 45738 45739 45742 45743 45746 45747 45750 45751 45754 45755 45758 45759 45762 45763 45766 45767 45770 45771 45774 45775 45778 45779 45782 45783 45786 45787 45790 45791 45794 45795 45798 45799 45802 45803 45...

result:

ok OK, Accepted.

Test #36:

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

input:

300 259 206 73 42316

output:

Yes
17307 17310 17311 17314 17315 17318 17319 17322 17323 17326 17327 17330 17331 17334 17335 17338 17339 17342 17343 17346 17347 17350 17351 17354 17355 17358 17359 17362 17363 17366 17367 17370 17371 17374 17375 17378 17379 17382 17383 17386 17387 17390 17391 17394 17395 17398 17399 17402 17403 17...

result:

ok OK, Accepted.

Test #37:

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

input:

149 295 129 201 30873

output:

Yes
24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24...

result:

ok OK, Accepted.

Test #38:

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

input:

121 252 57 39 17402

output:

Yes
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1...

result:

ok OK, Accepted.

Test #39:

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

input:

300 37 136 22 4789

output:

Yes
9705 9708 9709 9712 9713 9716 9717 9720 9721 9724 9725 9728 9729 9732 9733 9736 9737 9740 9741 9744 9745 9748 9749 9752 9753 9756 9757 9760 9761 9764 9765 9768 9769 9772 9773 9776 9777
9706 9707 9710 9711 9714 9715 9718 9719 9722 9723 9726 9727 9730 9731 9734 9735 9738 9739 9742 9743 9746 9747 9...

result:

ok OK, Accepted.

Test #40:

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

input:

300 300 298 186 66405

output:

Yes
64835 64838 64839 64842 64843 64846 64847 64850 64851 64854 64855 64858 64859 64862 64863 64866 64867 64870 64871 64874 64875 64878 64879 64882 64883 64886 64887 64890 64891 64894 64895 64898 64899 64902 64903 64906 64907 64910 64911 64914 64915 64918 64919 64922 64923 64926 64927 64930 64931 64...

result:

ok OK, Accepted.