QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#547034 | #7565. Harumachi Kaze | A_programmer | AC ✓ | 2549ms | 37552kb | C++14 | 3.6kb | 2024-09-04 17:13:10 | 2024-09-04 17:13:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int maxn = 2e4 + 5;
const int N = 32768;
int X[8], Y[8], n;
ull a[N], b[N], c[N];
ull add(ull x, ull y)
{
if (!x || !y) return x ^ y;
cout << "A " << x << " " << y << "\n"; cout.flush();
ull t; cin >> t; return t;
}
bool cmp(ull x, ull y)
{
cout << "C " << x << " " << y << "\n"; cout.flush();
ull t; cin >> t; return (t == x);
}
#define ls k << 1
#define rs k << 1 | 1
struct segtree
{
int l[N << 2], r[N << 2]; ull t[N << 2];
void build(int k, int L, int R)
{
l[k] = L, r[k] = R;
if (L == R) return t[k] = c[L], void();
int mid = (L + R) >> 1;
build(ls, L, mid); build(rs, mid + 1, R);
t[k] = add(t[ls], t[rs]);
}
void change(int k, int x, ull d)
{
if (l[k] == r[k]) return t[k] = d, void();
int mid = (l[k] + r[k]) >> 1;
if (x <= mid) change(ls, x, d); else change(rs, x, d);
t[k] = add(t[ls], t[rs]);
}
}T1[8], T2[8];
ull res;
vector<ull> ans;
void Solve(int k1, int k2, int p1, int p2, ull val1, ull val2)
{
if (T1[p1].l[k1] == T1[p1].r[k1]) return res = cmp(val1, val2) ? val2 : val1, void();
ull nw1 = add(val1, T1[p1].t[k1 << 1]), nw2 = add(val2, T2[p2].t[k2 << 1]);
if (T1[p1].r[k1 << 1] <= X[p1] + n && (T2[p2].r[k2 << 1] > Y[p2] + n || cmp(nw1, nw2))) Solve(k1 << 1 | 1, k2 << 1, p1, p2, nw1, val2);
else Solve(k1 << 1, k2 << 1 | 1, p1, p2, val1, nw2);
}
int rev[N];
int op[maxn], typ[maxn], k[maxn];
ull vl[maxn];
int main()
{
int q, B;
cin >> n >> q >> B;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
for (int i = 1; i <= q; i++)
{
cin >> op[i];
if (op[i] == 1) cin >> typ[i] >> k[i] >> vl[i];
else cin >> k[i];
}
for (int i = 1; i < N; i++) rev[i] = rev[i >> 1] >> 1 | ((i & 1) << (B - 1));
if (B <= 6)
{
int cnt = 0;
for (int i = 0; i < (1 << B); i++)
if (i == rev[i]) X[cnt++] = (1 << B) - 1 - i;
}
else if (B <= 12)
{
int cnt = 0;
for (int i = 0; i < 8; i++) X[i] = (i ^ 7) + rev[i ^ 7];
for (int i = 0; i < (1 << (B - 3)); i += 8)
if (i == rev[i]) Y[cnt++] = (1 << (B - 3)) - 8 - i;
}
else
{
for (int i = 0; i < 8; i++) X[i] = (i ^ 7) + rev[i ^ 7];
for (int i = 0; i < 8; i++) Y[i] = ((i ^ 7) << 3) + rev[(i ^ 7) << 3] + (1 << (B - 6)) - (1 << 6);
}
for (int i = 0; i < 8; i++)
if (X[i] + N - (1 << B) >= 0) X[i] += N - (1 << B);
for (int i = 0; i < 8; i++)
{
for (int j = 1; j <= X[i]; j++) c[j] = 0;
for (int j = X[i] + 1; j <= min(N, X[i] + n); j++) c[j] = a[j - X[i]];
for (int j = X[i] + n + 1; j <= N; j++) c[j] = 0;
T1[i].build(1, 1, N);
for (int j = 1; j <= Y[i]; j++) c[j] = 0;
for (int j = Y[i] + 1; j <= min(N, Y[i] + n); j++) c[j] = b[j - Y[i]];
for (int j = Y[i] + n + 1; j <= N; j++) c[j] = 0;
T2[i].build(1, 1, N);
}
for (int i = 1; i <= q; i++)
if (op[i] == 1)
{
if (typ[i] == 1)
{
for (int j = 0; j < 8; j++)
if (X[j] + k[i] <= N) T1[j].change(1, X[j] + k[i], vl[i]);
}
else
{
for (int j = 0; j < 8; j++)
if (Y[j] + k[i] <= N) T2[j].change(1, Y[j] + k[i], vl[i]);
}
}
else
{
bool Fl = 0;
for (int p = 0; p < 8 && !Fl; p++)
for (int q = 0; q < 8 && !Fl; q++)
if (X[p] + Y[q] + k[i] == N - 1)
Fl = 1, Solve(1, 1, p, q, 0, 0), ans.emplace_back(res);
}
cout << "! " << ans.size() << "\n";
for (ull val : ans) cout << val << " ";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 36668kb
input:
2 3 2 288230376151711744 864691128455135232 1441151880758558720 2017612633061982208 2 3 1 2 2 2594073385365405696 2 3 3458764513820540928 1152921504606846976 3458764513820540928 1152921504606846976 3458764513820540928 1152921504606846976 3458764513820540928 1152921504606846976 3458764513820540928 11...
output:
A 1441151880758558720 2017612633061982208 A 288230376151711744 864691128455135232 A 1441151880758558720 2017612633061982208 A 288230376151711744 864691128455135232 A 1441151880758558720 2017612633061982208 A 288230376151711744 864691128455135232 A 1441151880758558720 2017612633061982208 A 2882303761...
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 9ms
memory: 36796kb
input:
3 5 3 2017612633061982208 864691128455135232 2305843009213693952 1441151880758558720 2017612633061982208 288230376151711744 2 5 2 2 1 1 3 1729382256910270464 1 2 1 2017612633061982208 2 5 3458764513820540928 3746994889972252672 3170534137668829184 5188146770730811392 3458764513820540928 374699488997...
output:
A 1441151880758558720 2017612633061982208 A 3458764513820540928 288230376151711744 A 864691128455135232 2305843009213693952 A 2017612633061982208 3170534137668829184 A 1441151880758558720 2017612633061982208 A 3458764513820540928 288230376151711744 A 2017612633061982208 864691128455135232 A 28823037...
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 2224ms
memory: 36544kb
input:
16000 20000 14 12381691541923575949 2314459967875656919 15240288079556723088 320873566057825844 1013209648229540810 17538037439317817183 11476444495745028170 14967174865083701448 17232652930598276562 7175999203534983334 4597650078600036201 13978217693115848142 17682091621678261784 488328147143975490...
output:
A 2314459967875656919 15240288079556723088 A 320873566057825844 1013209648229540810 A 104495759024483944 1334083214287366654 A 17538037439317817183 11476444495745028170 A 14967174865083701448 17232652930598276562 A 11564229646654949290 14749575507274081947 A 1438578973311850598 7867061080219479621 A...
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 2186ms
memory: 37044kb
input:
16000 20000 14 14874916021093924522 12369740409537030379 6287256359015658845 823444916947643237 4526221239260804705 11449122367236060745 5269387146536217002 12271448617436014402 2707995377102611522 953402166614134577 8882130735136249391 5659092195367212151 12689325453646244318 14372002311792512418 7...
output:
A 12369740409537030379 6287256359015658845 A 823444916947643237 4526221239260804705 A 210252694843137608 5349666156208447942 A 11449122367236060745 5269387146536217002 A 12271448617436014402 2707995377102611522 A 17715001299073933300 15975935779840281477 A 6556410636353241103 15244193005204663161 A ...
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 2197ms
memory: 37136kb
input:
16000 20000 14 12315377266285165767 11473010392351879640 7998004721169407057 9573065544888591349 8327463206443780344 16951550409690804427 9014132268830135915 1328673092737196637 5921820488166554289 3905417438586104204 16182336802010099310 4414669279483371512 13388655175283310101 4417487293134062765 ...
output:
A 11473010392351879640 7998004721169407057 A 9573065544888591349 8327463206443780344 A 1024271039811735081 450276462924475630 A 16951550409690804427 9014132268830135915 A 1328673092737196637 5921820488166554289 A 7518938604811388726 8246985366205406479 A 1474547502736210711 15765923971016795205 A 12...
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 2070ms
memory: 37332kb
input:
16000 20000 14 12381691541923575949 2314459967875656919 15240288079556723088 320873566057825844 1013209648229540810 17538037439317817183 11476444495745028170 14967174865083701448 17232652930598276562 7175999203534983334 4597650078600036201 13978217693115848142 17682091621678261784 488328147143975490...
output:
A 2314459967875656919 15240288079556723088 A 320873566057825844 1013209648229540810 A 104495759024483944 1334083214287366654 A 17538037439317817183 11476444495745028170 A 14967174865083701448 17232652930598276562 A 11564229646654949290 14749575507274081947 A 1438578973311850598 7867061080219479621 A...
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 2213ms
memory: 36552kb
input:
16000 20000 14 14874916021093924522 12369740409537030379 6287256359015658845 823444916947643237 4526221239260804705 11449122367236060745 5269387146536217002 12271448617436014402 2707995377102611522 953402166614134577 8882130735136249391 5659092195367212151 12689325453646244318 14372002311792512418 7...
output:
A 12369740409537030379 6287256359015658845 A 823444916947643237 4526221239260804705 A 210252694843137608 5349666156208447942 A 11449122367236060745 5269387146536217002 A 12271448617436014402 2707995377102611522 A 17715001299073933300 15975935779840281477 A 6556410636353241103 15244193005204663161 A ...
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 2549ms
memory: 37448kb
input:
16000 20000 14 12315377266285165767 11473010392351879640 7998004721169407057 9573065544888591349 8327463206443780344 16951550409690804427 9014132268830135915 1328673092737196637 5921820488166554289 3905417438586104204 16182336802010099310 4414669279483371512 13388655175283310101 4417487293134062765 ...
output:
A 11473010392351879640 7998004721169407057 A 9573065544888591349 8327463206443780344 A 1024271039811735081 450276462924475630 A 16951550409690804427 9014132268830135915 A 1328673092737196637 5921820488166554289 A 7518938604811388726 8246985366205406479 A 1474547502736210711 15765923971016795205 A 12...
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 2379ms
memory: 37552kb
input:
16000 20000 14 12381691541923575949 2314459967875656919 15240288079556723088 320873566057825844 1013209648229540810 17538037439317817183 11476444495745028170 14967174865083701448 17232652930598276562 7175999203534983334 4597650078600036201 13978217693115848142 17682091621678261784 488328147143975490...
output:
A 2314459967875656919 15240288079556723088 A 320873566057825844 1013209648229540810 A 104495759024483944 1334083214287366654 A 17538037439317817183 11476444495745028170 A 14967174865083701448 17232652930598276562 A 11564229646654949290 14749575507274081947 A 1438578973311850598 7867061080219479621 A...
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 2308ms
memory: 37508kb
input:
16000 20000 14 14874916021093924522 12369740409537030379 6287256359015658845 823444916947643237 4526221239260804705 11449122367236060745 5269387146536217002 12271448617436014402 2707995377102611522 953402166614134577 8882130735136249391 5659092195367212151 12689325453646244318 14372002311792512418 7...
output:
A 12369740409537030379 6287256359015658845 A 823444916947643237 4526221239260804705 A 210252694843137608 5349666156208447942 A 11449122367236060745 5269387146536217002 A 12271448617436014402 2707995377102611522 A 17715001299073933300 15975935779840281477 A 6556410636353241103 15244193005204663161 A ...
result:
ok 2 lines
Test #11:
score: 0
Accepted
time: 2280ms
memory: 37452kb
input:
16000 20000 14 12315377266285165767 11473010392351879640 7998004721169407057 9573065544888591349 8327463206443780344 16951550409690804427 9014132268830135915 1328673092737196637 5921820488166554289 3905417438586104204 16182336802010099310 4414669279483371512 13388655175283310101 4417487293134062765 ...
output:
A 11473010392351879640 7998004721169407057 A 9573065544888591349 8327463206443780344 A 1024271039811735081 450276462924475630 A 16951550409690804427 9014132268830135915 A 1328673092737196637 5921820488166554289 A 7518938604811388726 8246985366205406479 A 1474547502736210711 15765923971016795205 A 12...
result:
ok 2 lines