QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#69860#5113. Bridgemagicduck#WA 44ms5368kbC++141.7kb2023-01-02 16:53:402023-01-02 16:53:41

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-02 16:53:41]
  • Judged
  • Verdict: WA
  • Time: 44ms
  • Memory: 5368kb
  • [2023-01-02 16:53:40]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &F) {
    int R = 1; F = 0; char CH = getchar();
    for(; !isdigit(CH); CH = getchar()) if(CH == '-') R = -1;
    for(; isdigit(CH); CH = getchar()) F = F * 10 + CH - 48;
    F *= R;
}
inline void file(string str) {
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}
const int N = 1e5 + 10, B = 400;
int n, m, q, op[N], g[N], id[N], tot, flag[N], p[B][N], tmp[N], M; pair<int, int> c[N];
void rebuild(int x) {
    const int l = (x - 1) * B + 1, r = x * B;
    for(int i = 1; i <= n; i++) tmp[i] = i;
    for(int i = l; i <= r; i++)
        if(flag[i]) swap(tmp[g[c[i].second]], tmp[g[c[i].second] + 1]);
    for(int i = 1; i <= n; i++) p[x][tmp[i]] = i;
}
void ins(int x) {
    flag[x] = 1;
    const int y = (x - 1) / B + 1;
    rebuild(y);
}
int qry(int x) {
    for(int i = 1; i <= M; i++) x = p[i][x];
    return x;
}
int main() {
    //file("");
    read(n), read(m), read(q); 
    for(int i = 1; i <= q; i++) {
        read(op[i]);
        if(op[i] == 1) {
            int a, b; read(a), read(b);
            c[++tot] = make_pair(b, i);
            g[i] = a;
        }
        else read(g[i]);
    }
    sort(c + 1, c + tot + 1);
    for(int i = 1; i <= tot; i++) id[c[i].second] = i;
    M = (n - 1) / B + 1;
    for(int i = 1; i <= M; i++)
        for(int j = 1; j <= n; j++) p[i][j] = j;
    for(int i = 1; i <= q; i++) {
        if(op[i] == 1) ins(id[i]);
        else cout << qry(g[i]) << '\n';
    }
    #ifdef _MagicDuck
        fprintf(stderr, "# Time: %.3lf s", (double)clock() / CLOCKS_PER_SEC);
    #endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 4 13
2 2
1 1 3
2 1
2 2
2 3
1 2 4
2 1
2 2
2 3
1 2 1
2 1
2 2
2 3

output:

2
2
1
3
3
1
2
3
2
1

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 44ms
memory: 5368kb

input:

3 100000 99997
2 2
2 2
2 3
2 3
2 3
2 3
2 3
1 2 11047
1 1 98732
1 2 90045
1 1 43556
2 1
2 3
1 2 17242
1 1 17027
2 1
1 1 94195
2 1
2 2
2 1
2 3
1 1 34124
1 2 14354
1 2 673
1 2 39812
1 2 35520
1 2 16046
2 3
2 2
1 1 25410
2 3
2 1
2 3
2 2
1 2 55684
2 1
1 2 24811
1 2 92268
1 2 60268
2 2
1 1 89272
1 2 19232...

output:

2
2
3
3
3
3
3
1
3
1
1
2
1
3
2
3
2
1
2
3
1
3
3
1
3
2
3
3
1
2
2
3
2
2
3
1
2
3
1
2
3
1
1
3
3
1
2
2
3
2
1
2
3
3
2
2
3
1
3
1
3
2
3
2
3
3
3
3
1
2
1
2
3
1
3
3
3
1
1
1
3
2
1
2
2
3
3
3
2
2
1
3
3
2
3
3
1
1
3
2
3
2
3
1
1
2
1
3
1
1
3
1
1
3
3
2
1
2
1
2
2
1
1
3
1
1
3
3
1
2
3
3
3
1
2
2
2
2
1
2
2
1
2
1
2
1
2
1
2
1
...

result:

wrong answer 8th numbers differ - expected: '3', found: '1'