답안 #698980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698980 2023-02-15T06:58:02 Z Abrar_Al_Samit 가로등 (APIO19_street_lamps) C++17
20 / 100
1 ms 468 KB
#include<bits/stdc++.h>
using namespace std;

void PlayGround() {
  int n, q;
  cin>>n>>q;

  assert(max(n, q)<=100);  

  vector<string>state(1);
  cin>>state[0];

  for(int i=0; i<q; ++i) {
    string type;
    cin>>type;
    string cur = state.back();
    if(type=="toggle") {
      int j;
      cin>>j;
      --j;
      cur[j] = cur[j]=='0'?'1':'0';
      state.push_back(cur);
    } else {
      state.push_back(cur);

      int a, b;
      cin>>a>>b;
      --a, --b;

      int ans = 0;
      for(int j=0; j<=i; ++j) {
        bool ok = true;
        for(int k=a; k<b; ++k) {
          ok &= state[j][k]=='1';
        }
        ans += ok;
      }
      cout<<ans<<'\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Runtime error 1 ms 468 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -