답안 #689389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689389 2023-01-28T11:41:12 Z ToroTN 가로등 (APIO19_street_lamps) C++14
20 / 100
2 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,l,r,cnt,ans;
char s[105][105],op[15];
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",s[1]+1);
    for(int i=1;i<=m;i++)
    {
        scanf("%s",op);
        if(op[0]=='q')
        {
            scanf("%d%d",&l,&r);
            ans=0;
            for(int j=1;j<=i;j++)
            {
                cnt=0;
                for(int k=l;k<r;k++)
                {
                    if(s[j][k]=='1')++cnt;
                }
                if(cnt==r-l)++ans;
            }
            printf("%d\n",ans);
            for(int j=1;j<=n;j++)s[i+1][j]=s[i][j];
        }else
        {
            for(int j=1;j<=n;j++)s[i+1][j]=s[i][j];
            scanf("%d",&l);
            s[i+1][l]='1'+'0'-s[i+1][l];
        }
    }
}

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",s[1]+1);
      |     ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%s",op);
      |         ~~~~~^~~~~~~~~
street_lamps.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |             scanf("%d%d",&l,&r);
      |             ~~~~~^~~~~~~~~~~~~~
street_lamps.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |             scanf("%d",&l);
      |             ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Runtime error 1 ms 440 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -