QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113111#1147. Wallmyee100 ✓558ms213988kbC++114.0kb2023-06-16 14:39:142023-06-16 14:39:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-16 14:39:16]
  • 评测
  • 测评结果:100
  • 用时:558ms
  • 内存:213988kb
  • [2023-06-16 14:39:14]
  • 提交

answer

#include "wall.h"
#include <algorithm>
#include <stdio.h>
#include <vector>

namespace
{

typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}

struct Seg
{
    Seg*L,*R;uint len,maxv,maxv2,minv,minv2;
    Seg(uint n):L(NULL),R(NULL),len(n),maxv(0),maxv2(0),minv(0),minv2(100000)
    {
        if(n>1)L=new Seg(n>>1),R=new Seg(n-(n>>1));
    }
#ifdef MYEE
    ~Seg(){if(len>1){delete L;delete R;}}
#endif
    voi Min(uint l,uint r,uint w)
    {
        if(l>=r||w>=maxv)return;
        if(!l&&r==len)
        {
            if(w<=minv){minv=maxv=w,minv2=1e5,maxv2=0;return;}
            if(w>=maxv2){maxv=w,_min(minv2,w);return;}
        }
        if(minv==maxv)L->minv=L->maxv=R->minv=R->maxv=minv,L->minv2=R->minv2=1e5,L->maxv2=R->maxv2=0;
        else
            _min(L->maxv,maxv),_min(R->maxv,maxv),_min(L->minv2,maxv),_min(R->minv2,maxv),
            _max(L->minv,minv),_max(R->minv,minv),_max(L->maxv2,minv),_max(R->maxv2,minv);
        if(l<(len>>1))
            if(r<=(len>>1))L->Min(l,r,w);
            else L->Min(l,len>>1,w),R->Min(0,r-(len>>1),w);
        else R->Min(l-(len>>1),r-(len>>1),w);
        minv=std::min(L->minv,R->minv),maxv=std::max(L->maxv,R->maxv),minv2=1e5,maxv2=0;
        _min(minv2,minv==L->minv?L->minv:L->minv2),_min(minv2,minv==R->minv?R->minv:R->minv2);
        _max(maxv2,maxv==L->maxv?L->maxv:L->maxv2),_max(maxv2,maxv==R->maxv?R->maxv:R->maxv2);
    }
    voi Max(uint l,uint r,uint w)
    {
        if(l>=r||w<=minv)return;
        if(!l&&r==len)
        {
            if(w>=maxv){minv=maxv=w,minv2=1e5,maxv2=0;return;}
            if(w<=minv2){minv=w,_max(maxv2,w);return;}
        }
        if(minv==maxv)L->minv=L->maxv=R->minv=R->maxv=minv,L->minv2=R->minv2=1e5,L->maxv2=R->maxv2=0;
        else
            _min(L->maxv,maxv),_min(R->maxv,maxv),_min(L->minv2,maxv),_min(R->minv2,maxv),
            _max(L->minv,minv),_max(R->minv,minv),_max(L->maxv2,minv),_max(R->maxv2,minv);
        if(l<(len>>1))
            if(r<=(len>>1))L->Max(l,r,w);
            else L->Max(l,len>>1,w),R->Max(0,r-(len>>1),w);
        else R->Max(l-(len>>1),r-(len>>1),w);
        minv=std::min(L->minv,R->minv),maxv=std::max(L->maxv,R->maxv),minv2=1e5,maxv2=0;
        _min(minv2,minv==L->minv?L->minv:L->minv2),_min(minv2,minv==R->minv?R->minv:R->minv2);
        _max(maxv2,maxv==L->maxv?L->maxv:L->maxv2),_max(maxv2,maxv==R->maxv?R->maxv:R->maxv2);
    }
    voi solve(std::vector<uint>&V)
    {
        if(len==1){V.push_back(minv);return;}
        if(minv==maxv)L->minv=L->maxv=R->minv=R->maxv=minv,L->minv2=R->minv2=1e5,L->maxv2=R->maxv2=0;
        else
            _min(L->maxv,maxv),_min(R->maxv,maxv),_min(L->minv2,maxv),_min(R->minv2,maxv),
            _max(L->minv,minv),_max(R->minv,minv),_max(L->maxv2,minv),_max(R->maxv2,minv);
        L->solve(V),R->solve(V);
    }
};

}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    Seg S(n);
    for(int i=0;i<k;i++)
        if(op[i]==1)
            S.Max(left[i],right[i]+1,height[i]);
        else
            S.Min(left[i],right[i]+1,height[i]);
    std::vector<uint>V;S.solve(V);
    for(int i=0;i<n;i++)
        finalHeight[i]=V[i];
}

/*

g++ 25.cpp grader.cpp -o code -std=c++14 -DMYEE -Wall -fsanitize=undefined

time ./code

*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 3056kb

input:

1 1
1 0 0 79348

output:

79348

result:

ok single line: '79348'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3136kb

input:

1 5000
2 0 0 91858
1 0 0 85391
2 0 0 5015
1 0 0 41611
1 0 0 42982
1 0 0 70801
1 0 0 14431
2 0 0 14050
2 0 0 70240
2 0 0 84517
1 0 0 42618
1 0 0 92678
1 0 0 63376
1 0 0 36582
2 0 0 39214
2 0 0 22581
2 0 0 10970
1 0 0 67580
2 0 0 44016
2 0 0 12053
1 0 0 42450
1 0 0 12995
2 0 0 71888
2 0 0 29992
2 0 0 ...

output:

18711

result:

ok single line: '18711'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3104kb

input:

267 1952
1 30 144 71757
1 170 257 86481
2 112 115 42915
2 11 144 6908
1 141 161 3819
1 91 126 47581
1 107 149 6466
2 81 204 50010
1 9 103 77557
2 115 202 42541
2 199 230 18052
2 98 230 553
1 125 235 36745
2 59 114 71005
1 18 65 78224
2 24 52 21249
1 16 84 47198
1 131 207 81016
2 162 263 21662
1 8 24...

output:

58284
58284
60534
58284
83411
83411
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
...

result:

ok 267 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 4320kb

input:

10000 5000
1 2237 2818 16629
2 3559 7378 25221
2 5353 6596 18247
2 7 8525 7339
2 7753 9730 78256
2 6301 8598 74433
1 5372 6260 23526
2 8231 9732 89822
2 1050 6451 41238
1 6362 6459 90393
2 1812 4993 90638
2 3518 4329 88017
2 412 6273 45512
1 6297 8927 87237
2 763 8022 2387
1 8561 8995 32427
2 1364 3...

output:

0
0
8060
8060
8060
8060
8060
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
9...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 5ms
memory: 4216kb

input:

10000 5000
1 3 9999 99990
2 3 9998 6
1 4 9997 99982
2 4 9997 15
1 5 9996 99978
2 5 9993 24
1 5 9991 99974
2 8 9989 29
1 10 9989 99973
2 12 9989 44
1 13 9986 99961
2 16 9986 62
1 18 9985 99951
2 18 9982 78
1 19 9981 99950
1 19 9981 99937
2 20 9981 92
1 20 9981 99929
2 23 9978 98
1 23 9975 99917
2 23 ...

output:

0
0
0
6
15
99974
99974
99974
29
29
99973
99973
44
99961
99961
99961
62
62
78
99950
99929
99929
99929
98
98
99916
99916
99916
99916
99916
130
130
99904
99904
140
140
152
99894
99894
99894
166
166
166
99887
99887
99887
168
168
99877
99877
178
178
178
99863
193
193
99853
205
99852
99852
99852
99843
998...

result:

ok 10000 lines

Test #6:

score: 0
Accepted
time: 5ms
memory: 4216kb

input:

10000 5000
1 2 9997 99990
2 5 9996 0
1 8 9996 99981
1 11 9995 99976
2 14 9995 6
1 15 9995 99973
2 15 9995 16
1 18 9993 99964
2 18 9991 29
2 21 9990 39
1 22 9987 99960
2 22 9984 40
1 25 9983 99947
2 26 9982 50
1 27 9982 99934
2 30 9982 54
1 32 9979 99931
2 33 9977 55
1 35 9974 99928
2 37 9972 69
1 40...

output:

0
0
99990
99990
99990
0
0
0
99981
99981
99981
99981
99981
99981
6
16
16
16
29
29
29
29
40
40
40
99947
50
99934
99934
99934
54
54
99931
55
55
99928
99928
69
69
69
99913
99913
99913
99913
99913
99913
71
71
71
99896
99896
99896
82
98
98
98
99885
99885
99885
118
118
118
99876
99876
118
118
118
99868
998...

result:

ok 10000 lines

Subtask #2:

score: 24
Accepted

Test #7:

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

input:

1 1
1 0 0 51569

output:

51569

result:

ok single line: '51569'

Test #8:

score: 0
Accepted
time: 67ms
memory: 10864kb

input:

1 500000
1 0 0 92201
1 0 0 88187
1 0 0 78173
1 0 0 57498
1 0 0 95946
1 0 0 72895
1 0 0 46122
1 0 0 67752
1 0 0 45557
1 0 0 46888
1 0 0 84250
1 0 0 24947
1 0 0 30575
1 0 0 54171
1 0 0 80874
1 0 0 81939
1 0 0 88805
1 0 0 71685
1 0 0 28774
1 0 0 33813
1 0 0 41164
1 0 0 78447
1 0 0 85126
1 0 0 30919
1 0...

output:

1

result:

ok single line: '1'

Test #9:

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

input:

18190 207265
1 1435 13396 14900
1 6250 8319 35530
1 7963 12194 50416
1 8286 12081 65629
1 11253 17172 87794
1 9886 16510 63411
1 2728 11446 61035
1 14426 17678 41533
1 2545 7233 6656
1 2158 8796 66853
1 10860 14353 55751
1 4751 14591 72745
1 6971 7654 82848
1 5292 15990 14033
1 10090 16771 27152
1 4...

output:

15148
15148
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
...

result:

ok 18190 lines

Test #10:

score: 0
Accepted
time: 98ms
memory: 20848kb

input:

100000 500000
1 16546 96152 61778
1 65633 84347 81918
1 1167 33153 33889
1 14638 68983 49183
1 77051 89744 25931
1 45554 54937 92578
1 2701 86999 44372
1 42630 54711 86636
1 64766 75528 57550
1 46752 55820 25508
1 56987 75749 15422
1 44733 80957 83290
1 25573 58009 56972
1 49550 96862 72047
1 16419 ...

output:

636
232
232
232
232
232
232
232
232
232
232
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
4...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 109ms
memory: 20812kb

input:

100000 500000
1 2 99997 100000
1 4 99994 100000
1 6 99993 100000
1 7 99992 100000
1 10 99991 100000
1 11 99991 100000
1 13 99988 100000
1 16 99987 100000
1 17 99985 100000
1 20 99983 100000
1 20 99983 100000
1 23 99981 100000
1 24 99980 100000
1 26 99978 100000
1 27 99977 100000
1 29 99974 100000
1 ...

output:

0
0
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
10...

result:

ok 100000 lines

Test #12:

score: 0
Accepted
time: 132ms
memory: 20780kb

input:

100000 500000
1 0 99997 100000
1 3 99996 100000
1 6 99993 100000
1 8 99993 100000
1 11 99993 100000
1 14 99992 100000
1 16 99992 100000
1 17 99990 100000
1 19 99988 100000
1 22 99988 100000
1 23 99988 100000
1 26 99985 100000
1 26 99983 100000
1 26 99983 100000
1 29 99980 100000
1 30 99977 100000
1 ...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 100000 lines

Subtask #3:

score: 29
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #13:

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

input:

1 1
1 0 0 79348

output:

79348

result:

ok single line: '79348'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3132kb

input:

1 5000
2 0 0 91858
1 0 0 85391
2 0 0 5015
1 0 0 41611
1 0 0 42982
1 0 0 70801
1 0 0 14431
2 0 0 14050
2 0 0 70240
2 0 0 84517
1 0 0 42618
1 0 0 92678
1 0 0 63376
1 0 0 36582
2 0 0 39214
2 0 0 22581
2 0 0 10970
1 0 0 67580
2 0 0 44016
2 0 0 12053
1 0 0 42450
1 0 0 12995
2 0 0 71888
2 0 0 29992
2 0 0 ...

output:

18711

result:

ok single line: '18711'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3272kb

input:

267 1952
1 30 144 71757
1 170 257 86481
2 112 115 42915
2 11 144 6908
1 141 161 3819
1 91 126 47581
1 107 149 6466
2 81 204 50010
1 9 103 77557
2 115 202 42541
2 199 230 18052
2 98 230 553
1 125 235 36745
2 59 114 71005
1 18 65 78224
2 24 52 21249
1 16 84 47198
1 131 207 81016
2 162 263 21662
1 8 24...

output:

58284
58284
60534
58284
83411
83411
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
...

result:

ok 267 lines

Test #16:

score: 0
Accepted
time: 5ms
memory: 4284kb

input:

10000 5000
1 2237 2818 16629
2 3559 7378 25221
2 5353 6596 18247
2 7 8525 7339
2 7753 9730 78256
2 6301 8598 74433
1 5372 6260 23526
2 8231 9732 89822
2 1050 6451 41238
1 6362 6459 90393
2 1812 4993 90638
2 3518 4329 88017
2 412 6273 45512
1 6297 8927 87237
2 763 8022 2387
1 8561 8995 32427
2 1364 3...

output:

0
0
8060
8060
8060
8060
8060
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
9...

result:

ok 10000 lines

Test #17:

score: 0
Accepted
time: 5ms
memory: 4216kb

input:

10000 5000
1 3 9999 99990
2 3 9998 6
1 4 9997 99982
2 4 9997 15
1 5 9996 99978
2 5 9993 24
1 5 9991 99974
2 8 9989 29
1 10 9989 99973
2 12 9989 44
1 13 9986 99961
2 16 9986 62
1 18 9985 99951
2 18 9982 78
1 19 9981 99950
1 19 9981 99937
2 20 9981 92
1 20 9981 99929
2 23 9978 98
1 23 9975 99917
2 23 ...

output:

0
0
0
6
15
99974
99974
99974
29
29
99973
99973
44
99961
99961
99961
62
62
78
99950
99929
99929
99929
98
98
99916
99916
99916
99916
99916
130
130
99904
99904
140
140
152
99894
99894
99894
166
166
166
99887
99887
99887
168
168
99877
99877
178
178
178
99863
193
193
99853
205
99852
99852
99852
99843
998...

result:

ok 10000 lines

Test #18:

score: 0
Accepted
time: 2ms
memory: 4212kb

input:

10000 5000
1 2 9997 99990
2 5 9996 0
1 8 9996 99981
1 11 9995 99976
2 14 9995 6
1 15 9995 99973
2 15 9995 16
1 18 9993 99964
2 18 9991 29
2 21 9990 39
1 22 9987 99960
2 22 9984 40
1 25 9983 99947
2 26 9982 50
1 27 9982 99934
2 30 9982 54
1 32 9979 99931
2 33 9977 55
1 35 9974 99928
2 37 9972 69
1 40...

output:

0
0
99990
99990
99990
0
0
0
99981
99981
99981
99981
99981
99981
6
16
16
16
29
29
29
29
40
40
40
99947
50
99934
99934
99934
54
54
99931
55
55
99928
99928
69
69
69
99913
99913
99913
99913
99913
99913
71
71
71
99896
99896
99896
82
98
98
98
99885
99885
99885
118
118
118
99876
99876
118
118
118
99868
998...

result:

ok 10000 lines

Test #19:

score: 0
Accepted
time: 1ms
memory: 3044kb

input:

1 1
1 0 0 51569

output:

51569

result:

ok single line: '51569'

Test #20:

score: 0
Accepted
time: 81ms
memory: 11036kb

input:

1 500000
1 0 0 92201
1 0 0 88187
1 0 0 78173
1 0 0 57498
1 0 0 95946
1 0 0 72895
1 0 0 46122
1 0 0 67752
1 0 0 45557
1 0 0 46888
1 0 0 84250
1 0 0 24947
1 0 0 30575
1 0 0 54171
1 0 0 80874
1 0 0 81939
1 0 0 88805
1 0 0 71685
1 0 0 28774
1 0 0 33813
1 0 0 41164
1 0 0 78447
1 0 0 85126
1 0 0 30919
1 0...

output:

1

result:

ok single line: '1'

Test #21:

score: 0
Accepted
time: 35ms
memory: 8192kb

input:

18190 207265
1 1435 13396 14900
1 6250 8319 35530
1 7963 12194 50416
1 8286 12081 65629
1 11253 17172 87794
1 9886 16510 63411
1 2728 11446 61035
1 14426 17678 41533
1 2545 7233 6656
1 2158 8796 66853
1 10860 14353 55751
1 4751 14591 72745
1 6971 7654 82848
1 5292 15990 14033
1 10090 16771 27152
1 4...

output:

15148
15148
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
...

result:

ok 18190 lines

Test #22:

score: 0
Accepted
time: 94ms
memory: 20760kb

input:

100000 500000
1 16546 96152 61778
1 65633 84347 81918
1 1167 33153 33889
1 14638 68983 49183
1 77051 89744 25931
1 45554 54937 92578
1 2701 86999 44372
1 42630 54711 86636
1 64766 75528 57550
1 46752 55820 25508
1 56987 75749 15422
1 44733 80957 83290
1 25573 58009 56972
1 49550 96862 72047
1 16419 ...

output:

636
232
232
232
232
232
232
232
232
232
232
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
4...

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 122ms
memory: 20828kb

input:

100000 500000
1 2 99997 100000
1 4 99994 100000
1 6 99993 100000
1 7 99992 100000
1 10 99991 100000
1 11 99991 100000
1 13 99988 100000
1 16 99987 100000
1 17 99985 100000
1 20 99983 100000
1 20 99983 100000
1 23 99981 100000
1 24 99980 100000
1 26 99978 100000
1 27 99977 100000
1 29 99974 100000
1 ...

output:

0
0
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
10...

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 131ms
memory: 20840kb

input:

100000 500000
1 0 99997 100000
1 3 99996 100000
1 6 99993 100000
1 8 99993 100000
1 11 99993 100000
1 14 99992 100000
1 16 99992 100000
1 17 99990 100000
1 19 99988 100000
1 22 99988 100000
1 23 99988 100000
1 26 99985 100000
1 26 99983 100000
1 26 99983 100000
1 29 99980 100000
1 30 99977 100000
1 ...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 1ms
memory: 3068kb

input:

1 1
1 0 0 4719

output:

4719

result:

ok single line: '4719'

Test #26:

score: 0
Accepted
time: 75ms
memory: 10868kb

input:

1 500000
1 0 0 55481
1 0 0 92979
2 0 0 79781
1 0 0 91391
1 0 0 98238
2 0 0 17132
1 0 0 37636
1 0 0 7121
1 0 0 15782
1 0 0 64195
1 0 0 59318
2 0 0 2493
2 0 0 2262
2 0 0 90591
1 0 0 64302
1 0 0 34806
2 0 0 31751
2 0 0 61399
2 0 0 86192
1 0 0 93148
1 0 0 16725
2 0 0 44879
2 0 0 82899
1 0 0 94553
2 0 0 ...

output:

86546

result:

ok single line: '86546'

Test #27:

score: 0
Accepted
time: 22ms
memory: 5344kb

input:

17168 31002
2 5443 13859 61179
2 5505 5804 60527
2 5392 10724 28703
2 4226 10887 32391
1 11308 16210 76159
1 4422 8867 66570
2 7712 16918 5602
2 2540 9683 16846
2 6930 9200 32688
2 5534 8325 26802
2 10016 11850 59762
1 3735 4887 46078
2 3929 13469 22330
2 2468 10692 32006
1 10181 17006 47665
1 93 23...

output:

70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
...

result:

ok 17168 lines

Test #28:

score: 0
Accepted
time: 377ms
memory: 20784kb

input:

100000 500000
1 62275 77351 65567
2 79134 79565 4314
2 15876 50734 88757
2 32271 39699 66618
1 45673 81534 85890
1 4949 99954 72652
2 10739 24444 97753
2 65880 93772 53515
2 19082 56048 98008
2 2322 98217 11326
2 16436 34551 75432
1 58402 72487 44114
2 39936 46357 41463
2 30468 46311 36118
1 50224 5...

output:

58097
58097
72831
72831
79787
77957
75236
75236
72831
72831
72831
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938...

result:

ok 100000 lines

Test #29:

score: 0
Accepted
time: 184ms
memory: 20816kb

input:

100000 500000
1 3 99996 100000
2 6 99993 0
1 7 99990 100000
2 9 99987 0
1 12 99984 100000
2 15 99981 0
1 18 99981 100000
2 19 99979 0
2 20 99977 0
1 21 99975 100000
2 23 99973 0
1 24 99971 100000
2 26 99970 0
1 26 99967 100000
2 29 99967 0
2 31 99965 0
1 31 99964 100000
2 34 99962 0
1 34 99959 10000...

output:

0
0
0
100000
100000
100000
0
100000
100000
0
0
0
100000
100000
100000
0
0
0
100000
0
0
100000
100000
0
100000
100000
100000
100000
100000
0
0
100000
100000
100000
100000
0
0
100000
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
100000
100000
0
100000
100000
0
100000
0
0
0
100000
0
0
0
0
0
...

result:

ok 100000 lines

Test #30:

score: 0
Accepted
time: 198ms
memory: 20760kb

input:

100000 500000
1 2 99997 100000
2 2 99995 0
2 5 99995 0
1 6 99992 100000
2 8 99991 0
1 11 99989 100000
2 13 99988 0
1 15 99985 100000
2 16 99983 0
1 17 99980 100000
2 20 99978 0
1 21 99977 100000
2 24 99977 0
1 26 99975 100000
2 26 99973 0
1 27 99972 100000
2 30 99972 0
2 33 99972 0
1 35 99972 100000...

output:

0
0
0
0
0
0
100000
100000
0
0
0
100000
100000
0
0
100000
0
100000
100000
100000
0
100000
100000
100000
0
0
0
100000
100000
100000
0
0
0
0
0
100000
0
0
0
100000
100000
100000
100000
0
0
0
0
100000
0
100000
0
0
100000
100000
100000
100000
100000
100000
100000
100000
0
0
100000
100000
0
0
0
100000
1000...

result:

ok 100000 lines

Subtask #4:

score: 39
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #31:

score: 39
Accepted
time: 1ms
memory: 3056kb

input:

1 1
1 0 0 79348

output:

79348

result:

ok single line: '79348'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3136kb

input:

1 5000
2 0 0 91858
1 0 0 85391
2 0 0 5015
1 0 0 41611
1 0 0 42982
1 0 0 70801
1 0 0 14431
2 0 0 14050
2 0 0 70240
2 0 0 84517
1 0 0 42618
1 0 0 92678
1 0 0 63376
1 0 0 36582
2 0 0 39214
2 0 0 22581
2 0 0 10970
1 0 0 67580
2 0 0 44016
2 0 0 12053
1 0 0 42450
1 0 0 12995
2 0 0 71888
2 0 0 29992
2 0 0 ...

output:

18711

result:

ok single line: '18711'

Test #33:

score: 0
Accepted
time: 1ms
memory: 3268kb

input:

267 1952
1 30 144 71757
1 170 257 86481
2 112 115 42915
2 11 144 6908
1 141 161 3819
1 91 126 47581
1 107 149 6466
2 81 204 50010
1 9 103 77557
2 115 202 42541
2 199 230 18052
2 98 230 553
1 125 235 36745
2 59 114 71005
1 18 65 78224
2 24 52 21249
1 16 84 47198
1 131 207 81016
2 162 263 21662
1 8 24...

output:

58284
58284
60534
58284
83411
83411
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
34807
...

result:

ok 267 lines

Test #34:

score: 0
Accepted
time: 2ms
memory: 4320kb

input:

10000 5000
1 2237 2818 16629
2 3559 7378 25221
2 5353 6596 18247
2 7 8525 7339
2 7753 9730 78256
2 6301 8598 74433
1 5372 6260 23526
2 8231 9732 89822
2 1050 6451 41238
1 6362 6459 90393
2 1812 4993 90638
2 3518 4329 88017
2 412 6273 45512
1 6297 8927 87237
2 763 8022 2387
1 8561 8995 32427
2 1364 3...

output:

0
0
8060
8060
8060
8060
8060
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
9...

result:

ok 10000 lines

Test #35:

score: 0
Accepted
time: 5ms
memory: 4272kb

input:

10000 5000
1 3 9999 99990
2 3 9998 6
1 4 9997 99982
2 4 9997 15
1 5 9996 99978
2 5 9993 24
1 5 9991 99974
2 8 9989 29
1 10 9989 99973
2 12 9989 44
1 13 9986 99961
2 16 9986 62
1 18 9985 99951
2 18 9982 78
1 19 9981 99950
1 19 9981 99937
2 20 9981 92
1 20 9981 99929
2 23 9978 98
1 23 9975 99917
2 23 ...

output:

0
0
0
6
15
99974
99974
99974
29
29
99973
99973
44
99961
99961
99961
62
62
78
99950
99929
99929
99929
98
98
99916
99916
99916
99916
99916
130
130
99904
99904
140
140
152
99894
99894
99894
166
166
166
99887
99887
99887
168
168
99877
99877
178
178
178
99863
193
193
99853
205
99852
99852
99852
99843
998...

result:

ok 10000 lines

Test #36:

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

input:

10000 5000
1 2 9997 99990
2 5 9996 0
1 8 9996 99981
1 11 9995 99976
2 14 9995 6
1 15 9995 99973
2 15 9995 16
1 18 9993 99964
2 18 9991 29
2 21 9990 39
1 22 9987 99960
2 22 9984 40
1 25 9983 99947
2 26 9982 50
1 27 9982 99934
2 30 9982 54
1 32 9979 99931
2 33 9977 55
1 35 9974 99928
2 37 9972 69
1 40...

output:

0
0
99990
99990
99990
0
0
0
99981
99981
99981
99981
99981
99981
6
16
16
16
29
29
29
29
40
40
40
99947
50
99934
99934
99934
54
54
99931
55
55
99928
99928
69
69
69
99913
99913
99913
99913
99913
99913
71
71
71
99896
99896
99896
82
98
98
98
99885
99885
99885
118
118
118
99876
99876
118
118
118
99868
998...

result:

ok 10000 lines

Test #37:

score: 0
Accepted
time: 0ms
memory: 3036kb

input:

1 1
1 0 0 51569

output:

51569

result:

ok single line: '51569'

Test #38:

score: 0
Accepted
time: 76ms
memory: 10936kb

input:

1 500000
1 0 0 92201
1 0 0 88187
1 0 0 78173
1 0 0 57498
1 0 0 95946
1 0 0 72895
1 0 0 46122
1 0 0 67752
1 0 0 45557
1 0 0 46888
1 0 0 84250
1 0 0 24947
1 0 0 30575
1 0 0 54171
1 0 0 80874
1 0 0 81939
1 0 0 88805
1 0 0 71685
1 0 0 28774
1 0 0 33813
1 0 0 41164
1 0 0 78447
1 0 0 85126
1 0 0 30919
1 0...

output:

1

result:

ok single line: '1'

Test #39:

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

input:

18190 207265
1 1435 13396 14900
1 6250 8319 35530
1 7963 12194 50416
1 8286 12081 65629
1 11253 17172 87794
1 9886 16510 63411
1 2728 11446 61035
1 14426 17678 41533
1 2545 7233 6656
1 2158 8796 66853
1 10860 14353 55751
1 4751 14591 72745
1 6971 7654 82848
1 5292 15990 14033
1 10090 16771 27152
1 4...

output:

15148
15148
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
840
...

result:

ok 18190 lines

Test #40:

score: 0
Accepted
time: 98ms
memory: 20764kb

input:

100000 500000
1 16546 96152 61778
1 65633 84347 81918
1 1167 33153 33889
1 14638 68983 49183
1 77051 89744 25931
1 45554 54937 92578
1 2701 86999 44372
1 42630 54711 86636
1 64766 75528 57550
1 46752 55820 25508
1 56987 75749 15422
1 44733 80957 83290
1 25573 58009 56972
1 49550 96862 72047
1 16419 ...

output:

636
232
232
232
232
232
232
232
232
232
232
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
43
4...

result:

ok 100000 lines

Test #41:

score: 0
Accepted
time: 86ms
memory: 20932kb

input:

100000 500000
1 2 99997 100000
1 4 99994 100000
1 6 99993 100000
1 7 99992 100000
1 10 99991 100000
1 11 99991 100000
1 13 99988 100000
1 16 99987 100000
1 17 99985 100000
1 20 99983 100000
1 20 99983 100000
1 23 99981 100000
1 24 99980 100000
1 26 99978 100000
1 27 99977 100000
1 29 99974 100000
1 ...

output:

0
0
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
10...

result:

ok 100000 lines

Test #42:

score: 0
Accepted
time: 116ms
memory: 20768kb

input:

100000 500000
1 0 99997 100000
1 3 99996 100000
1 6 99993 100000
1 8 99993 100000
1 11 99993 100000
1 14 99992 100000
1 16 99992 100000
1 17 99990 100000
1 19 99988 100000
1 22 99988 100000
1 23 99988 100000
1 26 99985 100000
1 26 99983 100000
1 26 99983 100000
1 29 99980 100000
1 30 99977 100000
1 ...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 100000 lines

Test #43:

score: 0
Accepted
time: 0ms
memory: 3044kb

input:

1 1
1 0 0 4719

output:

4719

result:

ok single line: '4719'

Test #44:

score: 0
Accepted
time: 92ms
memory: 10864kb

input:

1 500000
1 0 0 55481
1 0 0 92979
2 0 0 79781
1 0 0 91391
1 0 0 98238
2 0 0 17132
1 0 0 37636
1 0 0 7121
1 0 0 15782
1 0 0 64195
1 0 0 59318
2 0 0 2493
2 0 0 2262
2 0 0 90591
1 0 0 64302
1 0 0 34806
2 0 0 31751
2 0 0 61399
2 0 0 86192
1 0 0 93148
1 0 0 16725
2 0 0 44879
2 0 0 82899
1 0 0 94553
2 0 0 ...

output:

86546

result:

ok single line: '86546'

Test #45:

score: 0
Accepted
time: 20ms
memory: 5356kb

input:

17168 31002
2 5443 13859 61179
2 5505 5804 60527
2 5392 10724 28703
2 4226 10887 32391
1 11308 16210 76159
1 4422 8867 66570
2 7712 16918 5602
2 2540 9683 16846
2 6930 9200 32688
2 5534 8325 26802
2 10016 11850 59762
1 3735 4887 46078
2 3929 13469 22330
2 2468 10692 32006
1 10181 17006 47665
1 93 23...

output:

70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
70569
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
48160
...

result:

ok 17168 lines

Test #46:

score: 0
Accepted
time: 386ms
memory: 20936kb

input:

100000 500000
1 62275 77351 65567
2 79134 79565 4314
2 15876 50734 88757
2 32271 39699 66618
1 45673 81534 85890
1 4949 99954 72652
2 10739 24444 97753
2 65880 93772 53515
2 19082 56048 98008
2 2322 98217 11326
2 16436 34551 75432
1 58402 72487 44114
2 39936 46357 41463
2 30468 46311 36118
1 50224 5...

output:

58097
58097
72831
72831
79787
77957
75236
75236
72831
72831
72831
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938
7938...

result:

ok 100000 lines

Test #47:

score: 0
Accepted
time: 210ms
memory: 20764kb

input:

100000 500000
1 3 99996 100000
2 6 99993 0
1 7 99990 100000
2 9 99987 0
1 12 99984 100000
2 15 99981 0
1 18 99981 100000
2 19 99979 0
2 20 99977 0
1 21 99975 100000
2 23 99973 0
1 24 99971 100000
2 26 99970 0
1 26 99967 100000
2 29 99967 0
2 31 99965 0
1 31 99964 100000
2 34 99962 0
1 34 99959 10000...

output:

0
0
0
100000
100000
100000
0
100000
100000
0
0
0
100000
100000
100000
0
0
0
100000
0
0
100000
100000
0
100000
100000
100000
100000
100000
0
0
100000
100000
100000
100000
0
0
100000
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
100000
100000
0
100000
100000
0
100000
0
0
0
100000
0
0
0
0
0
...

result:

ok 100000 lines

Test #48:

score: 0
Accepted
time: 190ms
memory: 20756kb

input:

100000 500000
1 2 99997 100000
2 2 99995 0
2 5 99995 0
1 6 99992 100000
2 8 99991 0
1 11 99989 100000
2 13 99988 0
1 15 99985 100000
2 16 99983 0
1 17 99980 100000
2 20 99978 0
1 21 99977 100000
2 24 99977 0
1 26 99975 100000
2 26 99973 0
1 27 99972 100000
2 30 99972 0
2 33 99972 0
1 35 99972 100000...

output:

0
0
0
0
0
0
100000
100000
0
0
0
100000
100000
0
0
100000
0
100000
100000
100000
0
100000
100000
100000
0
0
0
100000
100000
100000
0
0
0
0
0
100000
0
0
0
100000
100000
100000
100000
0
0
0
0
100000
0
100000
0
0
100000
100000
100000
100000
100000
100000
100000
100000
0
0
100000
100000
0
0
0
100000
1000...

result:

ok 100000 lines

Test #49:

score: 0
Accepted
time: 535ms
memory: 213768kb

input:

2000000 500000
1 0 1999997 100000
2 1 1999997 0
2 4 1999995 0
1 6 1999994 100000
2 9 1999994 0
1 10 1999994 100000
2 13 1999993 0
1 14 1999990 100000
2 15 1999987 0
1 18 1999984 100000
2 20 1999983 0
1 22 1999980 100000
2 25 1999978 0
1 27 1999977 100000
2 29 1999976 0
2 29 1999975 0
1 29 1999975 10...

output:

100000
0
0
0
0
0
100000
100000
100000
0
100000
100000
100000
0
100000
0
0
0
100000
100000
0
0
100000
100000
100000
0
0
100000
100000
100000
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
0
0
100000
100000
100000
100000
0
0
0
0
0
100000
100000
100000
0
100000
100000
100000
0
0
0
100000
1000...

result:

ok 2000000 lines

Test #50:

score: 0
Accepted
time: 530ms
memory: 213636kb

input:

2000000 500000
1 0 1999997 100000
1 3 1999997 100000
2 5 1999997 0
1 8 1999996 100000
2 11 1999993 0
1 12 1999990 100000
2 14 1999987 0
1 17 1999987 100000
2 19 1999987 0
1 19 1999985 100000
2 22 1999985 0
1 23 1999984 100000
2 23 1999982 0
1 24 1999980 100000
2 25 1999977 0
1 28 1999974 100000
2 31...

output:

100000
100000
100000
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
0
0
0
100000
100000
100000
100000
100000
0
0
100000
0
0
0
100000
100000
100000
0
100000
0
0
0
100000
0
0
100000
100000
100000
0
100000
100000
100000
0
0
100000
100000
0
100000
100000
100000
0
0
0
100000
100000
100000
10000...

result:

ok 2000000 lines

Test #51:

score: 0
Accepted
time: 534ms
memory: 213624kb

input:

2000000 500000
1 1 1999996 100000
2 2 1999994 0
1 5 1999993 100000
2 5 1999993 0
1 8 1999991 100000
2 8 1999991 0
1 11 1999991 100000
2 12 1999988 0
1 15 1999987 100000
2 15 1999985 0
1 15 1999984 100000
2 16 1999981 0
1 17 1999978 100000
2 20 1999976 0
1 22 1999974 100000
2 23 1999971 0
1 23 199996...

output:

0
100000
0
0
0
0
0
0
0
0
0
100000
0
0
0
100000
0
100000
100000
100000
0
0
100000
100000
100000
100000
100000
0
0
0
100000
100000
0
0
0
0
0
100000
100000
100000
100000
100000
100000
0
0
0
0
100000
100000
0
0
0
100000
100000
100000
0
0
100000
100000
100000
0
0
0
100000
100000
100000
0
0
100000
100000
...

result:

ok 2000000 lines

Test #52:

score: 0
Accepted
time: 524ms
memory: 213576kb

input:

2000000 500000
1 0 1999999 100000
1 0 1999996 100000
2 1 1999993 0
1 3 1999993 100000
2 4 1999992 0
1 5 1999991 100000
2 8 1999989 0
1 9 1999989 100000
2 9 1999988 0
1 10 1999986 100000
2 11 1999983 0
1 14 1999981 100000
2 17 1999981 0
1 18 1999980 100000
2 21 1999980 0
1 21 1999979 100000
2 24 1999...

output:

100000
0
0
100000
0
100000
100000
100000
0
0
100000
0
0
0
100000
100000
100000
0
100000
100000
100000
100000
100000
100000
0
0
100000
0
0
0
100000
100000
0
0
100000
0
0
0
0
0
0
100000
0
0
100000
100000
100000
0
100000
100000
0
100000
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
0
0
0
100...

result:

ok 2000000 lines

Test #53:

score: 0
Accepted
time: 529ms
memory: 213988kb

input:

2000000 500000
1 0 1999998 100000
2 2 1999996 0
1 2 1999995 100000
2 3 1999994 0
1 5 1999994 100000
2 5 1999992 0
1 8 1999990 100000
2 11 1999990 0
1 12 1999990 100000
2 15 1999988 0
1 18 1999985 100000
2 18 1999985 0
1 18 1999985 100000
2 20 1999982 0
1 21 1999981 100000
2 22 1999981 0
1 22 1999980...

output:

100000
100000
100000
0
0
0
0
0
100000
100000
100000
0
100000
100000
100000
0
0
0
100000
100000
0
100000
100000
100000
100000
0
0
100000
100000
100000
0
100000
100000
100000
0
0
100000
100000
0
100000
100000
0
100000
100000
100000
0
0
0
0
100000
0
0
0
0
0
100000
100000
0
0
0
0
100000
100000
0
0
10000...

result:

ok 2000000 lines

Test #54:

score: 0
Accepted
time: 535ms
memory: 213584kb

input:

2000000 500000
1 1 1999999 100000
2 1 1999999 0
1 4 1999999 100000
2 5 1999997 0
1 7 1999995 100000
2 8 1999992 0
1 10 1999991 100000
2 12 1999989 0
1 14 1999987 100000
2 16 1999985 0
1 18 1999982 100000
2 20 1999980 0
1 20 1999979 100000
2 20 1999976 0
1 20 1999976 100000
2 23 1999974 0
1 24 199997...

output:

0
0
0
0
100000
0
0
100000
0
0
100000
100000
0
0
100000
100000
0
0
100000
100000
100000
100000
100000
0
100000
100000
100000
0
100000
0
0
100000
100000
0
0
0
100000
100000
100000
0
0
0
0
0
100000
100000
100000
100000
0
0
0
100000
0
100000
100000
0
0
0
100000
100000
100000
0
0
0
0
0
0
100000
100000
10...

result:

ok 2000000 lines

Test #55:

score: 0
Accepted
time: 494ms
memory: 213744kb

input:

2000000 500000
1 2 1999997 100000
2 4 1999994 0
1 5 1999992 100000
2 6 1999990 0
1 7 1999989 100000
2 7 1999986 0
1 10 1999986 100000
2 10 1999985 0
1 10 1999982 100000
2 12 1999982 0
1 14 1999979 100000
2 15 1999977 0
1 18 1999975 100000
2 20 1999972 0
1 20 1999970 100000
1 23 1999968 100000
2 24 1...

output:

0
0
100000
100000
0
100000
0
0
0
0
100000
100000
0
0
100000
0
0
0
100000
100000
100000
100000
100000
100000
0
0
100000
100000
0
0
100000
100000
100000
0
100000
100000
100000
100000
100000
100000
100000
100000
0
100000
100000
0
0
0
100000
100000
100000
100000
0
0
0
100000
100000
0
100000
0
0
0
100000...

result:

ok 2000000 lines

Test #56:

score: 0
Accepted
time: 539ms
memory: 213888kb

input:

2000000 500000
1 1 1999999 100000
2 1 1999999 0
1 3 1999999 100000
2 5 1999996 0
1 8 1999996 100000
2 11 1999994 0
1 12 1999993 100000
2 14 1999993 0
1 14 1999993 100000
2 14 1999992 0
1 15 1999990 100000
2 16 1999987 0
1 19 1999985 100000
2 19 1999983 0
1 22 1999983 100000
2 22 1999983 0
1 22 19999...

output:

0
0
0
100000
100000
0
0
0
100000
100000
100000
0
100000
100000
0
100000
0
0
0
0
0
0
100000
100000
100000
100000
100000
100000
0
100000
100000
100000
100000
0
100000
100000
0
0
0
100000
100000
0
100000
100000
100000
0
100000
100000
100000
100000
100000
100000
100000
100000
0
0
0
0
0
100000
0
0
0
1000...

result:

ok 2000000 lines

Test #57:

score: 0
Accepted
time: 551ms
memory: 213656kb

input:

2000000 500000
1 1 1999999 100000
2 1 1999996 0
1 3 1999996 100000
1 4 1999993 100000
2 6 1999991 0
1 6 1999989 100000
2 9 1999989 0
2 10 1999986 0
1 13 1999983 100000
1 16 1999983 100000
2 17 1999981 0
1 18 1999981 100000
2 20 1999981 0
1 22 1999980 100000
2 23 1999979 0
1 24 1999977 100000
1 26 19...

output:

0
0
0
100000
100000
100000
100000
100000
100000
0
0
0
0
100000
100000
100000
100000
0
100000
100000
0
0
100000
0
100000
100000
100000
100000
100000
0
100000
100000
100000
100000
100000
100000
0
100000
100000
100000
0
0
100000
100000
0
0
0
0
0
100000
100000
0
0
0
100000
100000
100000
0
0
0
0
100000
1...

result:

ok 2000000 lines

Test #58:

score: 0
Accepted
time: 550ms
memory: 213600kb

input:

2000000 500000
1 0 1999998 100000
2 3 1999997 0
1 3 1999996 100000
2 6 1999995 0
1 7 1999994 100000
2 10 1999991 0
1 10 1999990 100000
2 13 1999989 0
1 15 1999987 100000
2 18 1999984 0
1 18 1999984 100000
2 19 1999982 0
1 22 1999981 100000
2 23 1999979 0
1 26 1999977 100000
2 29 1999976 0
1 32 19999...

output:

100000
100000
100000
100000
100000
100000
0
100000
100000
100000
100000
100000
100000
0
0
100000
100000
100000
100000
0
0
0
100000
0
0
0
100000
100000
100000
0
0
0
100000
100000
100000
0
0
0
100000
100000
0
0
100000
0
100000
0
0
100000
100000
100000
0
0
0
0
100000
0
100000
100000
100000
0
0
100000
1...

result:

ok 2000000 lines

Test #59:

score: 0
Accepted
time: 551ms
memory: 213788kb

input:

2000000 500000
1 3 1999997 100000
2 5 1999997 0
1 6 1999995 100000
2 8 1999995 0
1 9 1999992 100000
2 10 1999992 0
1 10 1999992 100000
2 10 1999989 0
1 11 1999988 100000
2 13 1999988 0
1 15 1999985 100000
1 18 1999983 100000
1 20 1999983 100000
2 20 1999981 0
1 22 1999979 100000
2 24 1999977 0
1 24 ...

output:

0
0
0
100000
100000
0
100000
100000
0
100000
0
100000
100000
0
0
100000
100000
100000
100000
100000
0
0
100000
100000
100000
100000
100000
0
100000
0
100000
100000
100000
0
0
100000
100000
100000
0
0
0
100000
0
0
100000
100000
0
0
0
100000
0
100000
100000
100000
0
0
0
100000
100000
100000
100000
100...

result:

ok 2000000 lines

Test #60:

score: 0
Accepted
time: 558ms
memory: 213752kb

input:

2000000 500000
1 2 1999997 100000
2 5 1999997 0
1 7 1999996 100000
2 10 1999996 0
1 10 1999995 100000
2 12 1999993 0
2 13 1999990 0
1 15 1999988 100000
1 15 1999986 100000
2 17 1999985 0
1 19 1999983 100000
2 22 1999980 0
1 22 1999979 100000
2 25 1999978 0
2 25 1999977 0
1 28 1999977 100000
2 30 199...

output:

0
0
100000
100000
100000
0
0
100000
100000
100000
100000
100000
0
0
0
100000
100000
0
0
100000
100000
100000
100000
100000
100000
0
0
0
100000
100000
0
0
0
0
100000
0
100000
100000
0
0
100000
100000
100000
0
0
100000
100000
100000
0
0
0
100000
100000
100000
0
0
0
100000
100000
100000
100000
100000
1...

result:

ok 2000000 lines

Extra Test:

score: 0
Extra Test Passed