QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#100854 | #1807. Distribute the Bars | ckiseki# | RE | 2ms | 3360kb | C++20 | 850b | 2023-04-28 13:54:30 | 2023-04-28 13:54:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
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: 3312kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 2ms
memory: 3320kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3292kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 1ms
memory: 3360kb
input:
1659
output:
3 553 1 11 15 19 29 31 41 43 53 55 65 67 77 79 89 91 101 103 113 115 125 127 137 139 149 151 161 163 173 175 185 187 197 199 209 211 221 223 233 235 245 247 257 259 269 271 281 283 293 295 305 307 317 319 329 331 341 343 353 355 365 367 377 379 389 391 401 403 413 415 425 427 437 439 449 451 461 463...
result:
ok OK (3 groups)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3356kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: -100
Runtime Error
input:
458