Submission #140532

#TimeUsernameProblemLanguageResultExecution timeMemory
140532luciocf가로등 (APIO19_street_lamps)C++14
20 / 100
3 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5+10; struct Op { int type; int ind; } query[maxn]; int n, q; bool on[maxn]; bool mark[maxn]; void solve_small(void) { for (int i = 1; i <= q; i++) { string op; cin >> op; if (op == "toggle") { int ind; scanf("%d", &ind); query[i] = {0, ind}; } else { int l, r; scanf("%d %d", &l, &r); query[i] = {1, -1}; int ans = 0; for (int j = 1; j <= n; j++) mark[j] = on[j]; for (int j = 1; j <= i; j++) { if (query[j].type == 1) { bool ok = 1; for (int k = l; k < r; k++) if (!mark[k]) ok = 0; if (ok) ans++; } else { bool ok = 1; for (int k = l; k < r; k++) if (!mark[k]) ok = 0; if (ok) ans++; mark[query[j].ind] = !mark[query[j].ind]; } } printf("%d\n", ans); } } } int main(void) { scanf("%d %d", &n, &q); for (int i = 1; i <= n; i++) { char x; scanf(" %c", &x); if (x == '1') on[i] = true; } if (n <= 100 && q <= 100) { solve_small(); return 0; } }

Compilation message (stderr)

street_lamps.cpp: In function 'void solve_small()':
street_lamps.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &ind);
    ~~~~~^~~~~~~~~~~~
street_lamps.cpp:35:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d", &l, &r);
    ~~~~~^~~~~~~~~~~~~~~~~
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:75:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
street_lamps.cpp:80:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &x);
   ~~~~~^~~~~~~~~~~
#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...