Submission #432686

# Submission time Handle Problem Language Result Execution time Memory
432686 2021-06-18T12:23:42 Z inwbear Street Lamps (APIO19_street_lamps) C++14
0 / 100
96 ms 4588 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,ans[300005],ls[300005],a,b;
char c[300005],qq[10];
int main()
{
    scanf("%d %d",&n,&m);
    scanf("%s",c+1);
    for(int i=1;i<=n;i++)ls[i]=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%s",qq+1);
        if(qq[1]=='t')
        {
            scanf("%d",&a);
            if(c[a]=='1')
            {
                ans[a]+=i-ls[a];
                c[a]='0';
            }
            else
            {
                c[a]='1';
                ls[a]=i;
            }
        }
        else
        {
            scanf("%d %d",&a,&b);
            if(c[a]=='1')printf("%d\n",ans[a]+i-ls[a]+1);
            else printf("%d\n",ans[a]);
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%s",c+1);
      |     ~~~~~^~~~~~~~~~
street_lamps.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%s",qq+1);
      |         ~~~~~^~~~~~~~~~~
street_lamps.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d",&a);
      |             ~~~~~^~~~~~~~~
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 %d",&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~~
# 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 96 ms 4588 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 1 ms 332 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 -