QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360049#4633. Coprime MatricesKevin5307WA 1ms3716kbC++201.8kb2024-03-21 10:42:552024-03-21 10:42:56

Judging History

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

  • [2024-03-21 10:42:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3716kb
  • [2024-03-21 10:42:55]
  • 提交

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[100100];
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]+1;
		for(int i=0;i<m+m;i++)
			used[rep[x/2*2]+i]=psum[rep[x/2*2]+i]=1;
	}
	for(int i=1;i<=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]-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: 1ms
memory: 3640kb

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: 3584kb

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

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

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: 3716kb

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: 3680kb

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: -100
Wrong Answer
time: 1ms
memory: 3692kb

input:

8 8 7 3 56

output:

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

result:

wrong answer Integer parameter [name=A[i][j]] equals to 66, violates the range [1, 64]