Submission #432841

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

int n,q;
bool on[300010];
int last_open[300010]={};
char s[300010];
int res[300010]={};
int l,r;
int ans;
int main()
{
    scanf("%d %d",&n,&q);
    scanf("%s",s);
    for(int i=0;i<n;i++) on[i+1]=(s[i]=='1');
    for(int i=1;i<=q;i++)
    {
        scanf("%s",s);
        if(s[0]=='q')
        {
            scanf("%d %d",&l,&r);
            if(on[l]) printf("%d\n",res[l]+(i-last_open[l]));
            else printf("%d\n",res[l]);
        }
        else
        {
            scanf("%d",&l);
            if(on[l])
            {
                on[l]=false;
                res[l]+=(i-last_open[l]);
            }
            else
            {
                on[l]=true;
                last_open[l]=i;
            }
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%s",s);
      |     ~~~~~^~~~~~~~
street_lamps.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%s",s);
      |         ~~~~~^~~~~~~~
street_lamps.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf("%d %d",&l,&r);
      |             ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:29:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |             scanf("%d",&l);
      |             ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 88 ms 1176 KB Output is correct
2 Correct 92 ms 1184 KB Output is correct
3 Correct 100 ms 1212 KB Output is correct
4 Correct 123 ms 3820 KB Output is correct
5 Correct 151 ms 3024 KB Output is correct
6 Correct 122 ms 3864 KB Output is correct
7 Correct 135 ms 1568 KB Output is correct
8 Correct 142 ms 2756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -