QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546182#1807. Distribute the Barssurgutti#WA 0ms3856kbC++17884b2024-09-03 20:36:032024-09-03 20:36:03

Judging History

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

  • [2024-09-03 20:36:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-09-03 20:36:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	if (n == 2) {
		cout << "-1\n";
		return 0;
	}

	if (n % 2 == 0) {
		cout << n / 2 << '\n';
		for (int i = 1; i <= n / 2; i++) {
			cout << 2 << ' ' << 2 * i - 1 << ' ' << 2 * (n - i + 1) - 1 << '\n';
		}
		return 0;
	}

	int sq = 2;
	while (sq * sq <= n) {
		if (n % (sq * sq) == 0) {
			break;
		}

		sq++;
	}
	
	if (n % (sq * sq) == 0) {
		vector<vector<int>> types(n / sq);

		for (int i = 0; i < n; i++) {
			types[i / sq].push_back(2 * (i + 1) - 1);
		}
		
		cout << sq << '\n';

		for (int i = 0; i < sq; i++) {
			cout << n / sq << ' ';
			for (int j = 0; j < n / sq; j++) {
				cout << types[j][(i + j) % sq] << ' ';
			}
			cout << '\n';
		}
		return 0;
	}
	
	cout << "-1\n";

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4

output:

2
2 1 7
2 3 5

result:

ok OK (2 groups)

Test #2:

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

input:

2

output:

-1

result:

ok OK (impossible)

Test #3:

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

input:

3

output:

-1

result:

ok OK (impossible)

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

1659

output:

-1

result:

wrong answer Jury found the solution, contestant isn't