QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553379 | #7565. Harumachi Kaze | ucup-team1231 | WA | 4ms | 42072kb | C++14 | 3.4kb | 2024-09-08 12:32:01 | 2024-09-08 12:32:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int SZ = 1 << 17;
const ULL BAD = 234794728027282004ULL;
ULL addq(ULL u, ULL v) {
if(u == BAD || v == BAD) return BAD;
if(u == 0 || v == 0) return u + v;
printf("A %llu %llu\n", u, v); fflush(stdout);
ULL ret;
scanf("%llu", &ret);
return ret;
}
ULL minq(ULL u, ULL v) {
if(u == BAD || v == BAD) return u ^ v ^ BAD;
if(u == 0 || v == 0) return 0;
printf("C %llu %llu\n", u, v); fflush(stdout);
ULL ret;
scanf("%llu", &ret);
return ret;
}
int SA[8], SB[8];
struct segt {
ULL sum[SZ * 2 + 5];
void init(ULL arr[]) {
for(int i = 0; i < SZ; i++)
sum[i | SZ] = arr[i];
for(int i = SZ - 1; i >= 1; i--)
sum[i] = addq(sum[i << 1], sum[i << 1 | 1]);
}
void upd(int p, ULL x) {
sum[p |= SZ] = x;
for(p >>= 1; p >= 1; p >>= 1)
sum[p] = addq(sum[p << 1], sum[p << 1 | 1]);
}
}A[8], B[8];
int n, q, l;
ULL query(int ap, int bp) {
int v = 1;
ULL sl = 0, sr = 0;
while(v < SZ) {
ULL nl = addq(sl, A[ap].sum[v << 1]),
nr = addq(sr, B[bp].sum[v << 1 | 1]);
if(minq(nl, nr) == nl) {
sl = nl; v = v << 1 | 1;
} else {
sr = nr; v = v << 1;
}
}
return minq(sl, sr) == sl ? sr : sl;
}
ULL a[SZ], b[SZ], tmp[SZ];
int tp[SZ], qt[SZ], qpos[SZ];
ULL qx[SZ];
int main() {
scanf("%d%d%d", &n, &q, &l);
for(int i = 1; i <= n; i++) scanf("%llu", &a[i]);
for(int i = 1; i <= n; i++) scanf("%llu", &b[i]);
for(int i = 0; i < q; i++) {
scanf("%d", &tp[i]);
if(tp[i] == 1) scanf("%d%d%d", &qt[i], &qpos[i], &qx[i]);
else scanf("%d", &qt[i]);
}
vector<int> vec;
for(int i = 0; i * 2 < l; i++)
vec.push_back(1 << i | 1 << (l - 1 - i));
while(vec.size() < 6) vec.push_back(0);
vec.resize(6);
for(int i = 0; i < 8; i++) for(int j = 0; j < 3; j++)
if(i >> j & 1) SA[i] += vec[j];
for(int i = 0; i < 8; i++) for(int j = 0; j < 3; j++)
if(i >> j & 1) SB[i] += vec[j + 3];
for(int i = 0; i < 8; i++) {
memset(tmp, 0, sizeof(tmp));
for(int j = 1; j <= n; j++) tmp[j - SA[i] + 65535] = a[j];
tmp[n + 1 - SA[i] + 65535] = BAD;
A[i].init(tmp);
}
for(int i = 0; i < 8; i++) {
memset(tmp, 0, sizeof(tmp));
for(int j = 1; j <= n; j++) tmp[65537 + SB[i] - j] = b[j];
tmp[65537 + SB[i] - n - 1] = BAD;
B[i].init(tmp);
}
vector<ULL> ans;
for(int i = 0; i < q; i++) {
if(tp[i] == 1) {
int t = qt[i], pos = qpos[i]; ULL x = qx[i];
if(t == 1) for(int j = 0; j < 8; j++)
A[j].upd(pos - SA[j] + 65535, x);
else for(int j = 0; j < 8; j++)
B[j].upd(65537 + SB[j] - pos, x);
} else {
int t = qt[i];
bool ok = false;
for(int j = 0; j < 8; j++) for(int k = 0; k < 8; k++)
if(SA[j] + SB[k] == t && !ok) {
ans.push_back(query(j, k));
ok = true;
}
assert(ok);
}
}
printf("! %d\n", (int)ans.size());
for(auto i : ans) printf("%llu ", i);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 42072kb
input:
2 3 2 288230376151711744 864691128455135232 1441151880758558720 2017612633061982208 2 3 1 2 2 2594073385365405696 2 3 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 3458764513820540928 1152921504606846976 1152921504606846976 1152921504606846976 11...
output:
A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 1441151880758558720 2017612633061982208 C 1152921504606846976 3458764513820540928 C 11529215046068...
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 41508kb
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 3170534137668829184 2882303761517117440 3170534137668829184 5188146770730811392 288230376151...
output:
A 2017612633061982208 864691128455135232 A 864691128455135232 2305843009213693952 A 2017612633061982208 864691128455135232 A 864691128455135232 2305843009213693952 A 2017612633061982208 3170534137668829184 A 2017612633061982208 864691128455135232 A 864691128455135232 2305843009213693952 A 2017612633...
result:
wrong answer 2nd lines differ - expected: '3746994889972252672 2017612633061982208 4323455642275676160', found: '3746994889972252672 2017612633061982208 2882303761517117440'