이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
const int maxn = 300005;
int pre[maxn], ans[maxn];
signed main () {
cin.tie(0)->sync_with_stdio(0);
int n, q;
cin >> n >> q;
string s;
cin >> s;
if (n <= 100 and q <= 100) {
vector<string> v;
while (q--) {
v.push_back(s);
string t;
cin >> t;
if (t == "query") {
int l, r, ans = 0;
cin >> l >> r;
for (auto i : v) {
bool good = 1;
for (int j = l - 1 ; j < r - 1 ; j++) {
if (i[j] == '0') good = 0;
}
ans += good;
}
cout << ans << endl;
} else {
int i;
cin >> i;
s[i-1] = '0'+((s[i-1]-'0')^1);
}
}
return 0;
}
array<int, 3> Q[q];
bool ST2 = 1;
for (int i = 0 ; i < n ; i++) {
string t;
cin >> t >> Q[i][1];
Q[i][0] = (t == "query");
if (Q[i][0]) cin >> Q[i][2];
else Q[i][2] = 0;
if (Q[i][0] and Q[i][2] - Q[i][1] != 1) ST2 = 0;
}
if (ST2) {
memset(pre, -1, sizeof pre);
return 0;
int ct = 0;
for (int i = 0 ; i < n ; i++) if (s[i] == '1') pre[i] = 0;
for (auto [t, l, r] : Q) {
ct++;
if (t) {
int sm = ans[l];
if (pre[l] != -1) sm += ct - pre[l] + 1;
cout << sm << endl;
} else {
if (pre[l] == -1) pre[l] = ct;
else {
ans[l] += ct - pre[l];
pre[l] = -1;
}
}
}
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
street_lamps.cpp:17:1: warning: multi-line comment [-Wcomment]
17 | //\
| ^
# | 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... |