QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22379#2351. Lost in Transferli0201#0 2ms3572kbC++202.4kb2022-03-09 16:44:412023-01-17 09:34:17

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-17 09:34:17]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3572kb
  • [2022-03-09 16:44:41]
  • 提交

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();
    sort(a + 1, a + n + 1);
    int x = 0;
    FOR(i, 1, n) x ^= a[i];
    deqwq(x);
    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 == 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3572kb

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:

58 32 97 87 98 99 267 296 271 330 325 333 374 378 403 388 426 405 459 467 
26 61 100 68 32 86 118 120 136 281 150 125 192 292 339 451 495 481 444 494 

input:

recover
2
19 58 32 97 87 98 99 267 296 271 330 325 333 374 378 403 388 426 405 459 
19 26 61 100 68 86 118 120 136 281 150 125 192 292 339 451 495 481 444 494 

output:

58 32 97 87 98 99 267 296 271 330 325 333 374 378 403 388 426 405 459 467
26 61 100 68 86 118 120 136 281 150 125 192 292 339 451 495 481 444 494 32

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

output:


input:


output:


result: