답안 #1095028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095028 2024-10-01T07:34:30 Z vjudge1 가로등 (APIO19_street_lamps) C++17
20 / 100
5000 ms 524288 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <set>
#include <functional>
#warning That's not the baby, that's my baby

#define debug(x) #x << " = " << x << '\n'
using ll = long long;

const int INF = 1e9;
const int NMAX = 3e5;

std::string s;
int n;

std::vector<std::string> ss;

int query(int l, int r) {
  int answer = 0;
  for (const auto &q : ss) {
    bool ok = true;
    for (int i = l; i <= r && ok; i++) {
      ok &= q[i];
    }
    answer += ok;
  }
  return answer;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  #ifdef LOCAL
freopen("input.txt", "r", stdin);
  #endif

  int q;
  std::cin >> n >> q;

  std::cin >> s;
  s = '$' + s;

  for (int i = 1; i <= n; i++) {
    s[i] -= '0';
  }

  ss.push_back(s);

  for (int i = 1; i <= q; i++) {
    std::string type;
    std::cin >> type;
    if (type == "toggle") {
      int p;
      std::cin >> p;
      s[p] ^= 1;
    } else {
      int l, r;
      std::cin >> l >> r;
      r--;
      std::cout << query(l, r) << '\n';
    }
    ss.push_back(s);
  }

  return 0;
}

Compilation message

street_lamps.cpp:8:2: warning: #warning That's not the baby, that's my baby [-Wcpp]
    8 | #warning That's not the baby, that's my baby
      |  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5039 ms 12612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 2 ms 1372 KB Output is correct
3 Correct 3 ms 1372 KB Output is correct
4 Correct 122 ms 1364 KB Output is correct
5 Runtime error 216 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1372 KB Output is correct
2 Correct 2 ms 1372 KB Output is correct
3 Correct 2 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Runtime error 218 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Execution timed out 5039 ms 12612 KB Time limit exceeded
9 Halted 0 ms 0 KB -