QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218774#7147. IQ TestSolitaryDream#AC ✓740ms18224kbC++172.1kb2023-10-18 18:15:002023-10-18 18:15:01

Judging History

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

  • [2023-10-18 18:15:01]
  • 评测
  • 测评结果:AC
  • 用时:740ms
  • 内存:18224kb
  • [2023-10-18 18:15:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using pii=pair<int,int>;

const int N=4e5+1e3+7;

int n,w[N][2];

int f[N][2];

struct BIT {
    int c[N];

    vector<pair<int*,int> >mod; 

    void clr(int x)
    {
        x+=N/2;
        while(x<N)
        {
            c[x]=-1e9;
            x+=x&-x;
        }
    }

    void add(int x,int v)
    {
        x+=N/2;
        while(x<N)
        {
            c[x]=max(c[x],v);
            x+=x&-x;
        }
    }

    int qry(int x)
    {
        x+=N/2;
        int ret=-1e9;
        while(x)
        {
            ret=max(ret,c[x]);
            x-=x&-x;
        }
        return ret;
    }
}T;

int ans=0;

void solve(int l,int r)
{
    if(l==r)
    {
        for(int j=0;j<2;j++)
        {
            if(w[l][j]>=0&&w[l][j]<=l-1)
                f[l][j]=max(f[l][j],1);
            ans=max(ans,f[l][j]);
        }
        return;
    }
    int mid=(l+r)>>1;
    solve(l,mid);
    vector<pii> v;
    for(int i=l;i<=r;i++)
        for(int j=0;j<2;j++)
            v.push_back({i,j});
    sort(v.begin(),v.end(),[&](const pii &a,const pii &b) {
        if(w[a.first][a.second]+(a.first<=mid)*(a.second==0)!=w[b.first][b.second]+(b.first<=mid)*(b.second==0))
            return w[a.first][a.second]+(a.first<=mid)*(a.second==0)<w[b.first][b.second]+(b.first<=mid)*(b.second==0);
        return a.first<b.first;
    });
    for(auto [p,s]:v)
    {
        if(p<=mid)
            T.add(p-w[p][s]-(s==0)+1,f[p][s]);
        else
        {
            if(w[p][s]>=0&&w[p][s]<=p-1)
                f[p][s]=max(f[p][s],T.qry(p-w[p][s])+1);
        }
    }
    for(auto [p,s]:v)
        if(p<=mid)
            T.clr(p-w[p][s]-(s==0)+1);
    solve(mid+1,r);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char ty[3];
        scanf("%s",ty);
        scanf("%d%d",&w[i][0],&w[i][1]);
        if(ty[0]=='B')
        {
            for(int j=0;j<2;j++)
                w[i][j]=i-1-w[i][j];
        }
        f[i][0]=f[i][1]=-1e9;
    }
    fill(T.c,T.c+N,-1e9);
    solve(1,n);
    printf("%d\n",ans);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
A 0 1
B 0 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

2
A 1 2
B 0 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

1
A 1 1

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

10
A 1 1
A 1 0
B 1 0
B 3 1
B 1 0
B 1 5
A 5 6
B 3 0
A 0 0
B 8 9

output:

5

result:

ok 1 number(s): "5"

Test #5:

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

input:

10
A 3 0
B 0 1
B 0 2
A 1 5
B 5 2
B 3 2
B 7 2
A 4 3
B 6 0
B 2 2

output:

6

result:

ok 1 number(s): "6"

Test #6:

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

input:

10
B 1 0
A 0 0
A 1 4
A 4 1
B 0 2
A 5 1
B 5 0
B 3 2
A 2 1
A 6 7

output:

6

result:

ok 1 number(s): "6"

Test #7:

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

input:

10
B 1 0
A 0 2
A 0 0
A 3 0
A 0 2
A 1 0
B 0 7
B 1 0
B 0 1
A 2 0

output:

6

result:

ok 1 number(s): "6"

Test #8:

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

input:

10
B 0 1
B 4 2
B 0 7
A 0 1
A 1 2
A 6 7
B 0 4
A 3 8
A 1 2
B 3 4

output:

5

result:

ok 1 number(s): "5"

Test #9:

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

input:

10
A 0 0
A 0 0
B 0 1
B 1 3
A 2 0
B 0 5
A 0 1
B 7 3
B 2 2
B 1 0

output:

6

result:

ok 1 number(s): "6"

Test #10:

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

input:

10
A 1 0
B 3 1
A 1 0
B 0 3
B 0 3
B 1 2
A 3 7
B 4 1
A 2 2
A 2 2

output:

6

result:

ok 1 number(s): "6"

Test #11:

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

input:

10
B 1 1
B 0 2
A 2 2
B 2 5
B 3 3
B 3 1
A 3 5
A 3 4
B 5 1
A 0 6

output:

5

result:

ok 1 number(s): "5"

Test #12:

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

input:

10
B 0 0
A 1 1
B 2 2
B 2 1
B 3 0
A 4 3
A 4 2
B 1 2
A 4 1
A 10 0

output:

5

result:

ok 1 number(s): "5"

Test #13:

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

input:

10
A 0 0
A 1 0
B 0 2
B 2 0
A 3 2
B 7 8
A 0 1
B 2 5
B 3 1
B 9 6

output:

6

result:

ok 1 number(s): "6"

Test #14:

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

input:

100
B 1 0
A 3 1
B 4 1
B 3 1
B 2 1
B 20 8
A 2 9
A 1 4
A 17 0
A 1 7
B 25 6
A 7 26
A 8 5
A 13 9
A 16 25
B 15 17
B 21 22
B 4 18
B 39 13
A 12 3
B 39 32
B 17 31
B 29 10
B 5 2
B 6 4
A 35 19
A 59 27
B 14 3
B 15 26
B 9 36
B 8 20
A 24 15
A 19 46
A 19 77
B 46 25
A 43 11
B 21 20
B 28 34
B 23 38
B 31 32
A 31 9
A...

output:

20

result:

ok 1 number(s): "20"

Test #15:

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

input:

100
A 0 2
A 2 0
A 3 3
A 2 17
A 3 0
A 4 1
A 5 11
B 0 6
A 2 0
B 12 7
B 20 6
A 3 2
A 16 43
A 3 14
B 5 20
B 6 7
B 30 45
A 11 32
A 12 13
B 3 19
B 36 19
B 18 44
A 4 7
A 12 26
B 32 46
A 16 18
B 43 20
B 42 47
A 7 14
B 57 30
B 24 21
B 14 31
B 37 5
B 16 7
A 28 49
B 33 72
B 51 18
A 21 60
B 7 21
B 1 7
B 2 23
A ...

output:

21

result:

ok 1 number(s): "21"

Test #16:

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

input:

100
A 0 0
B 2 1
A 2 0
B 0 4
B 4 2
B 0 9
B 6 19
A 0 25
B 1 1
B 32 3
B 29 34
A 17 3
A 21 29
A 21 17
A 9 20
B 10 9
B 7 4
A 8 20
A 13 9
A 3 6
B 5 6
A 7 5
A 17 55
A 21 13
A 0 6
A 13 58
B 4 29
B 11 42
B 3 4
A 4 28
B 13 2
A 14 47
A 6 4
B 36 57
A 8 85
B 1 1
B 10 8
A 14 22
B 37 18
B 5 5
A 9 14
B 12 13
A 3 21...

output:

21

result:

ok 1 number(s): "21"

Test #17:

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

input:

100
A 2 4
A 1 0
B 1 1
A 0 1
A 2 0
A 2 2
B 1 4
B 1 0
A 18 5
A 6 11
A 0 12
A 3 14
A 1 16
A 17 0
A 15 37
A 20 11
B 22 11
B 5 23
B 9 26
A 0 2
B 17 32
A 23 0
B 18 66
A 0 7
A 5 16
A 10 17
A 17 4
B 7 29
A 19 32
B 10 7
B 5 6
B 47 26
A 10 27
B 52 47
B 10 17
B 28 47
B 54 15
B 8 5
B 1 13
A 27 26
B 11 61
B 21 2...

output:

19

result:

ok 1 number(s): "19"

Test #18:

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

input:

100
A 0 0
B 1 2
A 1 3
B 6 14
B 2 0
A 5 0
A 10 10
A 6 5
A 3 19
A 0 26
A 4 6
A 3 5
A 1 6
B 14 5
B 2 21
A 2 13
B 17 6
B 2 39
A 12 20
B 9 13
B 22 46
B 20 15
A 18 15
A 3 8
B 26 0
B 10 6
B 14 5
B 21 34
A 28 26
A 0 26
B 18 6
A 11 27
B 15 11
B 8 0
B 19 12
A 47 14
B 31 13
B 1 0
B 17 36
A 41 1
A 14 18
A 21 80...

output:

22

result:

ok 1 number(s): "22"

Test #19:

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

input:

100
B 0 0
B 0 0
A 0 11
A 3 3
A 2 1
B 9 2
A 16 10
B 3 0
B 0 10
B 12 6
A 3 5
A 9 11
A 3 13
B 14 2
A 0 4
A 1 21
B 8 18
A 11 30
B 40 12
B 9 13
A 22 25
B 10 15
B 15 6
B 0 25
A 14 8
B 38 47
B 2 11
B 50 18
B 1 13
A 7 27
B 16 14
B 16 8
A 9 25
B 53 7
A 15 9
A 56 4
A 8 1
A 56 30
B 7 63
B 49 44
B 30 4
A 44 10
...

output:

25

result:

ok 1 number(s): "25"

Test #20:

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

input:

100
B 0 0
A 0 3
B 0 1
B 1 1
B 4 2
A 1 4
B 3 3
B 2 36
A 22 3
B 14 6
B 5 26
B 20 5
B 7 6
B 3 1
B 9 22
A 45 6
B 20 48
A 16 41
B 1 1
A 8 1
A 2 4
B 28 4
B 12 5
B 9 3
A 30 0
B 19 5
A 60 10
B 2 2
A 24 13
B 57 0
A 14 18
A 5 7
A 24 12
B 13 21
A 1 28
A 6 15
A 51 9
A 11 25
B 31 15
B 2 20
A 4 23
A 41 46
B 48 6
...

output:

25

result:

ok 1 number(s): "25"

Test #21:

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

input:

100
B 1 0
B 0 0
A 10 2
A 0 13
B 0 7
B 0 8
B 4 2
A 14 6
A 3 0
A 4 6
B 1 0
B 9 0
B 4 1
B 5 5
B 22 1
B 32 7
B 38 2
B 14 20
A 1 16
B 24 20
A 5 18
A 7 23
A 12 18
B 18 0
B 15 5
B 34 3
A 12 19
B 23 49
B 30 62
A 5 22
A 12 2
B 10 19
B 29 33
A 34 41
B 11 5
A 33 14
A 10 8
B 33 20
B 21 45
B 16 51
B 11 2
B 14 11...

output:

20

result:

ok 1 number(s): "20"

Test #22:

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

input:

100
B 0 1
A 0 4
A 5 7
B 12 3
A 5 11
B 2 0
A 0 2
B 0 9
B 0 5
A 7 10
B 17 8
B 20 30
B 12 11
A 2 12
A 6 18
B 18 7
B 7 7
B 20 33
B 11 11
B 11 8
A 3 27
A 12 19
B 18 3
B 21 15
B 10 1
B 13 15
B 21 15
B 65 3
A 3 19
A 43 0
A 2 11
A 3 64
A 1 9
A 33 31
B 20 32
B 8 10
A 41 6
B 5 29
B 11 3
A 28 38
B 5 4
B 29 12
...

output:

19

result:

ok 1 number(s): "19"

Test #23:

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

input:

100
A 0 0
A 3 0
A 3 10
B 0 5
A 1 7
A 0 2
B 3 24
A 3 4
B 19 23
A 8 10
A 10 1
A 2 0
B 11 5
A 29 9
B 3 5
A 28 37
B 16 6
A 21 7
A 50 20
B 20 29
A 13 35
A 19 3
A 20 1
A 16 18
A 0 16
B 55 16
A 18 2
A 5 9
B 30 36
B 9 29
A 16 39
B 38 31
A 25 3
A 38 31
A 55 17
A 20 12
A 25 75
A 21 4
B 4 10
A 42 6
A 39 22
B 4...

output:

24

result:

ok 1 number(s): "24"

Test #24:

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

input:

1000
B 0 0
B 3 0
A 1 4
B 2 1
B 6 16
A 0 6
B 3 3
B 6 4
A 13 10
A 10 15
B 14 5
A 23 7
A 4 24
A 44 6
A 22 0
A 13 10
B 12 12
B 3 5
A 14 16
B 22 0
A 14 35
B 15 28
A 20 36
B 66 25
A 1 21
B 17 34
B 13 22
A 32 4
A 0 16
A 22 59
A 10 10
B 32 61
A 1 14
B 102 20
A 15 28
A 83 41
A 46 22
B 20 45
B 20 51
B 88 38
B...

output:

74

result:

ok 1 number(s): "74"

Test #25:

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

input:

1000
A 0 0
A 1 0
A 1 7
B 3 6
A 3 3
B 0 0
A 8 7
B 5 10
B 5 1
B 3 2
A 14 1
A 17 5
B 14 4
A 3 3
A 12 2
A 24 75
A 4 42
A 5 9
B 11 4
B 3 17
B 22 18
A 5 32
B 12 3
B 3 12
A 1 12
A 4 3
B 5 33
A 1 40
A 0 9
B 17 37
A 5 20
B 0 98
B 29 35
B 63 149
B 10 4
B 19 45
A 63 7
A 31 73
A 37 19
B 41 83
B 102 1
B 26 65
A ...

output:

70

result:

ok 1 number(s): "70"

Test #26:

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

input:

1000
A 1 2
B 16 6
B 1 0
A 5 1
B 2 0
B 0 2
A 0 19
A 4 0
A 0 7
B 26 12
B 15 17
A 13 3
B 0 18
B 10 1
B 7 4
A 98 10
A 36 6
A 8 14
B 8 33
B 18 3
A 35 9
A 50 38
A 6 15
A 8 4
B 1 5
B 43 18
A 86 55
A 14 14
A 0 3
A 12 24
B 1 34
B 16 1
B 5 132
B 46 24
B 6 36
A 90 49
B 97 86
A 47 1
A 68 2
A 20 6
B 19 46
A 11 1...

output:

66

result:

ok 1 number(s): "66"

Test #27:

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

input:

1000
A 1 0
A 1 4
B 1 0
A 10 5
A 0 4
B 0 7
B 2 1
B 3 3
B 11 0
B 8 1
A 16 8
A 10 1
A 6 3
B 21 46
A 2 7
A 3 60
A 14 20
A 11 21
A 6 11
A 1 27
B 80 2
B 20 47
B 1 41
A 16 56
B 1 0
A 16 55
B 35 1
A 38 1
A 111 97
A 8 15
A 72 61
A 48 5
B 39 11
B 35 1
A 2 7
B 20 55
B 1 36
B 76 7
B 2 46
A 7 20
B 33 53
B 13 8
A...

output:

74

result:

ok 1 number(s): "74"

Test #28:

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

input:

1000
B 0 1
B 0 4
A 1 0
A 0 1
B 14 1
B 0 0
B 7 4
A 2 8
A 4 5
A 2 10
B 17 2
A 7 0
A 17 15
A 1 24
B 56 10
A 8 10
B 4 1
B 16 33
B 4 1
A 15 8
A 3 46
A 7 61
A 46 4
A 26 25
A 2 44
B 4 8
B 19 5
B 3 31
A 93 47
B 5 8
B 45 2
A 6 8
B 9 30
B 27 27
A 107 47
A 100 61
B 5 16
A 1 16
B 12 17
A 98 42
B 28 35
B 33 94
B...

output:

78

result:

ok 1 number(s): "78"

Test #29:

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

input:

1000
B 0 0
B 2 3
A 1 1
B 0 5
A 6 6
A 25 3
A 21 8
A 1 23
B 0 19
A 19 1
A 18 32
B 5 33
B 1 2
A 5 16
B 22 13
A 15 53
B 44 10
B 21 145
A 2 23
A 0 49
B 7 22
A 123 148
B 26 17
B 46 12
B 2 26
A 41 27
A 9 11
B 16 10
B 82 30
A 1 3
B 32 9
A 25 13
B 53 81
B 20 3
B 65 12
B 21 68
A 10 3
A 7 26
B 25 0
B 43 98
A 2...

output:

72

result:

ok 1 number(s): "72"

Test #30:

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

input:

1000
B 4 0
A 0 3
B 1 2
B 1 0
B 4 1
A 18 10
A 2 25
B 0 2
B 9 3
A 7 8
B 19 12
B 3 21
B 8 12
B 13 10
A 12 18
A 29 9
B 15 33
B 29 2
B 0 7
A 12 13
B 12 11
B 25 1
A 16 47
B 1 4
B 2 15
B 16 1
A 2 18
B 45 83
B 74 20
B 96 88
A 22 17
A 83 17
B 14 8
B 14 32
B 47 62
A 115 78
A 15 60
B 14 40
A 45 41
B 22 8
A 24 ...

output:

77

result:

ok 1 number(s): "77"

Test #31:

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

input:

1000
A 1 1
B 4 2
B 1 3
B 2 4
A 2 9
A 15 1
B 6 1
A 0 6
A 3 13
A 1 0
A 20 5
B 2 15
B 22 0
B 31 7
B 7 25
A 1 48
B 5 4
A 45 6
A 54 59
B 57 1
A 19 4
A 10 2
B 9 5
B 6 55
A 3 8
A 3 13
B 54 28
B 5 24
B 68 12
B 59 46
B 15 30
A 11 23
B 79 25
A 10 5
B 36 17
B 22 91
B 21 28
A 24 64
A 89 14
B 8 22
A 49 28
B 77 9...

output:

72

result:

ok 1 number(s): "72"

Test #32:

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

input:

1000
A 0 0
A 1 2
A 1 4
A 4 0
B 0 2
A 13 4
A 16 4
B 25 15
B 26 2
B 15 6
A 22 1
B 1 11
A 2 9
A 2 4
B 3 39
A 5 9
A 59 17
A 0 10
A 37 16
B 10 22
B 30 69
B 1 3
A 3 19
A 12 25
B 3 2
B 39 40
B 28 44
B 20 7
B 64 6
A 43 30
A 9 52
B 37 30
B 20 63
A 5 37
A 27 92
A 140 113
B 29 11
A 36 174
B 5 136
A 113 46
A 34...

output:

71

result:

ok 1 number(s): "71"

Test #33:

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

input:

1000
B 1 1
A 1 0
A 4 1
A 1 3
A 14 0
A 0 8
B 1 5
B 6 2
A 6 4
B 1 7
B 46 33
B 4 8
B 7 2
B 0 32
A 40 11
A 86 35
A 0 13
A 17 20
A 21 25
B 22 4
A 113 36
B 12 1
A 39 25
B 52 21
B 24 49
B 36 2
A 8 16
B 107 3
A 11 3
A 9 0
A 4 9
A 46 45
A 50 24
B 15 139
A 22 6
A 69 21
B 25 18
B 7 25
A 61 33
B 115 24
A 85 38
...

output:

69

result:

ok 1 number(s): "69"

Test #34:

score: 0
Accepted
time: 719ms
memory: 17104kb

input:

200000
A 3 1
A 3 0
B 0 3
B 5 6
B 0 10
A 14 12
A 4 12
A 0 9
A 3 14
A 13 3
A 10 3
B 55 19
B 4 29
B 12 2
B 12 0
B 1 17
A 0 17
B 12 1
A 16 17
A 9 10
A 12 55
B 38 23
A 3 6
A 14 24
A 7 186
A 25 29
A 141 14
A 35 58
B 7 4
A 11 53
B 6 97
B 0 36
A 120 33
A 21 20
A 22 15
B 39 0
B 37 40
B 26 9
B 112 55
A 62 4
A...

output:

1069

result:

ok 1 number(s): "1069"

Test #35:

score: 0
Accepted
time: 730ms
memory: 17460kb

input:

200000
A 0 0
B 3 0
B 0 6
B 0 1
A 4 2
A 1 5
A 9 6
B 3 8
A 13 22
A 2 9
A 4 18
B 26 22
B 18 3
A 8 10
B 17 57
B 14 28
A 9 1
B 19 49
B 4 49
B 61 11
A 4 21
B 46 6
A 15 11
B 5 11
A 1 1
B 0 12
A 4 9
B 12 21
A 2 11
A 5 25
A 15 23
B 4 9
B 11 18
B 0 52
A 0 34
A 42 22
A 16 12
B 40 41
B 35 7
A 2 12
B 85 9
B 0 12...

output:

1076

result:

ok 1 number(s): "1076"

Test #36:

score: 0
Accepted
time: 736ms
memory: 17184kb

input:

200000
B 1 0
B 2 1
A 0 0
A 4 11
B 0 13
A 6 1
A 0 3
A 7 7
B 2 0
A 10 25
B 0 4
A 18 28
A 3 12
B 4 33
A 24 41
B 1 76
A 28 12
B 28 27
A 34 5
B 15 13
A 76 9
A 60 41
A 40 18
A 68 3
A 51 3
A 12 1
B 9 4
A 154 6
A 71 20
A 0 11
B 26 3
B 7 54
B 30 9
A 25 4
B 29 77
A 47 97
B 3 88
B 64 3
A 11 33
B 14 23
B 110 33...

output:

1070

result:

ok 1 number(s): "1070"

Test #37:

score: 0
Accepted
time: 732ms
memory: 18048kb

input:

200000
B 0 1
A 2 1
A 1 1
A 0 2
A 6 3
A 0 26
A 2 1
B 20 6
A 9 1
A 1 2
B 16 24
A 13 39
B 14 71
A 2 4
A 35 34
B 13 2
A 3 47
A 52 17
B 11 16
A 2 14
B 28 1
B 98 13
A 4 28
B 28 47
A 29 5
B 37 38
B 16 0
A 28 53
B 41 33
A 57 1
A 45 34
B 12 15
B 81 1
B 1 21
B 4 6
B 52 18
A 61 27
B 146 28
B 92 180
B 33 37
B 1...

output:

1074

result:

ok 1 number(s): "1074"

Test #38:

score: 0
Accepted
time: 719ms
memory: 17188kb

input:

200000
B 0 0
B 2 1
A 2 2
A 4 0
B 1 25
A 2 7
B 5 31
A 2 5
B 1 2
A 8 7
B 7 6
A 10 0
A 1 5
B 0 14
B 0 29
B 1 6
A 15 7
A 1 11
A 1 42
B 24 16
B 14 31
A 0 0
A 16 45
A 13 22
B 17 8
A 4 16
B 26 60
B 8 20
B 26 57
A 35 48
B 101 8
B 16 95
B 8 61
A 29 57
B 38 19
B 57 71
A 28 6
B 5 127
B 32 19
A 70 59
B 1 12
A 7...

output:

1074

result:

ok 1 number(s): "1074"

Test #39:

score: 0
Accepted
time: 738ms
memory: 18224kb

input:

200000
A 1 0
A 1 2
A 2 4
A 0 4
A 8 3
A 7 3
B 10 10
B 6 4
A 7 4
A 0 16
A 2 35
A 7 0
A 11 17
A 29 0
B 2 25
B 13 10
B 64 27
A 4 6
B 23 4
A 6 18
B 6 13
B 2 22
A 46 0
B 5 10
B 9 10
B 19 4
B 40 39
A 66 5
A 17 1
A 23 23
A 5 53
A 22 23
A 25 34
B 3 5
B 8 42
A 64 14
B 11 55
B 13 19
A 9 65
B 3 112
B 4 38
A 4 2...

output:

1068

result:

ok 1 number(s): "1068"

Test #40:

score: 0
Accepted
time: 740ms
memory: 17528kb

input:

200000
A 0 1
A 1 2
B 4 10
B 3 1
B 2 0
A 0 0
B 0 5
A 14 4
B 56 6
B 6 1
A 27 7
B 5 1
B 0 1
B 18 7
B 4 22
B 0 16
B 7 4
A 8 3
A 7 14
A 41 20
B 0 4
A 3 5
A 5 4
A 66 2
B 3 13
A 62 53
B 71 27
B 21 49
A 10 7
A 14 10
B 13 15
A 29 2
A 63 19
B 34 23
B 49 120
B 72 56
A 169 18
B 23 67
A 78 9
B 16 4
A 7 133
A 20 ...

output:

1066

result:

ok 1 number(s): "1066"

Test #41:

score: 0
Accepted
time: 736ms
memory: 17240kb

input:

200000
B 0 0
B 1 3
B 6 0
B 0 6
A 13 4
A 3 9
B 2 3
B 1 3
A 5 9
B 33 5
A 11 0
B 3 2
A 9 8
A 12 21
A 6 20
B 12 26
B 23 18
A 13 0
B 60 36
B 12 23
B 35 49
B 4 38
A 18 9
A 27 42
B 73 16
B 8 22
B 2 19
A 5 18
B 4 14
B 8 0
A 23 104
A 37 33
A 6 9
A 6 62
B 12 9
B 83 10
B 46 0
B 36 11
B 28 39
A 36 12
A 9 15
A 4...

output:

1069

result:

ok 1 number(s): "1069"

Test #42:

score: 0
Accepted
time: 733ms
memory: 17744kb

input:

200000
B 2 0
A 1 3
B 15 1
B 3 1
B 3 0
A 10 4
A 5 1
A 4 3
B 19 13
B 5 11
B 4 9
B 2 3
A 48 23
B 8 2
A 9 18
B 0 57
B 2 1
A 19 33
A 16 3
A 0 25
B 18 20
A 6 12
A 54 15
B 13 20
A 35 19
A 29 8
A 7 12
B 47 4
B 125 25
B 2 44
B 40 23
A 49 7
A 21 1
B 39 6
B 66 24
A 98 45
A 21 37
B 57 45
B 7 1
A 79 23
A 12 44
B...

output:

1078

result:

ok 1 number(s): "1078"

Test #43:

score: 0
Accepted
time: 738ms
memory: 17704kb

input:

200000
B 0 4
B 6 1
A 2 2
B 0 2
B 0 6
A 0 1
B 6 7
A 14 2
A 0 0
B 6 7
A 2 24
A 0 0
A 11 5
A 1 8
A 1 10
A 10 21
B 0 12
A 46 19
B 25 17
B 16 11
B 12 29
B 3 32
A 0 0
A 11 14
A 18 15
B 86 9
A 59 21
A 34 10
A 65 8
A 18 6
A 5 45
A 88 32
A 5 57
A 298 14
A 3 35
A 19 58
B 31 51
A 12 6
A 60 4
B 39 34
A 96 18
B ...

output:

1066

result:

ok 1 number(s): "1066"

Extra Test:

score: 0
Extra Test Passed