| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 910685 | ibm2006 | Street Lamps (APIO19_street_lamps) | C++17 | 132 ms | 25228 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,a[1100000],b[1100000],q,ee,d[1100000],seg1[1100000],seg2[1100000];
char c[110000];
void f1(ll x)
{
seg1[x]=(seg1[x*2]+seg1[x*2+1]);
if(x==1)
return;
f1(x/2);
}
void f2(ll x)
{
seg2[x]=max(seg2[x*2],seg2[x*2+1]);
if(x==1)
return;
f2(x/2);
}
ll g1(ll x,ll y,ll z)
{
if(y<l||x>r)
return 0;
if(l<=x&&y<=r)
return seg1[z];
return g1(x,(x+y)/2,z*2)+g1((x+y)/2+1,y,z*2+1);
}
ll g2(ll x,ll y,ll z)
{
if(y<l||x>r)
return 0;
if(l<=x&&y<=r)
return seg2[z];
return max(g2(x,(x+y)/2,z*2),g2((x+y)/2+1,y,z*2+1));
}
int main()
{
scanf("%lld %lld",&n,&q);
for(i=1;i<=n;i++)
{
scanf("%01lld",&a[i]);
}
for(i=1;i<=n;i++)
{
b[i]=b[i-1]+a[i];
}
for(ee=1;ee<=q;ee++)
{
scanf("\n%s",c);
if(c[0]=='t')
{
scanf("%lld",&x);
seg2[x+262143]=ee;
f2((x+262143)/2);
seg1[x+262143]++;
f1((x+262143)/2);
continue;
}
scanf("%lld %lld",&x,&y);
y--;
l=x;
r=y;
z=g1(1,262144,1);
if(b[y]-b[x-1]+z==y-x+1)
{
printf("%lld\n",ee-g2(1,262144,1));
continue;
}
else
printf("0\n");
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
