QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#172993#7178. Bishopsucup-team298#WA 1ms3868kbC++14918b2023-09-09 21:33:122023-09-09 21:33:13

Judging History

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

  • [2023-09-09 21:33:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2023-09-09 21:33:12]
  • 提交

answer

#include <bits/stdc++.h>
signed main ()
{
	std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
	int n, m, f = 0; std::cin >> n >> m;
	if (n > m) std::swap(n, m), f = 1;
	std::vector<std::pair<int, int>> ans;
	if (n == 1) for (int i = 1; i <= m; i++) ans.emplace_back(1, i);
	else
	{
		int o = 0;
		for (int i = 1; i <= m; i += n - 1, o ^= 1)
			if (!o) for (int j = 1; j <= n; j++) ans.emplace_back(j, i);
			else for (int j = (n + 1) / 2; j <= n / 2 + 1; j++) ans.emplace_back(j, i);
		if ((m - 1) % (n - 1))
		{
			int l = 1, r = n;
			if (o) l = (n + 1) / 2, r = n / 2 + 1;
			l += (m - 1) % (n - 1); r -= (m - 1) % (n - 1);
			std::swap(l, r);
			for (int j = l + 1; j <= r - 1; j++) ans.emplace_back(j, m);
		}
	}
	std::cout << ans.size() << '\n';
	for (auto &[u, v]: ans) if (f) std::swap(u, v);
	for (auto [u, v]: ans) std::cout << u << " " << v << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 5

output:

10
1 1
2 1
1 2
2 2
1 3
2 3
1 4
2 4
1 5
2 5

result:

wrong answer Integer parameter [name=q] equals to 10, violates the range [0, 7]