QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236781 | #7522. Sequence Shift | SSH_automaton | WA | 6ms | 7736kb | C++14 | 1.4kb | 2023-11-04 10:41:32 | 2023-11-04 10:41:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
const int MAX = 1e9;
int n, q, a[N], b[N], p[N], s[N], len;
int ans[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i) cin >> b[i];
if (n <= 1000 && q <= 1000) {
int last = 0;
for (int i = 1; i <= n; ++i) last = max(last, a[i] + b[i]);
cout << last << '\n';
for (int d = 1; d <= q; ++d) {
cin >> b[n + d];
b[n + d] ^= last;
last = 0;
for (int j = 1; j <= n; ++j) last = max(last, a[j] + b[j + d]);
cout << last << '\n';
}
return 0;
}
int m = 8000;
int mn = MAX - 1LL * MAX * m / n;
for (int i = 1; i <= n; ++i) {
if (a[i] >= mn) p[++len] = i, s[len] = a[i];
}
int last = 0;
for (int i = 1; i <= n; ++i) last = max(last, a[i] + b[i]);
cout << last << '\n';
for (int i = 1; i <= n; ++i) {
if (b[i] < mn) continue;
for (int j = 1; j <= len; ++j)
if (i > p[j])
ans[i - p[j]] = max(ans[i - p[j]], b[i] + s[j]);
}
int cnt = 0;
for (int d = 1; d <= q; ++d) {
cin >> b[n + d];
b[n + d] ^= last;
if (b[n + d] >= mn) {
++cnt;
for (int j = 1; j <= len; ++j)
if (n + d > p[j])
ans[n + d - p[j]] = max(ans[n + d - p[j]], b[n + d] + s[j]);
}
last = ans[d];
cout << last << '\n';
}
cerr << cnt << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7728kb
input:
5 3 1 4 3 2 5 7 5 8 3 2 3 6 4
output:
11 13 16 25
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 7680kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7652kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 835582012
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 7644kb
input:
1 10 700282491 332230980 90825676 1630266999 644973380 262379760 2122877054 1851957134 1370195232 110993724 1319359505 1883523208
output:
1032513471 1654684398 759763732 888538827 1695749302 1163465539 1425605448 789576931 1397740634 1202288326 1638577353
result:
ok 11 lines
Test #5:
score: -100
Wrong Answer
time: 6ms
memory: 7736kb
input:
1000 100000 438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...
output:
1962871590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 2nd lines differ - expected: '1986083253', found: '0'