QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383357#4633. Coprime MatricesDoqeRE 0ms3708kbC++14824b2024-04-09 11:05:372024-04-09 11:05:37

Judging History

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

  • [2024-04-09 11:05:37]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3708kb
  • [2024-04-09 11:05:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=110;
int M[N][N],n,m,x,y,w;
vector<pair<int,int>>Z;
int main()
{
	cin>>n>>m>>x>>y>>w;
	cout<<"Yes\n";
	for(int _=1;_<=n+m;++_)
	{
		int X=-1,Y=-1;
		for(int i=1;i<=n&&X==-1;++i)
			for(int j=m;j;--j)if(!M[i][j]){X=i,Y=j;break;}
		if(X==-1)break;
		int er=0;
		if(_!=1&&Y!=1)--Y;
		while(X<=n&&X<=_*2-1)
		{
			Z.emplace_back(X,Y);M[X][Y]=1;
			if(Y==m||M[X][Y+1])++X;
			else ++Y,er=0;
		}
//		for(int i=1;i<=n;++i,cerr<<endl)
//			for(int j=1;j<=m;++j)cerr<<M[i][j]<<",";
//		cerr<<endl;
	}
	for(int i=0;i<n*m;++i)if(Z[i].first==x&&Z[i].second==y)
	{
		for(int j=0;j<n*m;++j)
			M[Z[(i+j)%(n*m)].first][Z[(i+j)%(n*m)].second]
			=(w+j-1)%(n*m)+1;break;
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)cout<<M[i][j]<<" \n"[j==m];
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3 2 1 3

output:

Yes
7 8 6
3 9 1
4 5 2

result:

ok OK, Accepted.

Test #2:

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

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

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

input:

8 3 4 2 9

output:

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

result:

ok OK, Accepted.

Test #4:

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

input:

7 6 7 2 28

output:

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

result:

ok OK, Accepted.

Test #5:

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

input:

6 8 1 2 7

output:

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

result:

ok OK, Accepted.

Test #6:

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

input:

8 8 7 3 56

output:

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

result:

ok OK, Accepted.

Test #7:

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

input:

2 4 2 1 8

output:

Yes
7 3 4 2
8 1 5 6

result:

ok OK, Accepted.

Test #8:

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

input:

6 6 4 2 17

output:

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

result:

ok OK, Accepted.

Test #9:

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

input:

8 6 3 1 33

output:

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

result:

ok OK, Accepted.

Test #10:

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

input:

2 8 2 4 15

output:

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

result:

ok OK, Accepted.

Test #11:

score: -100
Runtime Error

input:

295 280 79 198 74034

output:


result: