Submission #211400

# Submission time Handle Problem Language Result Execution time Memory
211400 2020-03-20T09:11:23 Z VEGAnn Street Lamps (APIO19_street_lamps) C++14
20 / 100
5000 ms 7028 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define pll pair<ll, ll>
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 300100;
const int M = 300100;
const int oo = 2e9;
string qr, s, t;
int n, q, loc[M], ans;
bool typ[M];

bool check(int l, int r){
    for (int i = l; i < r; i++)
        if (t[i] == '0')
            return 0;
    return 1;
}

int main(){

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);
#endif // _LOCAL

    cin >> n >> q >> s;

    for (int i = 0; i < q; i++){
        cin >> qr;

        if (qr[0] == 't'){
            typ[i] = 1;

            cin >> loc[i];
            loc[i]--;
        } else{
            int l, r; cin >> l >> r;
            l--; r--;
            ans = 0;

            t = s;

            for (int j = 0; j <= i; j++) {
                ans += check(l, r);
                if (typ[j]) {
                    t[loc[j]] = (t[loc[j]] == '1' ? '0' : '1');
                }
            }

            cout << ans << '\n';
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5064 ms 916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 102 ms 508 KB Output is correct
5 Correct 2518 ms 7028 KB Output is correct
6 Execution timed out 5072 ms 3352 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Execution timed out 5034 ms 2864 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Execution timed out 5064 ms 916 KB Time limit exceeded
9 Halted 0 ms 0 KB -