Submission #65266174
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;using ll = long long;const int L = 1, R = 1000000001;struct Node {Node *l = nullptr, *r = nullptr;int cnt = 0;ll s0 = 0, s1 = 0;};void upd(Node*& t, int lo, int hi, int x) {if (!t) t = new Node();if (lo + 1 == hi) {t->cnt++;t->s0 += x;return;}int mid = lo + (hi - lo) / 2;if (x < mid) {upd(t->l, lo, mid, x);
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int L = 1, R = 1000000001;
struct Node {
Node *l = nullptr, *r = nullptr;
int cnt = 0;
ll s0 = 0, s1 = 0;
};
void upd(Node*& t, int lo, int hi, int x) {
if (!t) t = new Node();
if (lo + 1 == hi) {
t->cnt++;
t->s0 += x;
return;
}
int mid = lo + (hi - lo) / 2;
if (x < mid) {
upd(t->l, lo, mid, x);
} else {
upd(t->r, mid, hi, x);
}
int cL = 0, cR = 0;
ll s0L = 0, s1L = 0, s0R = 0, s1R = 0;
if (t->l) {
cL = t->l->cnt;
s0L = t->l->s0;
s1L = t->l->s1;
}
if (t->r) {
cR = t->r->cnt;
s0R = t->r->s0;
s1R = t->r->s1;
}
t->cnt = cL + cR;
if (cL % 2 == 0) {
t->s0 = s0L + s0R;
t->s1 = s1L + s1R;
} else {
t->s0 = s0L + s1R;
t->s1 = s1L + s0R;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Q;
cin >> Q;
Node* root = nullptr;
ll z = 0;
while (Q--) {
ll y;
cin >> y;
int x = int((y + z) % 1000000000) + 1;
upd(root, L, R, x);
z = root->s0;
cout << z << "\n";
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | G - Odd Position Sum Query |
| User | OYU__0YU |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1326 Byte |
| Status | WA |
| Exec Time | 566 ms |
| Memory | 195268 KB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 600 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3604 KB |
| 00_sample_01.txt | AC | 1 ms | 3488 KB |
| 01_test_00.txt | AC | 1 ms | 3596 KB |
| 01_test_01.txt | AC | 1 ms | 3432 KB |
| 01_test_02.txt | AC | 1 ms | 3460 KB |
| 01_test_03.txt | AC | 1 ms | 3616 KB |
| 01_test_04.txt | AC | 2 ms | 3876 KB |
| 01_test_05.txt | AC | 2 ms | 3944 KB |
| 01_test_06.txt | AC | 9 ms | 8788 KB |
| 01_test_07.txt | AC | 3 ms | 5160 KB |
| 01_test_08.txt | AC | 26 ms | 18148 KB |
| 01_test_09.txt | WA | 144 ms | 70976 KB |
| 01_test_10.txt | WA | 280 ms | 122828 KB |
| 01_test_11.txt | WA | 228 ms | 110576 KB |
| 01_test_12.txt | WA | 467 ms | 185776 KB |
| 01_test_13.txt | WA | 475 ms | 185876 KB |
| 01_test_14.txt | WA | 291 ms | 124920 KB |
| 01_test_15.txt | WA | 480 ms | 184840 KB |
| 01_test_16.txt | WA | 358 ms | 138352 KB |
| 01_test_17.txt | WA | 506 ms | 185892 KB |
| 01_test_18.txt | WA | 451 ms | 170292 KB |
| 01_test_19.txt | WA | 477 ms | 185836 KB |
| 01_test_20.txt | WA | 281 ms | 119288 KB |
| 01_test_21.txt | WA | 527 ms | 185864 KB |
| 01_test_22.txt | WA | 485 ms | 164976 KB |
| 01_test_23.txt | WA | 562 ms | 185760 KB |
| 01_test_24.txt | WA | 404 ms | 147088 KB |
| 01_test_25.txt | WA | 525 ms | 185752 KB |
| 01_test_26.txt | AC | 531 ms | 195200 KB |
| 01_test_27.txt | AC | 538 ms | 195268 KB |
| 01_test_28.txt | AC | 512 ms | 190708 KB |
| 01_test_29.txt | AC | 547 ms | 190752 KB |
| 01_test_30.txt | AC | 566 ms | 193240 KB |
| 01_test_31.txt | AC | 533 ms | 193284 KB |
| 01_test_32.txt | WA | 539 ms | 184360 KB |
| 01_test_33.txt | WA | 526 ms | 184444 KB |
| 01_test_34.txt | WA | 487 ms | 185680 KB |
| 01_test_35.txt | WA | 511 ms | 185664 KB |
| 01_test_36.txt | WA | 480 ms | 185596 KB |
| 01_test_37.txt | WA | 441 ms | 185712 KB |
| 01_test_38.txt | WA | 511 ms | 185780 KB |
| 01_test_39.txt | WA | 511 ms | 185476 KB |
| 01_test_40.txt | WA | 512 ms | 185560 KB |
| 01_test_41.txt | WA | 511 ms | 185504 KB |
| 01_test_42.txt | AC | 2 ms | 3440 KB |
| 01_test_43.txt | WA | 532 ms | 184360 KB |
| 01_test_44.txt | WA | 105 ms | 5152 KB |