# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934366 | vjudge1 | Street Lamps (APIO19_street_lamps) | C++17 | 5047 ms | 524288 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>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 1000000000
#define INF2 2000000000000000000
//#define ll long long
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, q; cin >> n >> q;
int ans[n+1][n+1] = {};
string s; cin >> s; int siz = s.size();
int arr[siz];
for(int i = 0; i < s.size(); i++) {
arr[i] = s[i]-'0';
}
while(q--) {
string ty; cin >> ty;
for(int i = 0; i < n; i++) {
for(int j = i+1; j < n+1; j++) {
bool ok = true;
for(int z = i; z <= j-1; z++) {
if(arr[z] == 0) {
ok = false;
break;
}
}
if(ok) {
ans[i][j]++;
}
}
}
if(ty == "toggle") {
int x; cin >> x;
arr[x-1] = abs(1-arr[x-1]);
}
else {
int a, b; cin >> a >> b;
cout << ans[a-1][b-1] << endl;
}
}
return 0;
}
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... |