QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760373#3509. Ants and SugarWansur#0 445ms601004kbC++202.1kb2024-11-18 16:33:222024-11-18 16:33:22

Judging History

This is the latest submission verdict.

  • [2024-11-18 16:33:22]
  • Judged
  • Verdict: 0
  • Time: 445ms
  • Memory: 601004kb
  • [2024-11-18 16:33:22]
  • Submitted

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;
    if(x.tr == x.tl) {
        if(y.tl == y.tr) {
            int val = min(x.lx, y.lx);
            ans.ans += val;
            ans.lx = x.lx - val;
            ans.rx = y.lx - val;
        }
        else {
            int val = min(x.lx, y.lx);
            ans.lx = x.lx - val;
            ans.rx = y.rx;
        }
    }
    else if(y.tl == y.tr) {
        int val = min(x.rx, y.lx);
        ans.ans += val;
        ans.lx = x.lx;
        ans.rx = y.lx - val;
    }
    else {
        ans.ans += min(x.rx, y.lx);
        ans.lx = x.lx;
        ans.rx = y.rx;
    }
    return ans;
}


asd t[maxn * 30];
int L[maxn * 30], R[maxn];
int nv = 1;

void upd(int v, int tl, int tr, int pos, int x) {
    if(tl == tr) {
        t[v] = asd(tl, t[v].lx + 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();
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 20ms
memory: 591356kb

input:

1 1
1 1 43789532

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Wrong Answer
time: 56ms
memory: 590760kb

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: 24ms
memory: 590428kb

input:

1 1
2 0 424230929

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Wrong Answer
time: 402ms
memory: 599408kb

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: 445ms
memory: 601004kb

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%