QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#437688#7565. Harumachi KazepandapythonerRE 1ms3724kbC++204.6kb2024-06-09 15:27:222024-06-09 15:27:22

Judging History

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

  • [2024-06-09 15:27:22]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3724kb
  • [2024-06-09 15:27:22]
  • 提交

answer

#include <bits/stdc++.h>


#define ull unsigned long long
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()


using namespace std;

const ll inf = 1e18;
mt19937 rnd(234);


#ifdef LOCAL
bool local = true;
#else
bool local = false;
#endif

struct biba {
    ull x = 0;
    bool bad = true;

    biba() {}
    biba(ull x) : x(x), bad(false) {}
    biba(ull x, bool bad) : x(x), bad(bad) {}
};


int query_count = 0;


biba operator+(const biba& a, const biba& b) {
    if (a.bad) {
        return a;
    }
    if (b.bad) {
        return b;
    }
    if (a.x == 0) {
        return b;
    }
    if (b.x == 0) {
        return a;
    }
    if (local) {
        return biba{ a.x + b.x, false };
    }
    if (query_count >= 1.5e6) {
        assert(0);
    }
    query_count += 1;
    cout << "A " << a.x << " " << b.x << endl;
    ull x;
    cin >> x;
    return biba{ x, false };
}


biba min(const biba& a, const biba& b) {
    if (a.bad) {
        return b;
    }
    if (b.bad) {
        return a;
    }
    if (a.x == 0) {
        return a;
    }
    if (b.x == 0) {
        return b;
    }
    if (local) {
        return biba{ min(a.x, b.x), false };
    }
    if (query_count >= 1.5e6) {
        assert(0);
    }
    query_count += 1;
    cout << "C " << a.x << " " << b.x << endl;
    ull x;
    cin >> x;
    return biba{ x, false };
}


bool operator==(const biba& a, const biba& b) {
    return a.x == b.x and a.bad == b.bad;
}


bool operator<=(const biba& a, const biba& b) {
    return min(a, b) == a;
}


biba max(const biba& a, const biba& b) {
    if (a <= b) {
        return b;
    } else {
        return a;
    }
}


istream& operator>>(istream& in, biba& a) {
    ull x;
    in >> x;
    a = biba{ x, false };
    return in;
}


ostream& operator<<(ostream& out, const biba& a) {
    return (out << a.x);
}


struct query {
    int type;
    int t, pos;
    biba x;
    int k;
};


istream& operator>>(istream& in, query& a) {
    in >> a.type;
    if (a.type == 1) {
        in >> a.t >> a.pos >> a.x;
        a.pos -= 1;
        assert(a.t == 1 or a.t == 2);
    } else if (a.type == 2) {
        in >> a.k;
    } else {
        assert(0);
    }
    return in;
}

int n, q;
int m;
ll B;

vector<biba> a, b;
vector<biba> ta, tb;
vector<query> f;
vector<biba> rs;


biba get_kth_old(int k) {
    assert(1 <= k and k <= 2 * n);
    int i = 0;
    int j = 0;
    biba last;
    biba sa = a[i], sb = b[j];
    while (k > 0) {
        k -= 1;
        if (sa <= sb) {
            last = sa;
            i += 1;
            sa = sa + a[i];
        } else {
            last = sb;
            j += 1;
            sb = sb + b[j];
        }
    }
    return last;
}


biba get_kth(int k) {
    assert(1 <= k and k <= 2 * n);
    return biba();
}


void solve() {
    m = 1;
    while (m < n) {
        m *= 2;
    }
    ta.assign(2 * m, biba());
    tb.assign(2 * m, biba());
    for (int i = 0; i < n; i += 1) {
        ta[m + i] = a[i];
        tb[m + i] = b[i];
    }
    for (int i = m - 1; i >= 1; i -= 1) {
        ta[i] = ta[i + i] + ta[i + i + 1];
        tb[i] = tb[i + i] + tb[i + i + 1];
    }
    rs.clear();
    for (auto d : f) {
        if (d.type == 1) {
            if (d.t == 1) {
                a[d.pos] = d.x;
                int v = m + d.pos;
                ta[v] = d.x;
                for (v /= 2; v >= 1; v /= 2) {
                    ta[v] = ta[v + v] + ta[v + v + 1];
                }
            } else {
                b[d.pos] = d.x;
                int v = m + d.pos;
                tb[v] = d.x;
                for (v /= 2; v >= 1; v /= 2) {
                    tb[v] = tb[v + v] + tb[v + v + 1];
                }
            }
        } else {
            auto val = get_kth_old(d.k);
            rs.push_back(val);
        }
    }
}


int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    cin >> n >> q >> B;
    a.assign(n + 1, biba());
    b.assign(n + 1, biba());
    for (int i = 0; i < n; i += 1) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i += 1) {
        cin >> b[i];
    }
    f.resize(q);
    for (int i = 0; i < q; i += 1) {
        cin >> f[i];
    }
    solve();
    cout << "! " << (int)rs.size() << endl;
    for (auto x : rs) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


/*
2 3 2
1 3
5 7
2 3
1 2 2 9
2 3

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3724kb

input:

2 3 2
288230376151711744 864691128455135232
1441151880758558720 2017612633061982208
2 3
1 2 2 2594073385365405696
2 3
1152921504606846976
3458764513820540928
288230376151711744
1152921504606846976
1152921504606846976
3458764513820540928
4035225266123964416
288230376151711744
1152921504606846976
1152...

output:

A 288230376151711744 864691128455135232
A 1441151880758558720 2017612633061982208
C 288230376151711744 1441151880758558720
A 288230376151711744 864691128455135232
C 1152921504606846976 1441151880758558720
A 1441151880758558720 2017612633061982208
A 1441151880758558720 2594073385365405696
C 288230376...

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

3 5 3
2017612633061982208 864691128455135232 2305843009213693952
1441151880758558720 2017612633061982208 288230376151711744
2 5
2 2
1 1 3 1729382256910270464
1 2 1 2017612633061982208
2 5
2882303761517117440
3458764513820540928
1441151880758558720
3458764513820540928
2017612633061982208
288230376151...

output:

A 2017612633061982208 864691128455135232
A 1441151880758558720 2017612633061982208
C 2017612633061982208 1441151880758558720
A 1441151880758558720 2017612633061982208
C 2017612633061982208 3458764513820540928
A 2017612633061982208 864691128455135232
C 2882303761517117440 3458764513820540928
A 288230...

result:

ok 2 lines

Test #3:

score: -100
Runtime Error

input:

16000 20000 14
12381691541923575949 2314459967875656919 15240288079556723088 320873566057825844 1013209648229540810 17538037439317817183 11476444495745028170 14967174865083701448 17232652930598276562 7175999203534983334 4597650078600036201 13978217693115848142 17682091621678261784 488328147143975490...

output:

A 11048728814583818664 15677818123922243563
A 2565851401584575835 6437826446793249029
A 6866204288908749798 7524845485598995388
A 7541202894948887905 17999698327915010774
A 1068718252472774662 11980183590060892778
A 8586449783218478804 14434754479864353936
A 16451093994246303075 1651242460292755263
...

result: