QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#437680#7565. Harumachi KazepandapythonerWA 0ms3644kbC++203.3kb2024-06-09 15:14:252024-06-09 15:14:25

Judging History

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

  • [2024-06-09 15:14:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-06-09 15:14:25]
  • 提交

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;
};


int query_count = 0;


biba operator+(const biba& a, const biba& b) {
    if (a.bad) {
        return a;
    }
    if (b.bad) {
        return b;
    }
    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 (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;
}


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;
ll B;

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


biba get_kth(int k) {
    assert(1 <= k and k <= 2 * n);
    int i = 0;
    int j = 0;
    biba last;
    biba sa = a[i], sb = a[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;
}


void solve() {
    rs.clear();
    for (auto d : f) {
        if (d.type == 1) {
            if (d.t == 1) {
                a[d.pos] = d.x;
            } else {
                b[d.pos] = d.x;
            }
        } else {
            auto val = get_kth(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.resize(n + 1);
    b.resize(n + 1);
    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

*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3644kb

input:

2 3 2
288230376151711744 864691128455135232
1441151880758558720 2017612633061982208
2 3
1 2 2 2594073385365405696
2 3
288230376151711744
1152921504606846976
288230376151711744
2305843009213693952
1152921504606846976
288230376151711744
1152921504606846976
288230376151711744
2882303761517117440
115292...

output:

C 288230376151711744 288230376151711744
A 288230376151711744 864691128455135232
C 1152921504606846976 288230376151711744
A 288230376151711744 2017612633061982208
C 1152921504606846976 2305843009213693952
C 288230376151711744 288230376151711744
A 288230376151711744 864691128455135232
C 11529215046068...

result:

wrong answer 2nd lines differ - expected: '1441151880758558720 1441151880758558720', found: '1152921504606846976 1152921504606846976'