QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61588 | #4830. Transfer of Duty | yanran | 0 | 0ms | 0kb | C++14 | 1.2kb | 2022-11-14 10:26:45 | 2023-02-13 21:19:08 |
Judging History
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