Submission #1234265

#TimeUsernameProblemLanguageResultExecution timeMemory
1234265badge881Street Lamps (APIO19_street_lamps)C++20
20 / 100
84 ms5704 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, q; scanf("%d%d\n", &n, &q); vector<int> count(n); vector<int> state(n); for (int i = 0; i < n; i++) { char chr; scanf("%c", &chr); count[i] = state[i] = (chr == '1'); } vector<int> lastc(n, 0); for (int i = 0; i < q; i++) { char str[10]; scanf("\n%s ", str); if (str[0] == 't') { int t; scanf("%d", &t); t--; if (state[t]) count[t] += (i - lastc[t]); state[t] ^= 1; lastc[t] = i; } else { int l, r; scanf("%d%d", &l, &r); assert(l == r - 1); l--; int ans = count[l]; if (state[l]) ans += (i - lastc[l]); printf("%d\n", ans); } } return 0; }

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d\n", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
street_lamps.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%c", &chr);
      |         ~~~~~^~~~~~~~~~~~
street_lamps.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("\n%s ", str);
      |         ~~~~~^~~~~~~~~~~~~~
street_lamps.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d", &t);
      |             ~~~~~^~~~~~~~~~
street_lamps.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |             scanf("%d%d", &l, &r);
      |             ~~~~~^~~~~~~~~~~~~~~~
#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...