QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#806643 | #9874. Matrix Construction | WilliamHu# | WA | 1ms | 3724kb | C++11 | 1.2kb | 2024-12-09 13:28:18 | 2024-12-09 13:28:19 |
Judging History
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
Details
Tip: Click on the bar to expand more detailed information
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)