Submission #432851

# Submission time Handle Problem Language Result Execution time Memory
432851 2021-06-18T14:15:16 Z TLP39 Street Lamps (APIO19_street_lamps) C++14
20 / 100
362 ms 7200 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

const int big=1000000000;
int n,q;
int seg[1200040]={};
char s[300010];
int res[300010]={};
int x,y;
int ans;

void upd(int v,int l,int r,int pos,int val)
{
    if(l==r)
    {
        seg[v]=val;
        return;
    }
    int mid=(l+r)>>1;
    if(mid>=pos) upd(v<<1,l,mid,pos,val);
    else upd(1+(v<<1),mid+1,r,pos,val);
    seg[v]=max(seg[v<<1],seg[1+(v<<1)]);
}

int que(int v,int l,int r,int st,int ed)
{
    if(st>ed) return -1;
    if(l==st && r==ed) return seg[v];
    int mid=(l+r)>>1;
    return max(que(v<<1,l,mid,st,min(mid,ed)),que(1+(v<<1),mid+1,r,max(mid+1,st),ed));
}

int main()
{
    scanf("%d %d",&n,&q);
    scanf("%s",s);
    for(int i=0;i<1200040;i++) seg[i]=big;
    int temp;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1') upd(1,1,n,i+1,0);
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%s",s);
        if(s[0]=='q')
        {
            scanf("%d %d",&x,&y);
            temp=que(1,1,n,x,y-1);
            if(temp==big) printf("0\n");
            else printf("%d\n",i-temp);
        }
        else
        {
            scanf("%d",&x);
            upd(1,1,n,x,i);
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%s",s);
      |     ~~~~~^~~~~~~~
street_lamps.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%s",s);
      |         ~~~~~^~~~~~~~
street_lamps.cpp:50:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |             scanf("%d %d",&x,&y);
      |             ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:57:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 5400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 5000 KB Output is correct
4 Correct 4 ms 4940 KB Output is correct
5 Correct 153 ms 5276 KB Output is correct
6 Correct 213 ms 5428 KB Output is correct
7 Correct 277 ms 5532 KB Output is correct
8 Correct 347 ms 7196 KB Output is correct
9 Correct 111 ms 5788 KB Output is correct
10 Correct 119 ms 5828 KB Output is correct
11 Correct 121 ms 5924 KB Output is correct
12 Correct 299 ms 5840 KB Output is correct
13 Correct 362 ms 7200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Incorrect 4 ms 4940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4940 KB Output isn't correct
2 Halted 0 ms 0 KB -