| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 163954 | luciocf | 가로등 (APIO19_street_lamps) | C++14 | 294 ms | 13300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
struct Event
{
int op, a, b;
} event[maxn];
int n, q;
bool mark[maxn], aux[maxn];
void sub_1(void)
{
for (int i = 1; i <= q; i++)
{
if (event[i].op == 0) continue;
int ans = 0;
for (int j = 1; j <= n; j++)
aux[j] = mark[j];
for (int j = 1; j <= i; j++)
{
bool ok = 1;
for (int l = event[i].a; l < event[i].b; l++)
if (!aux[l])
ok = 0;
if (ok) ans++;
if (event[j].op == 0)
aux[event[j].a] = !aux[event[j].a];
}
printf("%d\n", ans);
}
}
int last[maxn];
int tot[maxn];
void sub_2(void)
{
for (int i = 1; i <= n; i++)
{
if (mark[i]) last[i] = 0;
else last[i] = -1;
}
for (int i = 1; i <= q; i++)
{
if (event[i].op == 0)
{
if (last[event[i].a] == -1) last[event[i].a] = i;
else tot[event[i].a] += i-last[event[i].a], last[event[i].a] = -1;
}
else
{
if (last[event[i].a] == -1) printf("%d\n", tot[event[i].a]);
else printf("%d\n", tot[event[i].a]+i-last[event[i].a]);
}
}
}
int main(void)
{
scanf("%d %d", &n, &q);
for (int i = 1; i <= n; i++)
{
char x;
scanf(" %c", &x);
if (x == '1') mark[i] = 1;
else mark[i] = 0;
}
for (int i = 1; i <= q; i++)
{
string op;
cin >> op;
if (op[0] == 't')
{
int a;
scanf("%d", &a);
event[i] = {0, a, -1};
}
else
{
int a, b;
scanf("%d %d", &a, &b);
event[i] = {1, a, b};
}
}
if (n <= 100 && q <= 100) sub_1();
else sub_2();
}
컴파일 시 표준 에러 (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... | ||||
