제출 #966779

#제출 시각아이디문제언어결과실행 시간메모리
966779kilkuwu가로등 (APIO19_street_lamps)C++17
20 / 100
92 ms9944 KiB
#include <bits/stdc++.h>

#define nl '\n'

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

signed main() {
  #ifndef LOCAL
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  #endif
  int n, q;
  std::cin >> n >> q;

  std::string s;
  std::cin >> s;

  std::vector<int> ans(n);

  for (int i = 1; i <= q; i++) {
    std::string com;
    std::cin >> com;
    if (com == "toggle") {
      int id;
      std::cin >> id;
      --id;
      if (s[id] == '0') {
        ans[id] -= i;
      } else {
        ans[id] += i;
      }
      s[id] = '1' ^ '0' ^ s[id];
    } else {
      int a, b;
      std::cin >> a >> b;
      --a, --b;
      if (s[a] == '0') {
        std::cout << ans[a] << nl;
      } else {
        std::cout << ans[a] + i << nl;
      }
    }
  }
}

/*
5 7
11011
query 3 4
toggle 3
query 3 4 
query 1 2 
toggle 1
query 3 4 
query 1 2 
*/
#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...