QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22412 | #2351. Lost in Transfer | li0201# | 0 | 2ms | 3832kb | C++20 | 3.0kb | 2022-03-09 17:34:31 | 2023-01-17 09:35:41 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define ROF(i, a, b) for (int i = a; i >= b; --i)
#define NEXT(i, r, v) for (int i = h[r], v; v = e[i].v, i; i = e[i].u)
const int INF = 2e9;
inline int Max(const int &a, const int &b) { return a > b ? a : b; }
inline int Min(const int &a, const int &b) { return a > b ? b : a; }
inline int read() {
int f = 1, x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int N = 205;
using namespace std;
int T, n, a[N], b[N], d[N];
int fac[10];
char qwq[N];
int enqwq() {
int w = 1;
FOR(i, 1, 6) {
int s = 0;
FOR(j, 1, i - 1) {
if (b[j] < b[i]) ++s;
}
w += s * fac[i - 1];
}
return w;
}
void deqwq(int w) {
--w;
vector<int> t(6);
FOR(i, 0, 5) t[i] = i + 1;
FOR(i, 1, 6) {
int r = w / fac[6 - i];
w %= fac[6 - i];
b[i] = t[r];
t.erase(t.begin() + r);
}
}
int getw(int l, int r) {
FOR(i, l, r) b[i - l + 1] = a[i];
return enqwq();
}
void transqwq() {
n = read();
FOR(i, 1, n) a[i] = read();
sort(a + 1, a + n + 1);
int mxid = 1, smxid = 1;
FOR(i, 1, n) {
if (a[i] > a[mxid]) {
smxid = mxid;
mxid = i;
} else if (a[i] > a[smxid]) {
smxid = i;
}
}
swap(a[mxid], a[7]);
swap(a[smxid], a[14]);
int x = 0;
FOR(i, 1, n) x ^= a[i];
deqwq(x), reverse(b + 1, b + 7);
sort(a + 1, a + 7);
sort(a + 8, a + 14);
sort(a + n - 5, a + n + 1);
FOR(i, 1, 6) d[i] = a[b[i]];
d[7] = a[7];
FOR(i, 1, 6) d[7 + i] = a[7 + b[i]];
FOR(i, 14, n - 6) d[i] = a[i];
FOR(i, 1, 6) d[n - 6 + i] = a[n - 6 + b[i]];
FOR(i, 1, n) printf("%d ", d[i]);
puts("");
}
void recoverqwq() {
n = read();
int s = 0;
FOR(i, 1, n) a[i] = read(), s ^= a[i];
int x = getw(1, 6), y = getw(8, 13), z = getw(n - 5, n);
if (x == y && y == z && z == s) {
sort(a + 1, a + n + 1);
FOR(i, 1, n) printf("%d ", a[i]);
puts("");
return;
}
int res = 0;
if (x > 600 || y > 600) {
res = s ^ z;
} else if (x == y || x == z) {
res = s ^ x;
} else {
res = s ^ z;
}
a[++n] = res;
sort(a + 1, a + n + 1);
FOR(i, 1, n) printf("%d ", a[i]);
puts("");
}
int main() {
// freopen("D.in", "r", stdin);
// freopen("D.out", "w", stdout);
scanf("%s", qwq + 1);
T = read();
fac[0] = 1;
FOR(i, 1, 9) fac[i] = fac[i - 1] * i;
if (qwq[1] == 't') {
FOR(i, 1, T) transqwq();
} else {
FOR(i, 1, T) recoverqwq();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3832kb
input:
transmit 2 20 97 388 459 467 32 99 98 296 403 325 330 271 87 333 378 267 405 58 426 374 20 125 481 451 150 495 136 444 192 118 26 68 281 120 61 494 339 86 292 100 32
output:
99 98 87 97 32 58 467 374 333 325 330 271 296 459 426 405 388 403 267 378 86 32 68 100 61 26 495 192 125 150 281 136 120 494 451 292 444 481 339 118
input:
recover 2 19 99 98 87 97 32 58 467 374 333 325 330 271 296 459 426 405 388 403 267 19 86 32 68 100 26 495 192 125 150 281 136 120 494 451 292 444 481 339 118
output:
32 58 87 97 98 99 267 271 296 325 330 333 374 378 388 403 405 426 459 467 26 32 61 68 86 100 118 120 125 136 150 192 281 292 339 444 451 481 494 495
result:
ok all correct (2 test cases)
Test #2:
score: 0
Programme Dangerous Syscalls
input:
transmit 1 20 158 220 174 224 137 134 339 175 147 122 480 26 151 266 474 144 451 301 105 188