QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61588#4830. Transfer of Dutyyanran0 0ms0kbC++141.2kb2022-11-14 10:26:452023-02-13 21:19:08

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-13 21:19:08]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2022-11-14 10:26:45]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS\
	ios::sync_with_stdio(false);\
	cin.tie(0), cout.tie(0);

using namespace std;

const int N = 1e5 + 3;

int a[N], n;
vector<int> b[N];

void ou(int l, int r, int p) {
	if (l > r) return;
	int num = (r - l + 1) / p / 2, cnt;
	for (int i = 1; i <= p; i++) {
		cnt = num;
		while (cnt--) {
			b[i].push_back(a[l]);
			l++;
		}
		cnt = num;
		while (cnt--) {
			b[i].push_back(a[r]);
			r--;
		}
	}
}

void ji(int m, int p) {
	for (int i = 1; i <= p; i++) {
		for (int j = i, now = i; j <= m; j += p) {
			b[now].push_back(a[j]);
			now--;
			if (!now) now = p;
		}
	}
}

int pd(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			return i;
		}
	}
	return 0;
}

signed main() {
	IOS;
	cin >> n;
	int p = pd(n);
	if (!p) {
		cout << -1;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		a[i] = i * 2 - 1;
	}
	if (n & 1) {
		ji(p * p, p);
		ou(p * p + 1, n, p);
	}
	else {
		p = n / 2;
		ou(1, n, n / 2);
	}
	cout << p << '\n';
	for (int i = 1; i <= p; i++) {
		cout << b[i].size() << ' ';
		for (auto x : b[i]) {
			cout << x << ' ';
		}
		cout << '\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer on the first run

input:

start
5
10
14
10
12
10

output:

-1

input:


output:


result:

wrong answer wrong answer on the first run, query 1: read -1 but expected 10