QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22378#2351. Lost in Transferli0201#0 0ms0kbC++202.3kb2022-03-09 16:42:582023-01-17 09:34:13

Judging History

This is the latest submission verdict.

  • [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:13]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2022-03-09 16:42:58]
  • Submitted

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]];
    FOR(i, 1, 6) d[7 + i] = a[7 + b[i]];
    FOR(i, 13, 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: 0
Wrong Answer

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 0 296 271 330 325 333 374 378 403 388 426 405 459 467 
26 61 100 68 32 86 0 120 136 281 150 125 281 292 339 451 495 481 444 494 

input:


output:


result:

wrong answer The sequence your program outputs on the first run is invalid. (test case 1)