답안 #966775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966775 2024-04-20T10:28:18 Z kilkuwu 가로등 (APIO19_street_lamps) C++17
20 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>

#define nl '\n'

#ifdef LOCAL
#include "template/debug.hpp"
#else
#define dbg(...) ;
#define timer(...) ;
#endif

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, q;
  std::cin >> n >> q;
  std::vector<std::string> state(q + 1);
  std::cin >> state[0];
  std::vector<std::vector<int>> pref(q + 1);
  auto make_pref = [&](int id) {
    pref[id].resize(n + 1);
    pref[id][0] = 0;
    for (int i = 0; i < n; i++) {
      pref[id][i + 1] = pref[id][i] + (state[id][i] == '1');
    }
  };
  make_pref(0);

  for (int tt = 1; tt <= q; tt++) {
    std::string com;
    std::cin >> com;
    state[tt] = state[tt - 1];
    if (com == "toggle") {
      int i;
      std::cin >> i;
      --i;
      state[tt][i] = '1' ^ '0' ^ state[tt][i]; 
      make_pref(tt);
    } else {
      make_pref(tt);
      int a, b;
      std::cin >> a >> b;
      --a, --b;
      int ans = 0;
      for (int x = 0; x < tt; x++) {
        ans += pref[x][b] - pref[x][a] == b - a; 
      }
      std::cout << ans << nl;
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5059 ms 47552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5212 KB Output is correct
2 Correct 4 ms 5368 KB Output is correct
3 Correct 4 ms 5720 KB Output is correct
4 Correct 4 ms 5444 KB Output is correct
5 Runtime error 380 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5468 KB Output is correct
2 Correct 4 ms 5288 KB Output is correct
3 Correct 4 ms 5468 KB Output is correct
4 Correct 3 ms 5328 KB Output is correct
5 Runtime error 256 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Execution timed out 5059 ms 47552 KB Time limit exceeded
9 Halted 0 ms 0 KB -