QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725998#9601. I Wanna MakerTheZoneAC ✓54ms6756kbC++202.7kb2024-11-08 21:10:112024-11-08 21:10:11

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 21:10:11]
  • 评测
  • 测评结果:AC
  • 用时:54ms
  • 内存:6756kb
  • [2024-11-08 21:10:11]
  • 提交

answer

#include<bits/stdc++.h>
#define N 200010
#define ll long long
#define pll pair<ll,ll>
#define fi first 
#define se second
using namespace std;
int T,n;
ll k,x,lm,rm,l,r;
pll p[N];

void solve(){
    ll pl=0,pr=1e9;
    while(pl<pr){
        ll mid=(pl+pr+1)/2;
        if(k*(2*mid+k-1)/2>x) pr=mid-1;
        else pl=mid;
    }
    l=pl;
    pl=0;pr=1e9;
    while(pl<pr){
        ll mid=(pl+pr)/2;
        if(k*(2*mid-k+1)/2<x) pl=mid+1;
        else pr=mid;
    }
    r=pl;
    // cout<<l<<' '<<r<<" !!!\n";
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int _;
    cin>>_;
    while(_--){
        cin>>n;
        int cnt=0;
        lm=1e9;
        rm=0;
        for(int i=1;i<=n;i++){
            int t;
            cin>>t>>k>>x;
            solve();
            if(t==1){
                lm=min(l,lm);
                rm=max(r,rm);
                continue;
            }
            cnt++;
            p[cnt].fi=l;
            p[cnt].se=r;
        }
        if(!lm){
            cout<<"0\n";
            continue;
        }
        if(!cnt){
            cout<<"-1\n";
            continue;
        }
        cnt++;
        p[cnt].fi=lm;
        p[cnt].se=1e18;
        sort(p+1,p+cnt+1);
        ll ans=0,rx=1e18;
        // cout<<lm<<' '<<rm<<" !!\n";
        for(int i=cnt;i>=1;i--){
            rx=min(rx,p[i].se);
            // cout<<i<<' '<<p[i].fi<<' '<<p[i].se<<" !!\n"; 
            if(p[i].fi>lm) continue;
            if(p[i].fi>p[i-1].fi&&rx==1e18){
                ans=-1;
                break; 
            }
            ans+=(p[i].fi-p[i-1].fi)*max(0ll,rx-rm);
        }
        cout<<ans<<'\n';
    }
    return 0;
}
/*#include<bits/stdc++.h>
#define N 200010
#define ll long long
#define pll pair<ll,ll>
#define fi first 
#define se second
using namespace std;
int T,n;
ll k,x,lm,rm,l,r;
pll p[N];

void solve(){
    ll pl=0,pr=1e9;
    while(pl<pr){
        ll mid=(pl+pr+1)/2;
        if(k*(2*mid+k-1)/2>x) pr=mid-1;
        else pl=mid;
    }
    l=pl;
    pl=0;pr=1e9;
    while(pl<pr){
        ll mid=(pl+pr)/2;
        if(k*(2*mid-k+1)/2<x) pl=mid+1;
        else pr=mid;
    }
    r=pl;
    // cout<<l<<' '<<r<<" !!!\n";
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int _;
    cin>>_;
    while(_--){
        cin>>n;
        int cnt=0;
        lm=1e9;
        rm=0;
        for(int i=1;i<=n;i++){
            int t;
            cin>>t>>k>>x;
            solve();
            if(t==1){
                lm=min(l,lm);
                rm=max(r,rm);
                continue;
            }
            cnt++;
            p[cnt].fi=l;
        cout<<ans<<'\n';
    }
    return 0;
}*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3644kb

input:

4
2
1 1 2
2 1 4
2
1 1 4
2 1 2
2
1 1 1
2 1 1
4
2 1 15
1 5 20
1 3 8
2 2 25

output:

4
-1
0
7

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 3588kb

input:

2000
5
2 4 9
2 2 7
2 1 6
2 1 8
2 1 6
5
2 1 6
2 1 13
1 4 14
1 3 6
1 4 1
5
2 5 6
2 2 13
2 3 4
1 2 13
2 3 12
5
1 3 7
2 2 15
1 2 9
1 2 11
2 2 6
5
1 1 19
2 2 10
2 2 4
2 5 16
1 1 20
5
1 5 18
1 1 19
1 4 18
2 3 1
2 3 16
5
1 3 18
1 2 11
2 4 12
2 2 8
1 2 6
5
2 5 16
1 3 17
1 5 13
2 5 3
1 5 15
5
1 5 6
1 3 16
1 ...

output:

-1
0
0
0
-1
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
-1
-1
0
0
6
0
0
0
0
-1
-1
0
-1
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
30
0
2
0
1
0
0
0
0
0
0
-1
0
0
0
-1
-1
0
7
0
2
0
-1
2
0
0
0
0
56
-1
0
6
-1
0
0
0
3
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
1
26
0
5
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
4
-1
0
0
0
-1
0
0
0...

result:

ok 2000 lines

Test #3:

score: 0
Accepted
time: 13ms
memory: 3652kb

input:

10000
5
1 5 15
1 1 7
2 2 16
2 3 11
1 5 19
5
1 2 4
2 4 12
1 1 12
1 4 4
2 4 19
5
1 1 16
1 2 8
1 1 5
2 5 10
2 1 12
5
2 1 8
2 5 19
2 1 18
1 1 4
1 5 1
5
1 3 5
1 3 9
1 1 8
1 3 20
1 1 15
5
1 5 5
2 5 11
2 5 6
2 1 14
1 5 3
5
2 4 2
1 5 19
1 5 12
1 1 11
2 3 20
5
1 2 13
2 2 2
1 1 10
1 4 9
1 1 4
5
1 1 3
1 5 7
2 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
-1
0
0
0
-1
0
-1
0
-1
0
0
0
0
0
0
12
42
0
6
0
0
0
0
1
0
0
0
0
28
0
0
0
0
-1
0
0
0
1
0
0
0
0
0
0
0
2
0
-1
0
0
-1
0
-1
0
0
24
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
-1
0
0
9
0
0
3
0
0
0
2
0
0
6
0
0
0
0
0
0
0
0
8
0
0
0
0...

result:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 19ms
memory: 3588kb

input:

15000
5
1 2 18
1 5 2
1 1 13
1 4 19
1 1 13
5
2 2 2
2 1 19
2 2 14
1 4 20
2 1 10
5
1 5 10
1 4 8
1 3 20
1 1 2
1 1 8
5
1 2 1
2 4 14
1 5 19
1 4 16
1 1 18
5
1 1 13
2 1 18
2 4 13
1 4 3
2 3 8
5
2 4 19
2 4 2
2 1 4
1 3 3
1 2 18
5
1 1 4
1 4 11
1 2 6
1 1 19
2 3 20
5
1 5 18
2 5 2
2 2 4
1 1 8
1 1 16
5
1 2 20
1 5 1...

output:

0
3
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
-1
0
0
13
1
-1
0
0
1
3
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
2
-1
0
0
0
0
0
0
0
0
20
0
0
-1
0
10
0
0
0
0
0
0
-1
0
-1
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
-1
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 15000 lines

Test #5:

score: 0
Accepted
time: 24ms
memory: 3660kb

input:

20000
5
1 4 2
1 1 14
2 1 18
1 1 8
1 4 1
5
1 1 10
2 3 13
1 3 5
2 5 2
1 1 15
5
2 1 10
2 5 18
1 1 18
1 3 14
1 5 10
5
1 4 12
2 3 11
1 3 19
2 4 11
2 4 19
5
2 4 14
1 4 3
2 3 7
2 4 10
2 3 20
5
1 5 2
2 2 14
1 2 8
2 4 8
2 1 8
5
1 2 6
2 4 3
1 4 17
2 1 1
1 1 17
5
2 2 18
1 5 18
1 3 3
2 3 15
1 4 18
5
1 1 3
1 1 1...

output:

0
0
0
0
0
0
-1
0
0
0
0
-1
0
0
0
1
0
0
0
-1
0
0
0
0
3
0
0
0
1
1
0
3
0
0
0
0
0
0
-1
0
0
-1
0
0
-1
0
0
0
0
0
0
0
-1
0
0
0
0
0
-1
20
-1
6
-1
-1
14
-1
0
0
0
16
0
0
0
0
42
0
0
7
0
1
0
-1
0
0
0
0
0
0
0
0
9
0
0
0
0
0
0
0
0
0
2
12
0
0
0
0
0
0
0
0
0
22
1
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
3
0
0
0
...

result:

ok 20000 lines

Test #6:

score: 0
Accepted
time: 3ms
memory: 3612kb

input:

2000
5
1 47 3
1 34 2
1 3 15
1 44 9
1 35 8
5
1 18 14
1 31 8
2 20 2
1 32 13
1 32 17
5
1 42 16
1 18 15
1 12 19
2 29 17
1 39 8
5
2 25 7
2 5 19
1 41 20
2 38 13
2 4 19
5
1 36 7
2 15 4
1 47 10
2 28 4
1 1 20
5
2 30 9
2 41 3
2 9 2
1 18 15
2 50 20
5
2 16 14
1 33 16
1 19 6
2 18 4
2 32 19
5
1 10 8
2 10 11
1 35 ...

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
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
...

result:

ok 2000 lines

Test #7:

score: 0
Accepted
time: 13ms
memory: 3660kb

input:

10000
5
2 44 11
1 12 11
2 50 13
2 10 20
1 12 14
5
2 3 15
1 48 1
1 33 14
2 39 8
1 33 9
5
2 25 1
1 17 8
1 8 18
2 46 4
1 21 7
5
2 16 20
2 25 3
2 30 14
2 33 13
1 32 11
5
2 26 18
2 30 12
2 19 19
2 11 2
1 33 15
5
2 20 13
2 50 10
1 22 16
1 15 7
1 27 4
5
2 3 1
2 4 17
2 45 3
1 31 16
2 9 13
5
1 36 3
1 15 2
2 ...

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
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0...

result:

ok 10000 lines

Test #8:

score: 0
Accepted
time: 19ms
memory: 3716kb

input:

15000
5
2 8 7
1 2 6
2 26 16
2 5 18
1 33 17
5
2 42 16
1 44 14
1 39 3
2 32 19
1 39 15
5
2 42 14
2 17 17
1 39 7
2 5 18
1 29 17
5
2 1 11
1 43 16
2 22 19
1 28 18
1 16 12
5
2 41 18
2 13 18
2 9 7
1 34 6
2 10 13
5
1 19 10
2 23 12
1 15 9
1 21 9
2 13 9
5
2 20 18
2 2 18
1 8 17
2 23 10
2 20 20
5
1 41 7
2 5 2
1 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
-1
0
...

result:

ok 15000 lines

Test #9:

score: 0
Accepted
time: 25ms
memory: 3668kb

input:

20000
5
1 37 13
2 4 1
1 18 20
1 11 6
1 2 20
5
2 3 20
2 21 13
1 10 7
1 7 18
1 36 18
5
1 22 16
2 22 11
2 5 18
2 37 15
2 50 2
5
2 39 2
1 17 17
2 4 9
2 35 15
2 25 6
5
2 45 11
2 6 15
1 3 5
2 42 7
1 31 16
5
1 13 16
1 32 1
1 32 10
1 45 10
2 44 12
5
1 33 3
2 28 8
2 31 12
1 21 16
1 23 15
5
1 1 9
1 19 15
2 30...

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
-1
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 20000 lines

Test #10:

score: 0
Accepted
time: 24ms
memory: 3636kb

input:

10000
10
2 29 17
2 31 8
2 47 16
1 34 3
1 41 10
1 9 5
2 36 7
2 42 11
2 20 11
1 17 12
10
1 15 4
2 4 15
2 32 19
1 2 20
2 16 4
2 25 9
1 36 9
2 31 18
2 9 4
2 12 10
10
1 33 20
1 46 12
2 20 16
2 46 13
2 32 17
2 6 3
1 48 14
1 4 3
1 39 10
1 33 3
10
1 7 2
2 7 3
1 19 20
2 19 8
1 46 2
2 37 13
1 18 10
1 21 5
2 2...

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:

ok 10000 lines

Test #11:

score: 0
Accepted
time: 24ms
memory: 3712kb

input:

10000
10
1 1 6
2 7 86
1 2 11
1 3 13
1 1 6
2 9 86
2 8 90
1 1 4
2 8 94
2 10 95
10
1 1 5
2 11 83
2 8 97
1 3 10
1 2 11
1 1 6
1 1 6
2 7 89
2 11 94
2 8 92
10
2 9 83
2 8 87
1 2 10
1 1 4
1 2 10
2 13 79
1 2 6
2 11 88
2 13 84
1 1 3
10
2 13 89
1 1 4
2 8 96
2 8 86
1 2 7
2 11 84
1 2 11
2 11 87
1 2 9
1 1 5
10
1 3...

output:

24
14
14
23
7
15
16
15
8
14
24
24
15
16
14
8
7
24
14
8
7
9
15
41
7
7
7
7
14
24
32
7
22
23
22
8
16
15
23
7
24
14
8
8
14
7
22
7
14
32
22
7
7
8
7
7
8
8
34
7
30
8
7
7
15
14
7
14
14
15
8
7
16
7
8
25
7
16
7
14
16
15
14
7
15
7
7
14
8
8
18
7
17
33
7
8
8
7
14
15
16
8
15
16
8
7
7
14
7
16
23
23
7
15
8
22
14
8
...

result:

ok 10000 lines

Test #12:

score: 0
Accepted
time: 21ms
memory: 3588kb

input:

1000
100
1 1 18
1 1 24
1 1 22
2 39 2486
1 1 25
2 47 2434
2 40 2384
2 60 2371
1 9 184
2 53 2491
2 67 2431
1 2 47
1 8 167
2 39 2421
1 1 17
1 9 167
1 2 49
2 70 2429
1 7 139
2 52 2424
1 6 119
2 66 2445
2 40 2448
1 2 46
1 8 144
1 2 42
2 57 2430
2 65 2462
2 42 2427
1 4 86
1 3 66
2 65 2469
2 48 2468
2 40 2...

output:

634
634
635
634
635
636
634
638
635
634
634
634
635
636
634
634
680
634
634
634
634
634
635
634
634
634
634
634
634
634
634
634
636
634
637
635
633
634
634
634
635
634
634
634
680
634
634
634
635
634
636
635
636
634
634
635
634
634
634
635
636
635
638
635
635
635
680
638
634
634
634
635
637
634
635
...

result:

ok 1000 lines

Test #13:

score: 0
Accepted
time: 38ms
memory: 3656kb

input:

100
1000
2 9496 99984641
1 184 715853
2 8907 99990925
2 7515 99983724
2 10812 99991554
1 2106 6392284
2 9930 99980494
1 1925 5658431
1 552 2616103
1 3183 6922856
1 2605 5584460
2 10784 99986786
2 8596 99978295
1 3534 9732158
1 643 3181571
2 11227 99981583
1 193 960792
2 8369 99983878
1 1972 3143170
...

output:

5103933
5278635
4963232
4901729
4919295
5103896
5199836
4910449
5190920
4911101
5077726
4980617
4910500
5217268
5034352
4928101
4954415
4919303
4902319
5103912
4936911
4901828
5103288
4980612
5261638
4919852
5068778
4980700
5278459
4998374
4998127
4901775
4989420
4989911
4919247
5226041
4919841
4945...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 40ms
memory: 3656kb

input:

10
10000
2 26185 999935373
2 28474 999955237
2 28555 999948595
1 4484 94040579
2 30376 999937936
2 36050 999971887
2 24683 999963114
1 429 10416337
1 554 13870426
1 600 11968120
2 38607 999958959
1 215 5271824
1 2552 62799522
2 34874 999950297
1 2362 51362587
2 39876 999951799
2 24981 999974946
2 31...

output:

364664005
364686156
364663852
364685850
364775484
364664312
364731273
364821077
364686975
364664827

result:

ok 10 lines

Test #15:

score: 0
Accepted
time: 54ms
memory: 5116kb

input:

1
100000
2 6 999797814
2 2 804720644
2 1 676157034
2 12 964266473
2 10 989245371
2 4 923174351
2 3 804458196
2 2 719857674
2 21 977397140
1 2 880588907
2 1 918392620
2 1 951508361
2 113 998043385
1 1 324244324
2 2 866932108
2 6 959452724
2 23 995560035
2 1 811388268
1 1 484382116
2 5 859914044
2 1 5...

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 49ms
memory: 6600kb

input:

1
100000
2 2 778841257
2 1 515764506
2 4 831022913
2 2 806845574
2 6 872441496
1 1 770162722
2 1 545890654
2 1 908822515
2 1 950736702
2 3 761124568
2 2 808101383
2 1 891141904
2 1 561006543
2 2 975885594
1 1 615733767
1 1 542372425
1 1 667833998
2 1 967472393
1 1 723391864
2 44 995473870
2 8 921287...

output:

0

result:

ok single line: '0'

Test #17:

score: 0
Accepted
time: 50ms
memory: 4336kb

input:

1
100000
1 1 539870485
1 1 512051538
2 2 722189202
2 2 725647236
2 4 988693259
1 1 486417473
1 2 977916064
2 5 950831814
2 3 829249547
2 1 509150954
2 84 991410261
2 2 942078812
1 1 530210895
2 2 846933663
1 1 492928365
2 4 923678303
2 8 923075203
1 1 542630229
1 1 520222444
1 1 535655050
1 2 981657...

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 42ms
memory: 5856kb

input:

1
100000
1 5 997287681
2 1 771792807
2 1 515288366
1 1 519337499
1 1 878130929
1 2 857708612
2 3 914797105
1 1 591184047
1 1 442405783
2 12 969866402
1 1 856399734
2 3 936845725
2 74 992745897
1 2 835304280
1 1 493724726
1 4 850609717
1 1 77537148
1 2 820862514
1 1 753909414
1 1 871710046
2 7 966069...

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 43ms
memory: 3816kb

input:

1
100000
1 2 741203053
1 2 927220539
1 2 718822503
1 2 879120963
1 1 479214703
1 3 765146704
1 1 370440087
1 1 445746323
1 1 474819792
1 1 454214188
1 3 943628060
1 1 308166606
1 2 674331871
1 2 695173271
1 2 916067828
1 2 863334952
1 2 497485006
1 1 420317291
1 1 332226883
1 3 987817420
1 2 8200906...

output:

0

result:

ok single line: '0'

Test #20:

score: 0
Accepted
time: 48ms
memory: 4192kb

input:

1
100000
1 1 877362750
1 1 910610338
2 3 875623044
2 9 988602316
1 1 898983652
1 1 882468518
1 1 877299290
1 1 872522095
1 1 872768278
1 1 899342234
2 1 664989920
2 2 867814210
2 1 676826651
2 4 831727579
2 3 830446535
2 1 636012805
1 1 892689689
1 1 903948893
1 1 884210944
1 1 912968113
1 1 9116716...

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 26ms
memory: 6220kb

input:

1
100000
2 44699 999925268
2 44645 999920496
1 8 619
2 44637 999914729
2 44688 999929001
2 44690 999959795
1 16 850
1 13 1096
1 5 447
2 44666 999948814
1 12 739
2 44661 999921389
1 28 2319
1 17 1341
1 6 522
2 44670 999924328
1 15 1168
2 44652 999948048
1 33 2567
1 50 3532
1 12 971
1 35 2572
2 44622 ...

output:

1874082

result:

ok single line: '1874082'

Test #22:

score: 0
Accepted
time: 34ms
memory: 4440kb

input:

1
100000
2 43956 999969681
2 44349 999966670
2 44401 999969409
1 392 178728
2 44194 999954862
2 44387 999977133
1 14 8600
2 44203 999923537
1 11 7412
2 43844 999936373
1 14 10258
2 44245 999966189
2 43939 999941544
1 32 23270
1 13 5920
1 29 11121
1 51 36577
2 43946 999956680
1 341 156541
2 43770 999...

output:

9629976

result:

ok single line: '9629976'

Test #23:

score: 0
Accepted
time: 36ms
memory: 5744kb

input:

1
100000
2 40078 999950658
1 2232 14572842
2 36091 999973091
1 959 3595350
2 38058 999990209
2 41161 999949367
2 43298 999945952
1 50 431109
1 3345 21277603
1 178 784629
1 1386 9292130
2 43752 999934164
2 36941 999932235
2 36026 999984373
1 4412 23929278
1 381 2730331
1 5455 27265377
1 989 3503678
1...

output:

62403732

result:

ok single line: '62403732'

Test #24:

score: 0
Accepted
time: 39ms
memory: 5936kb

input:

1
100000
1 1787 143541408
1 9454 705233853
1 6393 371986090
1 15803 741285238
2 32913 999965590
2 10412 999988604
1 2908 227751417
1 3529 259968536
2 14403 999932280
1 11959 613801400
1 2653 173870747
2 21643 999933470
1 19472 957887577
1 17660 968554828
1 14133 997514802
2 42555 999925335
2 32927 9...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 44ms
memory: 4488kb

input:

1
100000
1 1010 501954671
1 495 238278514
1 1888 910049349
2 2442 999757852
2 2647 999674774
1 1018 506294244
2 2046 999632340
1 1596 777319401
1 913 445299708
1 1915 920857497
1 1221 582503550
2 20574 999983134
1 887 431245332
2 1269 999900917
1 1658 813588286
2 2971 999942648
1 359 177314237
2 132...

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 43ms
memory: 6060kb

input:

1
100000
2 131 997250092
2 3640 999803141
1 170 961245283
1 92 690163467
1 197 681017869
1 660 791655595
1 76 458788189
2 139 997890820
2 619 998831411
2 108 998785609
1 133 787816673
2 105 992042175
2 115 996328664
1 37 247900990
1 15 106470535
2 105 999384288
2 121 992003613
1 161 882499039
2 539 ...

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 45ms
memory: 4388kb

input:

1
100000
1 4 310864997
1 13 962669443
2 87 996451546
1 6 435230908
2 18 949911453
1 4 309447780
1 1 78473389
2 18 996701613
2 27 996086363
2 17 975558939
2 16 944540974
1 5 377855399
2 33 985423146
2 16 942830984
2 75 999866320
2 64 985752404
1 10 726158143
2 11 991756995
1 12 939244607
1 11 8181008...

output:

0

result:

ok single line: '0'

Test #28:

score: 0
Accepted
time: 29ms
memory: 3656kb

input:

100000
1
2 5 15
1
1 3 11
1
1 5 14
1
1 1 1
1
2 2 4
1
1 3 18
1
1 2 16
1
2 4 19
1
2 4 20
1
1 5 6
1
2 4 6
1
2 3 19
1
2 1 20
1
2 3 7
1
2 3 2
1
1 3 4
1
2 5 12
1
2 4 12
1
1 1 12
1
1 5 18
1
2 3 17
1
1 2 17
1
2 4 16
1
1 4 8
1
2 3 19
1
2 1 10
1
2 1 19
1
2 3 8
1
1 5 5
1
1 5 8
1
1 2 4
1
1 4 12
1
2 5 1
1
2 4 5
1...

output:

-1
-1
0
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
0
0
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
0
-1
-1
-1
-1
-1
0
-1
-1
-1
0
-1
0
-1
0
0
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
0
0
-1
0
-1
-1
0
-1
0
-1
...

result:

ok 100000 lines

Test #29:

score: 0
Accepted
time: 27ms
memory: 3648kb

input:

50000
2
1 4 7
2 2 2
2
2 1 15
2 1 8
2
2 3 3
2 4 20
2
1 2 18
2 5 6
2
2 1 13
1 2 9
2
2 4 2
2 1 2
2
1 2 9
2 2 17
2
1 5 10
2 4 15
2
1 4 18
2 4 9
2
1 3 13
1 2 20
2
2 4 15
2 3 17
2
2 4 11
2 5 10
2
1 4 13
2 2 9
2
2 2 15
1 2 13
2
2 5 10
2 5 14
2
1 5 17
1 1 1
2
1 3 2
2 2 13
2
2 1 11
2 3 3
2
1 3 19
2 4 12
2
1 ...

output:

0
-1
-1
-1
32
-1
16
0
-1
-1
-1
-1
0
6
-1
-1
0
-1
-1
0
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
0
-1
-1
0
-1
-1
-1
0
0
-1
-1
0
-1
0
-1
-1
-1
-1
-1
-1
0
-1
-1
0
-1
52
0
30
-1
-1
-1
-1
-1
15
11
-1
-1
0
9
3
0
-1
-1
-1
-1
0
0
0
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
0
-1
1
0
-1
0
-1
-1
-1
-1
0
-1
0...

result:

ok 50000 lines

Test #30:

score: 0
Accepted
time: 30ms
memory: 3580kb

input:

20000
5
2 26 279
2 8 1555
1 30 1831
2 14 1057
2 11 1397
5
2 10 851
2 33 1510
1 2 989
1 43 1629
1 46 582
5
1 42 593
2 45 1616
1 50 927
1 50 1928
1 31 835
5
2 48 1278
1 29 1153
1 47 261
2 9 1593
1 12 494
5
1 10 1340
1 48 640
2 15 1976
1 1 780
2 17 1563
5
2 4 303
2 36 934
2 30 408
2 33 1409
2 3 235
5
1...

output:

276
0
0
0
0
-1
0
545
0
0
0
-1
-1
0
0
0
-1
0
4902
0
-1
0
0
0
0
270
0
0
0
1824
0
0
0
0
0
0
0
0
120
0
0
0
0
-1
0
0
76
0
0
0
0
715
0
-1
0
0
-1
0
0
0
399
0
0
0
-1
0
0
0
0
0
-1
0
11
0
12
0
0
0
-1
0
0
12
0
0
0
510
0
0
0
0
30
-1
0
-1
0
0
272
8906
432
0
1728
0
720
664
0
-1
0
-1
-1
0
0
0
0
0
-1
0
0
7
3638
0
0...

result:

ok 20000 lines

Test #31:

score: 0
Accepted
time: 28ms
memory: 3652kb

input:

10000
10
1 8 179
1 40 1723
1 2 951
2 35 186
1 37 1156
1 31 1348
1 50 612
2 14 1560
1 22 1824
2 24 1384
10
2 15 1915
1 14 197
2 16 27
1 29 1100
2 48 1402
1 27 880
1 36 1629
2 13 312
2 38 307
2 47 428
10
2 13 1633
1 21 1819
1 9 1036
2 10 319
1 43 1560
1 42 116
1 12 784
2 26 1029
2 38 501
2 16 1097
10
...

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
-1
0
0
0
0
0
0
0
858
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24
0
0
0
0
0
0
0
0
0
0
0
0
0
0
840
0
0
0
0
0
0
0
0
870
0
0
0
0
0
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:

ok 10000 lines

Test #32:

score: 0
Accepted
time: 29ms
memory: 3716kb

input:

5000
20
2 29 3550
2 7 2218
1 47 4571
1 19 4256
1 30 1921
1 27 1593
2 3 2177
1 48 403
2 34 2191
2 18 2259
2 14 1182
2 9 2677
2 1 2491
2 45 617
1 28 3921
2 22 1825
1 11 3989
2 11 4511
1 8 723
2 34 748
20
1 33 2232
2 1 3406
1 6 1401
1 44 2337
2 37 2123
2 14 2922
1 33 1252
1 46 2327
1 31 4267
2 32 3235
...

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:

ok 5000 lines

Test #33:

score: 0
Accepted
time: 29ms
memory: 3644kb

input:

1000
100
1 20 722
2 7 275
1 41 39
1 40 400
1 37 3602
1 20 1015
1 4 2000
1 30 1566
1 28 2495
1 1 1853
1 9 1658
1 37 3821
1 12 3636
2 22 3828
1 12 3778
1 47 2780
2 27 2339
2 3 141
1 14 1124
2 18 216
2 20 2390
2 48 2605
2 48 283
1 27 3447
1 9 2145
2 7 374
2 24 1750
2 30 3116
1 33 4437
2 31 300
1 7 4431...

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:

ok 1000 lines

Test #34:

score: 0
Accepted
time: 33ms
memory: 3716kb

input:

100
1000
2 322 135124
2 8 193952
2 286 483244
1 151 453685
2 392 205255
2 87 95859
2 248 137053
2 399 55068
1 54 343989
1 12 122683
2 489 452195
1 472 209375
2 9 167525
1 57 316019
2 241 41600
1 215 152258
2 35 221591
2 128 73098
2 233 277133
2 244 266527
2 292 213628
2 52 208643
2 238 417590
2 246 ...

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

result:

ok 100 lines

Test #35:

score: 0
Accepted
time: 53ms
memory: 3664kb

input:

25000
4
2 1 644114374
2 15 963218922
1 1 734198377
1 2 987287252
4
1 1 775462011
2 1 753632132
2 10 923256032
1 1 520298359
4
2 9 923881393
1 1 708770464
1 1 540594841
2 1 630795236
4
1 1 659101601
1 1 659210568
2 1 532815496
2 4 823890181
4
1 1 513356033
1 1 717383607
2 4 800350853
2 6 860982021
4
...

output:

0
0
0
-1
-1
-1
64532879125071264
-1
83552498985435492
-1
16309808740905260
466042504394676
72312912925652160
-1
42062819658143875
0
45045520414395060
-1
87965044583772234
-1
16257680170681425
0
0
19688360293769609
14278288291974528
-1
0
14063747208316156
-1
135021281171764440
29725190386985125
-1
0
...

result:

ok 25000 lines

Test #36:

score: 0
Accepted
time: 43ms
memory: 3864kb

input:

10
10000
2 36272 999937612
2 33111 999953763
2 27280 999954312
2 25298 999951236
2 27735 999945786
2 40647 999981797
2 40705 999948856
2 41250 999936848
2 24004 999965892
2 31069 999948650
2 32484 999967053
2 24262 999954432
2 37556 999951422
2 24312 999952043
2 38752 999958685
2 36945 999955628
2 3...

output:

255971967
253006792
251434480
253957206
254767473
253687288
258433777
257043821
252328529
252852816

result:

ok 10 lines

Test #37:

score: 0
Accepted
time: 43ms
memory: 3740kb

input:

10
10000
2 26126 999968972
2 27850 999978728
2 27063 999953376
2 30809 999987714
2 28681 999952595
2 31432 999941226
2 28122 999959200
2 39110 999955011
2 36656 999958275
2 40357 999959763
2 36314 999994947
2 27319 999943038
2 27900 999977801
2 28424 999942897
2 25069 999959411
2 29275 999973192
2 3...

output:

5404666
7001614
5035468
7283677
13193022
6338210
309414
3447421
5094543
5492376

result:

ok 10 lines

Test #38:

score: 0
Accepted
time: 45ms
memory: 6756kb

input:

1
100000
2 40081 999962167
2 41027 999989195
2 25536 999947504
2 44521 999980463
2 32973 999944221
2 26093 999975491
2 26946 999965565
2 42182 999982607
2 42347 999975620
2 39444 999949713
2 25542 999952548
2 29930 999957690
2 36591 999929444
2 36056 999968657
2 28061 999942660
2 28678 999934820
2 3...

output:

410511366

result:

ok single line: '410511366'

Test #39:

score: 0
Accepted
time: 45ms
memory: 6088kb

input:

1
100000
2 42264 999981325
2 24862 999982802
2 30459 999987956
2 35579 999968409
2 43187 999988117
2 31244 999958475
2 29355 999960053
2 34907 999974944
2 43606 999974956
2 26452 999951263
2 24040 999970687
2 28619 999959913
2 25734 999956906
2 37929 999936404
2 28828 999948995
2 34046 999960067
2 2...

output:

456413

result:

ok single line: '456413'

Test #40:

score: 0
Accepted
time: 41ms
memory: 5220kb

input:

1
100000
2 34373 999964583
2 35473 999978204
2 30923 999932319
2 24823 999954671
2 33411 999973339
2 37868 999938346
2 39506 999964128
2 34108 999986810
2 26945 999931649
2 24696 999945347
2 28922 999969062
2 44528 999975541
2 37167 999973694
2 27428 999938801
2 24452 999941998
2 26101 999938140
2 3...

output:

444228797

result:

ok single line: '444228797'

Test #41:

score: 0
Accepted
time: 45ms
memory: 6452kb

input:

1
100000
2 28328 999968675
2 42646 999950341
2 27868 999966937
2 36726 999956680
2 39110 999972221
2 41886 999952232
2 36762 999958906
2 28178 999969595
2 32231 999965564
2 25310 999973531
2 38199 999939061
2 29755 999947827
2 41758 999917953
2 24735 999947146
2 27878 999948752
2 26730 999958392
2 3...

output:

322811537

result:

ok single line: '322811537'

Test #42:

score: 0
Accepted
time: 37ms
memory: 5216kb

input:

1
100000
2 24673 999925973
2 26553 999968018
2 26533 999966720
2 29611 999942319
2 32744 999968085
2 28311 999952749
2 27713 999966748
2 30847 999943635
2 27765 999945574
2 31763 999976231
2 32275 999972288
2 32132 999943333
2 33363 999948579
2 40482 999962022
2 43265 999979877
2 30421 999969678
2 2...

output:

27147516

result:

ok single line: '27147516'

Extra Test:

score: 0
Extra Test Passed