QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#553332 | #7565. Harumachi Kaze | ucup-team1231# | WA | 4ms | 39612kb | C++14 | 3.0kb | 2024-09-08 11:56:48 | 2024-09-08 11:56:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int SZ = 1 << 17;
ULL addq(ULL u, ULL v) {
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 == 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 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];
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];
B[i].init(tmp);
}
vector<ULL> ans;
for(int i = 0; i < q; i++) {
int tp;
scanf("%d", &tp);
if(tp == 1) {
int t, pos; ULL x;
scanf("%d%d%llu", &t, &pos, &x);
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;
scanf("%d", &t);
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 39612kb
input:
2 3 2 288230376151711744 864691128455135232 1441151880758558720 2017612633061982208 2 3 1 2 2 2594073385365405696 2 3 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 1152921504606846976 3458764513820540928 34...
output:
A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744 864691128455135232 A 288230376151711744...
result:
wrong answer 1st lines differ - expected: '2', found: ''