QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#806643#9874. Matrix ConstructionWilliamHu#WA 1ms3724kbC++111.2kb2024-12-09 13:28:182024-12-09 13:28:19

Judging History

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

  • [2024-12-09 13:28:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3724kb
  • [2024-12-09 13:28:18]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int n, m, T;
int a[1010][1010];
int ans;

signed main()
{
	T = read();
	while(T --)
	{
		n = read();
		m = read();
		int flag = 0;
		if(n % 2 != 0)
		{
			flag = 1;
			swap(n, m);
		}
		
		int cnt1 = 0, cnt2 = 0;
		for(int i = 1;i <= (n/2)*2;i ++)
		{
			for(int j = 1;j <= m;j ++)
			{
				if(i % 2 == 0)a[i][j] = 2* (++ cnt2);
				else a[i][j] = 2*(++cnt1)-1;
			}
		}
		if(n % 2 == 1)
		{
			for(int j = 1;j <= m;j ++)
			{
				if(cnt1 * 2 + 1 <= n * m)a[n][j] = 2*(++cnt1)-1;
				else a[n][j] = 2*(++cnt2);
			}
		}
		if(flag)
		{
			for(int i = 1;i <= m;i ++)
			{
				for(int j = 1;j <= n;j ++)
				{
					cout<<a[j][i]<<' ';
				}
				cout<<endl;
			}
		}
		else
		{
			for(int i = 1;i <= n;i ++)
			{
				for(int j = 1;j <= m;j ++)
				{
					cout<<a[i][j]<<' ';
				}
				cout<<endl;
			}
			
		}
	}
	return 0;
}
//1 3 5
//2 4 6
//7 9 8

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3724kb

input:

2
1 1
2 3

output:

1 
1 3 5 
2 4 6 

result:

wrong answer Token parameter [name=ok] equals to "1", doesn't correspond to pattern "[yY][eE][sS]" (test case 1)