QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#100855 | #1807. Distribute the Bars | ckiseki# | WA | 2ms | 3320kb | C++20 | 1.0kb | 2023-04-28 14:01:53 | 2023-04-28 14:01:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
if (n % 2 == 0) {
cout << n / 2 << '\n';
for (int i = 0; i < n / 2; ++i) {
cout << 2 << ' ' << 2 * i + 1 << ' ' << 2 * (n - i - 1) + 1 << '\n';
}
return 0;
}
for (int i = 2; i * i <= n; ++i) {
if (n % i != 0) continue;
auto v = vector(n / i, vector(i, 0));
for (int x = 0; x < i; ++x)
for (int y = 0; y < i; ++y)
v[x][(x+y)%i] = y;
for (int x = i; x < n / i; x += 2) {
for (int y = 0; y < i; ++y) {
v[x][y] = y;
v[x + 1][i - y - 1] = y;
}
}
cout << i << '\n';
for (int x = 0; x < i; ++x) {
cout << n / i;
for (int y = 0; y < n / i; ++y) {
cout << ' ' << 2 * v[y][x] + 1 + i * y * 2;
}
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: 2ms
memory: 3320kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3320kb
input:
2
output:
1 2 1 3
result:
wrong answer M=1 is too small