QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#437682 | #7565. Harumachi Kaze | pandapythoner | RE | 1ms | 3728kb | C++20 | 3.3kb | 2024-06-09 15:16:23 | 2024-06-09 15:16:23 |
Judging History
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 = 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;
}
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3728kb
input:
2 3 2 288230376151711744 864691128455135232 1441151880758558720 2017612633061982208 2 3 1 2 2 2594073385365405696 2 3 288230376151711744 1152921504606846976 1152921504606846976 3458764513820540928 288230376151711744 1152921504606846976 1152921504606846976 4035225266123964416
output:
C 288230376151711744 1441151880758558720 A 288230376151711744 864691128455135232 C 1152921504606846976 1441151880758558720 A 1441151880758558720 2017612633061982208 C 288230376151711744 1441151880758558720 A 288230376151711744 864691128455135232 C 1152921504606846976 1441151880758558720 A 1441151880...
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
3 5 3 2017612633061982208 864691128455135232 2305843009213693952 1441151880758558720 2017612633061982208 288230376151711744 2 5 2 2 1 1 3 1729382256910270464 1 2 1 2017612633061982208 2 5 1441151880758558720 3458764513820540928 2017612633061982208 2882303761517117440 2882303761517117440 518814677073...
output:
C 2017612633061982208 1441151880758558720 A 1441151880758558720 2017612633061982208 C 2017612633061982208 3458764513820540928 A 2017612633061982208 864691128455135232 C 2882303761517117440 3458764513820540928 A 2882303761517117440 2305843009213693952 C 5188146770730811392 3458764513820540928 A 34587...
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:
C 12381691541923575949 9713655525013844501 A 12381691541923575949 2314459967875656919 C 14696151509799232868 9713655525013844501 A 9713655525013844501 1393448338525660988 C 14696151509799232868 11107103863539505489 A 14696151509799232868 15240288079556723088 C 12486187300948059893 111071038635395054...