QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553359 | #7565. Harumachi Kaze | ucup-team1231# | WA | 8ms | 40684kb | C++14 | 3.3kb | 2024-09-08 12:17:25 | 2024-09-08 12:17:28 |
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(min(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]);
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++) {
scanf("%d", &tp[i]);
if(tp[i] == 1) scanf("%d%d%d", &qt[i], &qpos[i], &qx[i]);
else scanf("%d", &qt[i]);
}
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;
}
}
}
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: 0
Wrong Answer
time: 8ms
memory: 40684kb
input:
2 3 2 288230376151711744 864691128455135232 1441151880758558720 2017612633061982208 2 3 1 2 2 2594073385365405696 2 3 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976
output:
A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 3 0 234794728027282004 0
result:
wrong answer 1st lines differ - expected: '2', found: ''