QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421219#1228. I 君的探险james1BadCreeper100 ✓471ms51944kbC++142.5kb2024-05-25 15:32:512024-05-25 15:32:51

Judging History

This is the latest submission verdict.

  • [2024-05-25 15:32:51]
  • Judged
  • Verdict: 100
  • Time: 471ms
  • Memory: 51944kb
  • [2024-05-25 15:32:51]
  • Submitted

answer

#include "explore.h"
#include <bits/stdc++.h>
using namespace std; 
const int N = 2e5 + 5; 

mt19937 Rand(time(0)); 
int id[N], die[N], t, a[N], m, T1[N], T2[N], Q[N], idx[N], st[N]; 
vector<int> G[N]; 
vector<int> cklis; 

inline int Query(int x) {
    int u = query(x - 1); 
    for (int i : G[x]) u ^= st[i]; 
    return u; 
}
void solve(int l, int r, int ql, int qr) { // 求解 [ql, qr] 的点连向哪些边:[l, r]
    if (ql > qr) return; 
    // cerr << l << " " << r << " " << ql << " " << qr << " ET::TGERTY\n"; 
    // for (int i = l; i <= r; ++i)
        // cerr << a[i] << " \n"[i == r]; 
    // for (int i = ql; i <= qr; ++i)
        // cerr << Q[i] << " \n"[i == qr]; 
    if (l == r) {
        for (int i = ql; i <= qr; ++i) if (a[l] != Q[i]) {
            // if (st.find({a[l], Q[i]}) == st.end()) 
            report(a[l] - 1, Q[i] - 1); cklis.push_back(a[l]); cklis.push_back(Q[i]); 
            // cerr << a[l] << " " << Q[i] << " FOUND\n"; 
            G[a[l]].emplace_back(Q[i]); 
            G[Q[i]].emplace_back(a[l]); 
            --m; 
        }
        return; 
    }
    int mid = l + r >> 1; 
    for (int i = l; i <= mid; ++i) modify(a[i] - 1), st[a[i]] = 1; 
    int p = 0, q = 0; 
    for (int i = ql; i <= qr; ++i) {
        // int u = Query(Q[i]); 
        if (idx[Q[i]] <= mid || Query(Q[i])) T1[++p] = Q[i]; 
        else T2[++q] = Q[i]; 
    }
    int ba = ql - 1; 
    for (int i = 1; i <= p; ++i) Q[++ba] = T1[i]; 
    for (int i = 1; i <= q; ++i) Q[++ba] = T2[i]; 
    for (int i = l; i <= mid; ++i) modify(a[i] - 1), st[a[i]] = 0; 
    solve(l, mid, ql, ql + p - 1); 
    solve(mid + 1, r, ql + p, qr); 
}

void explore(int n, int M) {
    if (M == 10 * n) {
        for (int i = 0; i < n - 1; ++i) {
            modify(i); st[i] ^= 1; 
            for (int j = i + 1; j < n; ++j)
                if (query(j) != st[j]) st[j] ^= 1, report(i, j); 
        }
        return; 
    }
    // cerr << n << " " << M << "\n"; 
    for (int i = 1; i <= n; ++i) id[i] = i; 
    m = M; 
    while (m) {
        // cerr << m << endl; 
        
        t = 0; 
        for (int i = 1; i <= n; ++i)
            if (!die[id[i]]) a[++t] = id[i], Q[t] = a[t], idx[a[t]] = t; 
        
        int be = m; 
        solve(1, t, 1, t); 
        
        if (m != 0) {
            for (int x : cklis)
                if (check(x - 1)) die[x] = 1; 
            cklis.clear(); 
        }

        shuffle(id + 1, id + n + 1, Rand); 
        // cerr << "--------------------\n"; 
    }
}

详细

Test #1:

score: 4
Accepted
time: 0ms
memory: 30488kb

Test #2:

score: 4
Accepted
time: 3ms
memory: 26496kb

Test #3:

score: 4
Accepted
time: 7ms
memory: 26484kb

Test #4:

score: 4
Accepted
time: 3ms
memory: 26464kb

Test #5:

score: 4
Accepted
time: 0ms
memory: 26208kb

Test #6:

score: 4
Accepted
time: 19ms
memory: 32500kb

Test #7:

score: 4
Accepted
time: 30ms
memory: 43232kb

Test #8:

score: 4
Accepted
time: 88ms
memory: 37784kb

Test #9:

score: 4
Accepted
time: 76ms
memory: 40880kb

Test #10:

score: 4
Accepted
time: 54ms
memory: 36148kb

Test #11:

score: 4
Accepted
time: 115ms
memory: 50232kb

Test #12:

score: 4
Accepted
time: 92ms
memory: 36196kb

Test #13:

score: 4
Accepted
time: 236ms
memory: 41900kb

Test #14:

score: 4
Accepted
time: 238ms
memory: 49296kb

Test #15:

score: 4
Accepted
time: 116ms
memory: 34952kb

Test #16:

score: 4
Accepted
time: 113ms
memory: 35088kb

Test #17:

score: 4
Accepted
time: 234ms
memory: 46048kb

Test #18:

score: 4
Accepted
time: 0ms
memory: 30608kb

Test #19:

score: 4
Accepted
time: 3ms
memory: 32188kb

Test #20:

score: 4
Accepted
time: 4ms
memory: 27100kb

Test #21:

score: 4
Accepted
time: 122ms
memory: 36712kb

Test #22:

score: 4
Accepted
time: 298ms
memory: 40368kb

Test #23:

score: 4
Accepted
time: 258ms
memory: 47912kb

Test #24:

score: 4
Accepted
time: 334ms
memory: 46864kb

Test #25:

score: 4
Accepted
time: 471ms
memory: 51944kb