답안 #910675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910675 2024-01-18T07:02:58 Z ibm2006 가로등 (APIO19_street_lamps) C++17
20 / 100
117 ms 18512 KB
#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];
char c[110000];
int main()
{
    scanf("%lld %lld",&n,&q);
    for(i=1;i<=n;i++)
    {
        scanf("%01lld",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
            d[i]=0;
        }
        else

            d[i]=-1;
    }
    for(ee=1;ee<=q;ee++)
    {
        scanf("\n%s",c);
        if(c[0]=='t')
        {
            scanf("%lld",&x);
            if(a[x]==1)
            b[x]+=ee-d[x];
            else
            {
                d[x]=ee;
            }
            a[x]^=1;
            continue;
        }
        scanf("%lld %lld",&x,&y);
        if(a[x]==1)
        printf("%lld\n",b[x]+ee-d[x]);
        else
            printf("%lld\n",b[x]);
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%lld %lld",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
street_lamps.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%01lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("\n%s",c);
      |         ~~~~~^~~~~~~~~~
street_lamps.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |             scanf("%lld",&x);
      |             ~~~~~^~~~~~~~~~~
street_lamps.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%lld %lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 7092 KB Output is correct
2 Correct 65 ms 8020 KB Output is correct
3 Correct 68 ms 9296 KB Output is correct
4 Correct 95 ms 16980 KB Output is correct
5 Correct 101 ms 17024 KB Output is correct
6 Correct 117 ms 18428 KB Output is correct
7 Correct 107 ms 17232 KB Output is correct
8 Correct 113 ms 18512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -