QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760398 | #3509. Ants and Sugar | Wansur# | 0 | 328ms | 605296kb | C++20 | 1.7kb | 2024-11-18 16:47:57 | 2024-11-18 16:48:08 |
Judging History
answer
#include <bits/stdc++.h>
#define ent '\n'
#define int long long
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 12;
const int mod = 998244353;
int n, m, k;
struct asd {
int lx, rx, ans;
int tl, tr;
asd() {
lx = rx = tl = tr = ans = 0;
}
asd(int i, int x) {
ans = 0;
lx = rx = x;
tl = tr = i;
}
};
asd merge(asd x, asd y) {
asd ans;
ans.ans = x.ans + y.ans;
ans.tl = x.tl, ans.tr = y.tr;
int val = min(x.rx, y.lx);
ans.ans += val;
ans.lx = x.lx, ans.rx = y.rx;
if(x.tl == x.tr) {
ans.lx -= val;
}
if(y.tl == y.tr) {
ans.rx -= val;
}
return ans;
}
asd t[maxn * 30];
int L[maxn * 30], R[maxn * 30];
int nv = 1;
void upd(int v, int tl, int tr, int pos, int x) {
if(tl == tr) {
t[v].tl = t[v].tr = tl;
t[v].lx += x;
t[v].rx += x;
return;
}
int mid = tl + tr >> 1;
if(!L[v]) {
L[v] = ++nv;
t[L[v]].tl = tl;
t[L[v]].tr = mid;
}
if(!R[v]) {
R[v] = ++nv;
t[R[v]].tl = mid + 1;
t[R[v]].tr = tr;
}
if(pos <= mid) {
upd(L[v], tl, mid, pos, x);
}
else {
upd(R[v], mid + 1, tr, pos, x);
}
t[v] = merge(t[L[v]], t[R[v]]);
}
void solve() {
cin >> n >> k;
m = (1 << 30) - 1;
while(n--) {
int tp, pos, x;
cin >> tp >> pos >> x;
upd(1, 0, m, pos, x);
cout << t[1].ans << ent;
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while(t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 27ms
memory: 591144kb
input:
1 1 1 1 43789532
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Wrong Answer
time: 43ms
memory: 589964kb
input:
2059 1 2 91 205759686 2 2689 599484232 1 2180 81617884 2 1782 293164452 2 1295 83799395 1 824 576761628 2 2942 522567248 2 2573 662719421 2 2570 691955288 1 2656 419809596 1 2225 256640321 1 2171 737201459 1 586 819276893 1 2368 699662246 1 738 914000324 2 2758 745510056 1 2108 122277545 1 1409 9821...
output:
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 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 226516121 22...
result:
wrong answer 86th lines differ - expected: '462049638', found: '226516121'
Subtask #2:
score: 0
Wrong Answer
Test #22:
score: 16
Accepted
time: 19ms
memory: 590456kb
input:
1 1 2 0 424230929
output:
0
result:
ok single line: '0'
Test #23:
score: 0
Wrong Answer
time: 269ms
memory: 600320kb
input:
362674 1 1 319945 761268318 1 277089 817774990 2 18206 713581467 2 142742 89669841 2 102420 421037684 2 114708 529878465 2 293986 64855921 2 339668 633637695 1 320879 569859555 1 241581 2375253 1 210995 379413808 1 63811 2383494 2 12768 261151784 2 180138 450721176 2 96696 419034251 2 97996 46059421...
output:
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 0 0 0 0 0 ...
result:
wrong answer 19374th lines differ - expected: '327089638255', found: '326648745057'
Subtask #3:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 328ms
memory: 605296kb
input:
401626 1 1 457671 568783758 1 417077 607440922 1 139391 32824188 1 14373 220864694 1 118370 531535298 1 266098 186053453 1 127727 666497333 1 338836 353757976 1 481683 518470240 1 480524 68393518 1 232781 901754468 1 8039 85894025 1 439988 468564731 1 27639 140803132 1 241258 222831725 1 477544 9656...
output:
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 0 0 0 0 0 ...
result:
wrong answer 482nd lines differ - expected: '0', found: '676273609'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%