Submission #916622

# Submission time Handle Problem Language Result Execution time Memory
916622 2024-01-26T07:25:34 Z duckindog Street Lamps (APIO19_street_lamps) C++14
0 / 100
2 ms 604 KB
//from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

const int N = 100 + 10;
int n, q;
string s[N];
bool dd[N];

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }
  cin >> n >> q;
  cin >> s[0];
  int it = 0;
  for (int i = 1; i <= q; ++i) {
    s[i] = s[i - 1];
    string ty; cin >> ty;
    if (ty == "toggle") {
      dd[i] = 1;
      int p; cin >> p;
      s[i][p - 1] = (s[i][p - 1] == '1' ? '0' : '1');
    } else {
      int a, b; cin >> a >> b;
      int answer = 0;
      for (int j = 1; j <= i; ++j) {
        if (dd[j]) continue;
        bool pass = 1;
        for (int t = a - 1; t < b - 1; ++t)
          if (s[j][t] == '0') pass = 0;
        answer += pass;
      }
      cout << answer << '\n';
    }

  }

}

Compilation message

street_lamps.cpp: In function 'int32_t main()':
street_lamps.cpp:20:7: warning: unused variable 'it' [-Wunused-variable]
   20 |   int it = 0;
      |       ^~
street_lamps.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("duck.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("duck.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -