QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360065#4633. Coprime MatricesKevin5307WA 4ms5172kbC++201.9kb2024-03-21 11:03:572024-03-21 11:03:57

Judging History

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

  • [2024-03-21 11:03:57]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:5172kb
  • [2024-03-21 11:03:57]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int ind[303][303],ans[303][303];
int rep[303];
bool used[100100];
int psum[200100];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,x,y,w;
	cin>>n>>m>>x>>y>>w;
	for(int i=2;i<n;i+=2)
	{
		int tot=0;
		for(int j=1;j<=m;j++)
			if(j%2)
			{
				ind[i][j]=++tot;
				ind[i+1][j]=++tot;
			}
			else
			{
				ind[i+1][j]=++tot;
				ind[i][j]=++tot;
			}
	}
	if(!ind[x][y])
	{
		ans[x][y]=w;
		used[w]=1;
		psum[w]=1;
	}
	else
	{
		rep[x/2*2]=(w-ind[x][y]+n*m)%(n*m)+1;
		for(int i=0;i<m+m;i++)
			used[(rep[x/2*2]+i-1)%(n*m)+1]=psum[(rep[x/2*2]+i-1)%(n*m)+1]=1;
	}
	for(int i=1;i<=n*m;i++)
		psum[i+n*m]=psum[i];
	for(int i=1;i<=n*m+n*m;i++)
		psum[i]+=psum[i-1];
	int p=1;
	for(int i=2;i<n;i+=2)
		if(!rep[i])
		{
			while(psum[p+m+m-1]!=psum[p-1])
				p++;
			rep[i]=p;
			p+=m+m;
		}
	for(int i=2;i<n;i+=2)
		for(int j=1;j<=m;j++)
			for(int k=0;k<2;k++)
			{
				ans[i+k][j]=(rep[i]+ind[i+k][j]-2+n*m)%(n*m)+1;
				used[ans[i+k][j]]=1;
			}
	p=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(!ind[i][j]&&!ans[i][j])
			{
				while(used[p]) p++;
				used[p]=1;
				ans[i][j]=p;
			}
	cout<<"Yes\n";
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cout<<ans[i][j]<<" \n"[j==m];
	return 0;
}

详细

Test #1:

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

input:

3 3 2 1 3

output:

Yes
1 2 9
3 6 7
4 5 8

result:

ok OK, Accepted.

Test #2:

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

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

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

input:

8 3 4 2 9

output:

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

result:

ok OK, Accepted.

Test #4:

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

input:

7 6 7 2 28

output:

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

result:

ok OK, Accepted.

Test #5:

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

input:

6 8 1 2 7

output:

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

result:

ok OK, Accepted.

Test #6:

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

input:

8 8 7 3 56

output:

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

result:

ok OK, Accepted.

Test #7:

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

input:

2 4 2 1 8

output:

Yes
1 2 3 4
8 5 6 7

result:

ok OK, Accepted.

Test #8:

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

input:

6 6 4 2 17

output:

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

result:

ok OK, Accepted.

Test #9:

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

input:

8 6 3 1 33

output:

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

result:

ok OK, Accepted.

Test #10:

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

input:

2 8 2 4 15

output:

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

result:

ok OK, Accepted.

Test #11:

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

input:

295 280 79 198 74034

output:

Yes
73361 73362 73363 73364 73365 73366 73367 73368 73369 73370 73371 73372 73373 73374 73375 73376 73377 73378 73379 73380 73381 73382 73383 73384 73385 73386 73387 73388 73389 73390 73391 73392 73393 73394 73395 73396 73397 73398 73399 73400 73401 73402 73403 73404 73405 73406 73407 73408 73409 73...

result:

ok OK, Accepted.

Test #12:

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

input:

300 26 55 17 3020

output:

Yes
2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 7771 7772 7773 7774
1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52
2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51
53 56 57 60 61 64 6...

result:

ok OK, Accepted.

Test #13:

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

input:

288 282 125 58 43649

output:

Yes
43429 43430 43431 43432 43433 43434 43435 43436 43437 43438 43439 43440 43441 43442 43443 43444 43445 43446 43447 43448 43449 43450 43451 43452 43453 43454 43455 43456 43457 43458 43459 43460 43461 43462 43463 43464 43465 43466 43467 43468 43469 43470 43471 43472 43473 43474 43475 43476 43477 43...

result:

ok OK, Accepted.

Test #14:

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

input:

128 299 59 164 38067

output:

Yes
37143 37144 37145 37146 37147 37148 37149 37150 37151 37152 37153 37154 37155 37156 37157 37158 37159 37160 37161 37162 37163 37164 37165 37166 37167 37168 37169 37170 37171 37172 37173 37174 37175 37176 37177 37178 37179 37180 37181 37182 37183 37184 37185 37186 37187 37188 37189 37190 37191 37...

result:

ok OK, Accepted.

Test #15:

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

input:

300 300 286 253 60209

output:

Yes
59401 59402 59403 59404 59405 59406 59407 59408 59409 59410 59411 59412 59413 59414 59415 59416 59417 59418 59419 59420 59421 59422 59423 59424 59425 59426 59427 59428 59429 59430 59431 59432 59433 59434 59435 59436 59437 59438 59439 59440 59441 59442 59443 59444 59445 59446 59447 59448 59449 59...

result:

ok OK, Accepted.

Test #16:

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

input:

240 77 171 56 15870

output:

Yes
15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15...

result:

ok OK, Accepted.

Test #17:

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

input:

165 141 69 107 11237

output:

Yes
10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23...

result:

ok OK, Accepted.

Test #18:

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

input:

300 200 106 195 36560

output:

Yes
36001 36002 36003 36004 36005 36006 36007 36008 36009 36010 36011 36012 36013 36014 36015 36016 36017 36018 36019 36020 36021 36022 36023 36024 36025 36026 36027 36028 36029 36030 36031 36032 36033 36034 36035 36036 36037 36038 36039 36040 36041 36042 36043 36044 36045 36046 36047 36048 36049 36...

result:

ok OK, Accepted.

Test #19:

score: -100
Wrong Answer
time: 1ms
memory: 4388kb

input:

247 46 55 25 776

output:

Yes
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 ...

result:

wrong answer Duplicated Entry