Submission #253527

# Submission time Handle Problem Language Result Execution time Memory
253527 2020-07-28T07:00:39 Z SorahISA Street Lamps (APIO19_street_lamps) C++17
20 / 100
140 ms 13452 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define double long double
using pii = pair<int, int>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)

int32_t main() {
    fastIO();
    
    int n, q, x, l, r;
    string s, op;
    cin >> n >> q >> s;
    
    vector<int> ans(n, 0), lst_mod(n, 0);
    
    for (int i = 1; i <= q; ++i) {
        cin >> op;
        if (op == "toggle") {
            cin >> x, --x;
            if (s[x] == '1') ans[x] += i - lst_mod[x];
            s[x] ^= 1, lst_mod[x] = i;
        }
        if (op == "query") {
            cin >> l >> r, --l, --r;
            cout << ans[l] + (s[l] ^ '0') * (i - lst_mod[l]) << "\n";
        }
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 77 ms 1272 KB Output is correct
2 Correct 86 ms 4856 KB Output is correct
3 Correct 86 ms 5368 KB Output is correct
4 Correct 124 ms 11276 KB Output is correct
5 Correct 131 ms 11748 KB Output is correct
6 Correct 103 ms 11016 KB Output is correct
7 Correct 132 ms 12044 KB Output is correct
8 Correct 140 ms 13452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -