# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
739152 | nguyentunglam | Street Lamps (APIO19_street_lamps) | C++17 | 61 ms | 1324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
int l = i - 1, r = i + 1;
a[i] ^= 1;
while (a[l]) l--;
while (a[r]) r++;
l++; r--;
// cout << l << " " << r << endl;
for(int j = l; j <= i; j++) for(int k = i; k <= r; k++) {
if (a[i]) f[j][k] -= timer;
else f[j][k] += timer;
}
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |