답안 #432704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432704 2021-06-18T12:35:22 Z inwbear 가로등 (APIO19_street_lamps) C++14
20 / 100
154 ms 9652 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]+1;
                c[a]='0';
            }
            else
            {
                c[a]='1';
                ls[a]=i+1;
            }
        }
        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);
      |             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 4336 KB Output is correct
2 Correct 102 ms 4636 KB Output is correct
3 Correct 98 ms 5188 KB Output is correct
4 Correct 132 ms 8680 KB Output is correct
5 Correct 132 ms 8080 KB Output is correct
6 Correct 110 ms 8436 KB Output is correct
7 Correct 145 ms 8184 KB Output is correct
8 Correct 154 ms 9652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -