QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22387 | #2351. Lost in Transfer | li0201# | 0 | 0ms | 3580kb | C++20 | 2.8kb | 2022-03-09 16:58:24 | 2023-01-17 09:34:56 |
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, i + 1, 6) {
if (b[j] > b[i]) ++s;
}
w += s * fac[6 - i];
}
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();
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);
sort(a + 1, a + 7), reverse(a + 1, a + 7);
sort(a + 8, a + 14), reverse(a + 8, a + 14);
sort(a + n - 5, a + n + 1), reverse(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];
FOR(i, 1, n) printf("%d ", a[i]);
int x = getw(1, 6), y = getw(8, 13), z = getw(n - 5, n);
if (x == y && y == z && z == s) {
puts("");
return;
}
int res = 0;
if (x > 500 || y > 500) {
res = s ^ z;
} else if (x == y || x == z) {
res = s ^ x;
} else {
res = s ^ z;
}
printf("%d\n", res);
}
int main() {
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: 0ms
memory: 3580kb
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:
333 388 98 99 97 32 467 330 403 296 325 271 87 459 405 426 374 378 267 58 481 444 125 150 451 136 495 281 120 26 118 192 68 494 339 100 32 86 292 61
input:
recover 2 19 333 388 98 99 97 32 467 330 403 296 325 271 87 459 405 426 374 378 267 19 481 444 125 150 136 495 281 120 26 118 192 68 494 339 100 32 86 292 61
output:
333 388 98 99 97 32 467 330 403 296 325 271 87 459 405 426 374 378 267 58 481 444 125 150 136 495 281 120 26 118 192 68 494 339 100 32 86 292 61 451
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