제출 #1228878

#제출 시각아이디문제언어결과실행 시간메모리
1228878JerStreet Lamps (APIO19_street_lamps)C++20
0 / 100
91 ms1256 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 300005;
int n, q;
int total[MAXN], last[MAXN];
bool a[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);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

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

    return 0;
}

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:31:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'bool*' [-Wformat=]
   31 |         scanf("%d", &a[i]);
      |                ~^   ~~~~~
      |                 |   |
      |                 |   bool*
      |                 int*
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:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |             scanf("%d", &c);
      |             ~~~~~^~~~~~~~~~
street_lamps.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |             scanf("%d%d", &f, &s);
      |             ~~~~~^~~~~~~~~~~~~~~~
#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...