# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249073 | crossing0ver | 가로등 (APIO19_street_lamps) | C++17 | 70 ms | 9720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int N = 3e5+5;
int n,q;
string S;
bool s[N];
void Small() {
string type;
vector<int> Q;
Q.pb(-1);
for (int rep = 0,a,b,x; rep < q; rep++) {
cin >> type;
if (type[0] == 't') {
cin >> x;
x--;
Q.pb(x);
}
else {
cin >> a >> b;
a--; b-=2;
int ans = 0;
for (int i : Q) {
if (i != -1 ) s[i] = (!s[i]);
bool flag = 1;
for (int i = a; i <= b; i++) if (s[i] == 0) flag = 0;
if (flag) ans++;
}
for (int i : Q) if (i != -1) s[i] = (!s[i]);
cout << ans <<'\n';
Q.pb(-1);
}
}
exit(0);
}
struct {
bool type;
int a,b;
}quest[N];
void CaseAdj() {
vector<int> last(n+1),ans(n+1);
for (int i = 0; i < q;i++) {
if (quest[i].type == 0) {
int x = quest[i].a;
if (s[x] == 1) {
ans[x] += (i+1)-last[x];
last[x] = i+1;
}
else {
last[x] = i; // or i+1
}
s[x] = (!s[x]);
}
else {
int x = quest[i].a;
cout << ans[i] + (s[x] ? (i + 1) - last[x] : 0) <<'\n';
}
}
}
main() {
ios::sync_with_stdio(0);
cin >> n >> q >> S;
for (int i = 0; i < S.size(); i++)
s[i] = (S[i] == '1');
if (n <= 100 && q <= 100)
Small();
string tp;
bool flag = 1;
for (int i = 0,x; i < q; i++) {
cin >> tp;
if (tp[0] == 't') {
quest[i].type = 0;
cin >> x;
x--;
quest[i].a = x;
}
else {
quest[i].type = 1;
cin >> quest[i].a >> quest[i].b;
quest[i].a--;
quest[i].b-=2;
if (quest[i].a != quest[i].b)
flag = 0;
}
}
if (flag == 1) CaseAdj();
}
컴파일 시 표준 에러 (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... |