Submission #916630

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

using namespace std;

const int N = 100 + 10;
int n, q;
string s[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[1];

  for (int i = 1; i <= q; ++i) {
    s[i + 1] = s[i];

    string ty; cin >> ty;
    if (ty == "toggle") {
      int p; cin >> p;
      s[i + 1][p - 1] = (s[i + 1][p - 1] == '0' ? '1' : '0');
    } else {
      int a, b; cin >> a >> b;

      int answer = 0;
      for (int j = 1; j <= i; ++j) {
        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:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("duck.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
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.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 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 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Runtime error 1 ms 856 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -