QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371405#6743. water235liutaowoaini#WA 1ms3660kbC++171.4kb2024-03-30 10:43:282024-03-30 10:43:29

Judging History

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

  • [2024-03-30 10:43:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2024-03-30 10:43:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int ans = n / 2 + 1 + m / 2;
	if (n == 1 && m == 1)
	{
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	if (n == 2&&m==2)
	{
		cout << 2 << endl;
		cout << 1 <<' ' << 0 << endl;
		cout << 0 <<' ' << 1 << endl;
		return 0;
	}
	if (m == 2)
	{
		if (n == 1)
		{
			cout << 2 << endl;
			cout << 1 <<' ' << 1 << endl;
			return 0;
		}
		else
		{
			int ans = 2 + (n - 1) / 2;
			cout << ans << endl;
			cout << 1<<' ' << 0 << endl;
			cout << 0<<" "<<1 << endl;
			for (int i = 3; i <= n; i++)
			{
				if (i == n && i & 1)
				{
					cout << 1<<' '<<0 << endl;
					continue;
				}
				for (int j = 1; j <= m; j++)
				{
					if (i % 2 == 0 && j == 1) cout << 1<<' ';
					else cout << 0<<' ';
				}
				cout << endl;
			}
		}
		return 0;
	}
	cout << ans << endl;
	for (int i = 1; i <= m; i++)
	{
		if (i == m)
		{
			cout << 1 << endl;
			continue;
		}
		if (i & 1) cout << 1<<' ';
		else cout << 0<<' ';
	}
	for (int i = 2; i <= n; i++)
	{
		if (i == n && i % 2 == 0)
		{
			for (int j = 1; j <= m; j++)
			{
				if (j == 1) cout << 1<<' ';
				else cout << 0<<' ';
			}
			cout << endl;
			continue;
		}
		for (int j = 1; j <= m; j++)
		{
			if (i & 1 && j == 1) cout << 1<<' ';
			else cout << 0<<' ';
		}
		cout << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1

output:

2
1
1 

result:

ok The answer is correct.

Test #2:

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

input:

3 3

output:

3
1 0 1
0 0 0 
1 0 0 

result:

ok The answer is correct.

Test #3:

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

input:

1 4

output:

3
1 0 1 1

result:

ok The answer is correct.

Test #4:

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

input:

2 2

output:

2
1 0
0 1

result:

ok The answer is correct.

Test #5:

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

input:

2 4

output:

4
1 0 1 1
1 0 0 0 

result:

wrong answer The answer is wrong: expected = 3, found = 4