QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659446 | #7367. 群岛 | BFSDFS123 | 0 | 255ms | 6252kb | C++14 | 2.4kb | 2024-10-19 20:13:40 | 2024-10-19 20:13:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e5+10;
int n,m;
struct segmenttree{
struct segtree{
int mn;
int tag;
}t[Maxn<<2];
#define ls node<<1
#define rs node<<1|1
void pushup(int node)
{
t[node].mn=min(t[ls].mn,t[rs].mn);
}
void pushdown(int node)
{
if(t[node].tag)
{
t[ls].mn+=t[node].tag;
t[rs].mn+=t[node].tag;
t[ls].tag+=t[node].tag;
t[rs].tag+=t[node].tag;
t[node].tag=0;
}
}
void update(int node,int l,int r,int ql,int qr,int v)
{
if(ql<=l && r<=qr)
{
t[node].mn+=v;
t[node].tag+=v;
return ;
}
pushdown(node);
int mid=(l+r)>>1;
if(ql<=mid) update(ls,l,mid,ql,qr,v);
if(qr>mid) update(rs,mid+1,r,ql,qr,v);
pushup(node);
}
int query(int node,int l,int r,int ql,int qr)
{
if(ql<=l && r<=qr)
{
return t[node].mn;
}
pushdown(node);
int mid=(l+r)>>1;
int res=n+1;
if(ql<=mid) res=min(res,query(ls,l,mid,ql,qr));
if(qr>mid) res=min(res,query(rs,mid+1,r,ql,qr));
return res;
}
}seg;
int Ar[Maxn];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%d",&Ar[i]);
if(Ar[i]<i)
{
seg.update(1,1,n,Ar[i]+1,i,1);
// cout<<Ar[i]<<"->"<<i<<endl;
}
}
while(m--)
{
int op;
int x;
scanf("%d%d",&op,&x);
if(op==1)
{
int y;
scanf("%d",&y);
if(Ar[x]<x)
{
seg.update(1,1,n,Ar[x]+1,x,-1);
}
Ar[x]=y;
if(Ar[x]<x)
{
seg.update(1,1,n,Ar[x]+1,x,1);
}
}else{
int l=1,r=x-1;
int res=-1;
while(l<=r)
{
int mid=(l+r)>>1;
if(seg.query(1,1,n,mid,x)==0)
{
res=mid;
l=mid+1;
}else{
r=mid-1;
}
}
if(res==-1) res=1;
printf("%d\n",res);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
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 1 3 2
result:
wrong answer 2nd lines differ - expected: '2', found: '1'
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 255ms
memory: 6252kb
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:
wrong answer 1006th lines differ - expected: '92285', found: '92284'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%