QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#498062#7367. 群岛MSavannah20 37ms8964kbC++142.7kb2024-07-29 22:25:222024-07-29 22:25:25

Judging History

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

  • [2024-07-29 22:25:25]
  • 评测
  • 测评结果:20
  • 用时:37ms
  • 内存:8964kb
  • [2024-07-29 22:25:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define il inline 
il int read()
{
    int xr=0,F=1;char cr;
    while(cr=getchar(),cr<'0'||cr>'9') if(cr=='-') F=-1;
    while(cr>='0'&&cr<='9') xr=(xr<<3)+(xr<<1)+(cr^48),cr=getchar();
    return xr*F;
}
const int N=100010;
int n,m,a[N],opt,x,y;
struct node{int pos,mn,laz;}tr[N<<2];
struct Tree{
    #define ls (k<<1)
    #define rs (k<<1|1)
    #define mid (l+r>>1)
    void build(int k,int l,int r)
    {
        tr[k].pos=r;
        if(l==r){tr[k].mn=0;return ;}
        build(ls,l,mid);build(rs,mid+1,r);
        pushup(k);
    }
    void pushup(int k)
    {
        tr[k].mn=min(tr[ls].mn,tr[rs].mn);
        if(tr[ls].mn<tr[rs].mn) tr[k].pos=tr[ls].pos;
        else tr[k].pos=tr[rs].pos;
    }
    void pushdown(int k)
    {
        tr[ls].mn+=tr[k].laz;tr[ls].laz+=tr[k].laz;
        tr[rs].mn+=tr[k].laz;tr[rs].laz+=tr[k].laz;
        tr[k].laz=0;
    }
    void add(int k,int l,int r,int ql,int qr,int v)
    {
        if(ql<=l&&r<=qr){tr[k].mn+=v,tr[k].laz+=v;return ;}
        pushdown(k);
        if(ql<=mid) add(ls,l,mid,ql,qr,v);
        if(qr>mid) add(rs,mid+1,r,ql,qr,v);
        pushup(k);
    }
    /*int query(int k,int l,int r,int ql,int qr)
    {
        if(ql==l&&r==qr)
        {
            if(!tr[k].mn) return tr[k].r;
            return -1;
        }
        pushdown(k);int res=0;
        if(qr<mid) res=query(ls,l,mid,ql,qr);
        else if(ql>=mid) res=query(rs,mid+1,r,ql,qr);
        else
        {
            int p=query(rs,mid+1,r,mid+1,qr);
            if(p!=-1) res=p;else p=query(ls,l,mid,ql,mid);
        }
        pushup(k);
        return res;
    }*/
    int query(int k,int l,int r,int ql,int qr)
    {
        if(ql<=l&&r<=qr)
        {
            if(!tr[k].mn) return tr[k].pos;
            return -1;
        }
        pushdown(k);int res=-1;
        if(qr>mid) res=query(rs,mid+1,r,ql,qr);
        if(res!=-1) return res;
        else res=query(ls,l,mid,ql,qr);
        return res;
    }
}seg;
int main()
{
    // freopen("island.in","r",stdin);
    // freopen("island.out","w",stdout);
    n=read(),m=read();
    seg.build(1,1,n);
    for(int i=1;i<=n;i++) 
    {
        a[i]=read();
        if(a[i]>=i) a[i]=i;
        seg.add(1,1,n,a[i]+1,i,1);
    }
    while(m--)
    {
        opt=read();
        if(opt==1) 
        {
            x=read(),y=read();
            seg.add(1,1,n,a[x]+1,x,-1);
            a[x]=y;
            seg.add(1,1,n,a[x]+1,x,1);
        }
        if(opt==2) 
        {
            x=read();
            int p=seg.query(1,1,n,1,x);
            if(p==-1) printf("%d\n",n);
            else printf("%d\n",p);
        }
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

7 7
7 3 2 7 3 5 3
1 3 4
2 4
1 2 6
2 2
2 5
1 5 3
2 3

output:

3
2
3
3

result:

ok 4 lines

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3896kb

input:

13 13
5 7 10 13 7 2 10 7 9 5 12 7 13
1 5 7
2 13
2 12
2 10
1 12 10
1 8 13
2 3
2 6
2 6
1 6 7
1 10 8
2 4
1 1 5

output:

0
2
2
2
2
2
4

result:

wrong answer 1st lines differ - expected: '13', found: '0'

Subtask #2:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 33ms
memory: 7548kb

input:

100000 100000
100000 1 1 2 4 1 5 4 5 10 6 11 9 9 11 11 15 17 14 16 19 19 19 23 20 21 26 25 26 29 28 27 29 30 32 33 32 36 36 35 39 40 41 41 43 45 44 43 44 117 46 51 48 50 50 52 55 53 54 42 59 61 61 63 94 64 65 64 64 66 68 69 70 69 87 72 72 77 78 75 76 78 78 79 80 84 84 83 84 142 87 87 90 92 80 91 93 ...

output:

7955
55775
14385
34175
2440
73165
98605
66275
48055
140
40220
65770
85350
2700
57785
89645
52320
44385
54200
62575
76740
82355
42660
93240
54200
11140
18075
89645
31305
44385
69885
25525
51320
77075
25525
85350
69240
40220
97675
16865
80920
98310
140
43240
63465
84765
39615
25525
61155
63465
60795
6...

result:

ok 100000 lines

Test #6:

score: 20
Accepted
time: 33ms
memory: 7852kb

input:

100000 100000
100000 100000 100000 100000 5 2 6 5 8 10 7 7 9 11 10 11 15 16 18 68 20 17 21 19 123 25 26 25 26 26 27 28 32 31 34 35 34 35 36 38 37 39 39 39 30 41 42 47 46 48 50 51 48 51 53 51 52 55 54 56 59 61 62 63 69 65 62 66 67 168 70 71 68 70 73 73 72 75 74 79 76 78 78 81 76 84 83 84 86 97 87 87 ...

output:

98050
12390
68355
77975
65210
30355
21265
77975
53660
46585
14370
65210
10270
58810
4515
72635
25930
75865
25
86215
9380
80270
9380
56705
75625
71125
62280
44100
77975
30435
30435
11590
71125
53660
65210
69410
75865
98050
25
66335
2145
56705
9740
53660
33850
25930
8115
46585
2145
66335
35115
75865
6...

result:

ok 100000 lines

Test #7:

score: 20
Accepted
time: 33ms
memory: 8964kb

input:

100000 100000
100000 100000 100000 1 3 3 4 5 7 10 9 7 9 11 13 12 16 17 18 18 16 17 20 23 41 23 22 23 27 25 28 27 28 32 19 31 35 35 38 51 39 40 40 42 41 41 45 47 47 39 49 51 51 50 47 52 54 56 55 57 56 61 61 62 60 65 66 67 66 106 69 67 70 71 72 74 76 76 76 76 77 77 78 82 80 85 84 83 84 87 89 88 88 93 ...

output:

40060
40060
51970
89010
29125
29125
29125
15675
72520
44765
32330
86635
29125
89365
64645
86635
8130
76680
24800
83685
72520
13140
54385
80215
32330
32330
27825
1
56030
72520
76680
24420
37840
97190
84640
80215
57675
11770
11175
77605
66940
72520
86635
15675
93495
15675
79380
2165
88565
93790
1
7252...

result:

ok 100000 lines

Test #8:

score: 20
Accepted
time: 37ms
memory: 8816kb

input:

100000 100000
100000 100000 100000 100000 100000 100000 100000 100000 4 100000 100000 100000 8 1 7 100000 12 100000 100000 100000 100000 2 7 12 100000 100000 100000 100000 24 100000 100000 2 100000 34 17 16 1 1 6 37 9 1 26 7 20 6 40 27 8 17 44 5 33 52 45 37 8 52 43 44 30 30 61 27 46 49 34 40 29 28 2...

output:

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

result:

ok 100000 lines

Test #9:

score: 20
Accepted
time: 30ms
memory: 8016kb

input:

100000 100000
8751 2011 12672 8150 8133 2290 16185 17801 17513 22749 18754 541 31934 1466 21018 30487 17406 15125 391 13136 5501 18415 24356 17256 28496 13606 7333 20048 25868 27702 28662 17824 17026 28114 32443 8813 15650 6043 22441 13593 14326 31713 32338 803 5452 18174 1107 13754 6336 13939 13498...

output:

25339
70884
70884
60758
66071
5629
11016
75507
11016
40667
982
85185
60758
66418
70884
80756
80756
46126
11016
11016
70884
11016
95892
55160
55160
95892
35118
75507
30867
35118
65773
90457
85185
66418
25714
95892
60758
46141
11016
46141
11016
20205
80756
11016
40667
11016
25714
70884
55160
65947
159...

result:

ok 100000 lines

Test #10:

score: 20
Accepted
time: 27ms
memory: 8864kb

input:

100000 100000
28342 23764 69 16293 8618 19424 30189 12094 8726 31553 11543 9511 8431 20726 20964 27876 27913 24197 13961 18478 5930 10577 24601 24133 26444 17137 25078 31993 8117 12704 2871 10664 4952 10609 25358 172 2293 5120 29969 26359 28610 26872 28007 2463 25689 22401 1668 12073 1379 15691 1732...

output:

97189
45674
67218
35922
72210
67218
62354
71948
92438
20906
52157
17209
55871
41841
27355
66295
2211
22440
7259
90223
12423
52112
36863
22440
46457
15757
32407
6232
55563
92438
17209
12423
15649
98033
56906
92216
72210
22440
12103
2211
16050
47329
70441
77308
36523
61456
5726
40028
32478
15477
65901...

result:

ok 100000 lines

Test #11:

score: 20
Accepted
time: 30ms
memory: 8328kb

input:

100000 100000
9 9 4 4 9 15 11 16 16 19 11 12 18 16 18 21 22 19 28 23 26 29 28 27 30 26 32 30 37 30 38 40 41 42 44 42 39 40 47 43 43 45 46 44 49 53 47 52 51 57 55 54 56 62 57 57 58 65 66 69 64 65 67 66 71 70 67 74 75 76 77 75 80 83 77 78 82 81 88 86 87 88 86 86 89 88 93 89 93 99 92 93 100 98 104 100 ...

output:

81180
49107
7073
88536
20074
45318
72818
77032
85478
85790
34368
77032
59735
24482
65318
20585
77032
51082
94440
61785
84938
34090
15348
68004
65046
27007
7073
20023
51082
68004
1223
68004
88536
51082
64655
7073
72050
69410
27342
71141
70074
39521
27492
77032
1223
72818
51082
20585
88536
94440
85483...

result:

ok 100000 lines

Test #12:

score: 20
Accepted
time: 26ms
memory: 7880kb

input:

100000 100000
10 8 4 13 6 15 13 9 10 13 11 13 15 14 20 18 24 21 26 29 27 24 28 29 25 30 27 31 34 36 33 37 42 42 40 39 39 43 46 47 50 42 51 51 53 52 50 51 53 53 56 56 61 54 60 62 62 64 61 65 67 63 71 73 73 75 67 76 75 74 74 75 77 75 78 80 86 82 82 80 82 84 83 88 86 90 94 95 98 98 98 101 96 94 101 101...

output:

63634
70160
27359
54647
58014
90041
67273
51132
18166
43407
15111
21208
92244
51132
7092
24240
92244
54289
76424
33742
161
41799
90041
54647
75281
42023
63634
67273
15111
86954
15111
67273
25475
37514
70160
44702
58014
40113
10196
27359
161
93183
70160
43407
34378
58014
47019
161
90041
99333
40113
6...

result:

ok 100000 lines

Test #13:

score: 20
Accepted
time: 29ms
memory: 8300kb

input:

100000 100000
100000 100000 100000 100000 46 4 4 6 6 9 7 10 12 12 13 11 15 15 15 18 17 18 19 23 20 23 26 26 25 31 29 29 32 29 31 33 32 35 37 67 39 39 41 41 44 41 46 43 46 47 50 49 52 49 52 53 54 56 54 58 57 58 62 63 64 61 65 63 64 66 70 70 72 71 71 71 75 75 77 78 79 77 78 82 81 85 84 85 88 87 89 87 ...

output:

65510
31960
87960
19385
76845
31960
29040
87225
825
24920
3090
90720
11535
81400
81000
83050
18420
16555
41520
84010
68570
31960
61625
93370
77285
71960
93370
6270
11650
79380
31960
65510
49970
31960
68570
61180
93370
19385
81400
22930
24920
11650
43395
15080
17595
97155
53025
71960
51315
97155
1938...

result:

ok 100000 lines

Subtask #3:

score: 0
Skipped

Dependency #1:

0%