Submission #739149

# Submission time Handle Problem Language Result Execution time Memory
739149 2023-05-10T04:05:33 Z nguyentunglam Street Lamps (APIO19_street_lamps) C++17
0 / 100
67 ms 1788 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 110;
int a[N];
int f[N][N];
int main() {
    #define task ""
    cin.tie(0) -> sync_with_stdio(0);
    if (fopen ("task.inp", "r")) {
        freopen ("task.inp", "r", stdin);
        freopen ("task.out", "w", stdout);
    }
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int n, q; cin >> n >> q;
    string s; cin >> s; s = " " + s;
    for(int i = 1; i <= n; i++) a[i] = s[i] - '0';
    for(int timer = 1; timer <= q; timer++) {
        string ask; cin >> ask;
        if (ask[0] == 't') {
            int i; cin >> i;
            a[i] ^= 1;
            int l, r; l = r = i;
            while (a[l]) l--;
            while (a[r]) r++;
            l++; r--;
            for(int j = l; j <= r; j++) for(int k = j; k <= r; k++) {
                if (a[i]) f[j][k] -= timer;
                else f[j][k] += timer + 1;
            }
        }
        else {
            int l, r; cin >> l >> r; r--;
            bool ok = 1;
            for(int j = l; j <= r; j++) ok &= a[j];
            int ans = f[l][r];
            if (ok) ans += timer;
            cout << ans << endl;
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 1788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -