Submission #1228927

#TimeUsernameProblemLanguageResultExecution timeMemory
1228927Jer가로등 (APIO19_street_lamps)C++20
20 / 100
2 ms584 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 105;
int n, q;
bool on[MAXN][MAXN]; // i, time

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][0] = s[i] - '0';

    for (int i = 0; i < n; i++)
        on[i][1] = on[i][0];

    int a, b, c;
    for (int h = 1; h <= q; h++)
    {
        for (int i = 0; i < n; i++)
            on[i][h + 1] = on[i][h];

        if (scan_ev())
        {
            scanf("%d", &c);
            c--;
            on[c][h + 1] = !on[c][h];
        }
        else
        {
            scanf("%d%d", &a, &b);
            a--, b--;
            int res = 0;
            for (int i = 1; i <= h; i++)
            {
                bool add = true;
                for (int j = a; j < b; j++)
                    add = add and on[j][i];
                res += add;
            }
            printf("%d\n", res);
        }
    }

    return 0;
}

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:30:14: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[105]' [-Wformat=]
   30 |     scanf(" %s", &s);
      |             ~^   ~~
      |              |   |
      |              |   char (*)[105]
      |              char*
street_lamps.cpp: In function 'bool scan_ev()':
street_lamps.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf(" %c", &c);
      |     ~~~~~^~~~~~~~~~~
street_lamps.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf(" %c", &c);
      |             ~~~~~^~~~~~~~~~~
street_lamps.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf(" %s", &s);
      |     ~~~~~^~~~~~~~~~~
street_lamps.cpp:45:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |             scanf("%d", &c);
      |             ~~~~~^~~~~~~~~~
street_lamps.cpp:51:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |             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...