제출 #1228889

#제출 시각아이디문제언어결과실행 시간메모리
1228889Jer가로등 (APIO19_street_lamps)C++20
20 / 100
139 ms4028 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 300005;
int n, q;
int total[MAXN], last[MAXN];
bool on[MAXN];

bool scan_ev()
{
    char c;
    scanf(" %c", &c);
    if (c == 't')
    {
        for (int i = 0; i < 5; i++)
            scanf(" %c", &c);
        return true;
    }

    for (int i = 0; i < 4; i++)
        scanf(" %c", &c);
    return false;
}

int main()
{
    scanf("%d%d", &n, &q);

    char s[MAXN];
    scanf(" %s", &s);
    for (int i = 0; i < n; i++)
        on[i] = s[i] - '0';

    int a, b, c;
    for (int h = 1; h <= q; h++)
    {
        if (scan_ev())
        {
            scanf("%d", &c);
            c--;
            if (on[c])
                total[c] += h - last[c];
            else
                last[c] = h;
            on[c] = !on[c];
        }
        else
        {
            scanf("%d%d", &a, &b);
            a--, b--;
            printf("%d\n", total[a] + ((on[a]) ? h - last[a] : 0));
        }
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:31:14: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[300005]' [-Wformat=]
   31 |     scanf(" %s", &s);
      |             ~^   ~~
      |              |   |
      |              |   char (*)[300005]
      |              char*
street_lamps.cpp: In function 'bool scan_ev()':
street_lamps.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf(" %c", &c);
      |     ~~~~~^~~~~~~~~~~
street_lamps.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |             scanf(" %c", &c);
      |             ~~~~~^~~~~~~~~~~
street_lamps.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf(" %s", &s);
      |     ~~~~~^~~~~~~~~~~
street_lamps.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             scanf("%d", &c);
      |             ~~~~~^~~~~~~~~~
street_lamps.cpp:50:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |             scanf("%d%d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...