QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61612 | #1807. Distribute the Bars | Pitiless0514 | WA | 6ms | 9824kb | C++14 | 3.7kb | 2022-11-14 11:26:57 | 2022-11-14 11:27:01 |
Judging History
answer
// 德丽莎你好可爱德丽莎你好可爱德丽莎你好可爱德丽莎你好可爱德丽莎你好可爱
// 德丽莎的可爱在于德丽莎很可爱,德丽莎为什么很可爱呢,这是因为德丽莎很可爱!
// 没有力量的理想是戏言,没有理想的力量是空虚
#include <bits/stdc++.h>
#define LL long long
using namespace std;
namespace IO {
const int SZ = (1 << 21) + 1;
char ib[SZ], *iS, *iT, ob[SZ], *oS = ob, *oT = oS + SZ - 1, cc, qu[55]; int ff, qr;
#define gc() (iS == iT ? (iT = (iS = ib) + fread(ib, 1, SZ, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
void flush() { fwrite(ob, 1, oS - ob, stdout), oS = ob; }
void putc(char x) { *oS++ = x; if (oS == oT) flush(); }
template <class I>
void read(I &x) {
for (ff = 1, cc = gc(); cc < '0' || cc > '9'; cc = gc()) if (cc == '-') ff = -1;
for (x = 0; cc <= '9' && cc >= '0'; cc = gc()) x = x * 10 + (cc & 15);
x *= ff;
}
template <class I, class... Y>
void read(I &t, Y &... a) { read(t), read(a...); }
template <class I>
void write(I x) {
if (!x) putc('0');
if (x < 0) putc('-'), x = -x;
while (x) qu[++qr] = x % 10 + '0', x /= 10;
while (qr) putc(qu[qr --]);
}
} using namespace IO;
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define repd(i, l, r) for (int i = (l); i >= (r); i--)
#define REP(i, l, r) for (int i = (l); i < (r); i++)
bool o1;
const int N = 2e5;
int n;
vector <int> ver[N];
deque <int> now;
void GG() { printf("-1\n"); exit(0); }
int check(int x) {
for (int i = 2; i * i <= x; i++)
if (x % i == 0) return false;
return true;
}
void solve() {
scanf("%d", &n);
if (n % 4 == 0) {
rep (i, 1, n) {
if (i % 4 == 0) {
ver[1].push_back(i);
} else if (i % 4 == 1) {
ver[1].push_back(i);
} else if (i % 4 == 2) {
ver[2].push_back(i);
} else if (i % 4 == 3) {
ver[2].push_back(i);
}
}
printf("2\n");
rep (i, 1, 2) {
printf("%d ", (int)ver[i].size());
for (auto x : ver[i]) printf("%d ", 2 * x - 1);
printf("\n");
}
return ;
} else {
if (n == 1) GG();
if (n == 2) GG();
if (check(n) == 1) GG();
if (n % 2 == 0) {
int num = 0;
rep (i, 1, n) now.push_back(2 * i - 1);
rep (i, 1, n / 2) {
++ num;
ver[num].push_back(now.front());
now.pop_front();
ver[num].push_back(now.back());
now.pop_back();
}
printf("%d\n", num);
rep (i, 1, num) {
printf("%d ",(int)ver[i].size());
for (auto x : ver[i]) printf("%d ", x);
printf("\n");
}
} else {
for (int d = 2; d * d <= n; d++) {
if (n % d == 0) {
int x = n / d, p = 0;
for (int j = 0; j < d; j++) {
printf("%d ", x);
for (int k = 0; k < d; k++) printf("%d ", 2 * (k * d + (k + j) % d + 1) - 1);
for (int k = 0; k < (x - d) / 2; k ++) {
++ p;
printf("%d ", 2 * (d * d + p) - 1);
printf("%d ", 2 * (n - p + 1) - 1);
}
printf("\n");
}
return ;
}
}
}
}
}
bool o2;
signed main () {
#ifdef LOCAL_DEFINE
cerr << "Memory elapsed: " << 1.0 * (&o1 - &o2) / 1024 / 1024 << ".Mib\n";
freopen("1.in", "r", stdin);
freopen("1.ans", "w", stdout);
#endif
int T = 1; while (T--) solve();
flush();
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 6ms
memory: 9012kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 1ms
memory: 9824kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 2ms
memory: 9168kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 9232kb
input:
1659
output:
553 1 9 17 19 3317 21 3315 23 3313 25 3311 27 3309 29 3307 31 3305 33 3303 35 3301 37 3299 39 3297 41 3295 43 3293 45 3291 47 3289 49 3287 51 3285 53 3283 55 3281 57 3279 59 3277 61 3275 63 3273 65 3271 67 3269 69 3267 71 3265 73 3263 75 3261 77 3259 79 3257 81 3255 83 3253 85 3251 87 3249 89 3247 9...
result:
wrong answer Integer 3301 violates the range [1, 1659]