# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
382629 | 2021-03-27T23:01:23 Z | rainboy | 가로등 (APIO19_street_lamps) | C | 215 ms | 12780 KB |
#include <stdio.h> #include <string.h> #define N 300000 #define Q 300000 #define N_ (1 << 19) #define S 100 int max(int a, int b) { return a > b ? a : b; } int st[N_ * 2], n_; void build(int n) { n_ = 1; while (n_ < n) n_ <<= 1; memset(st, 0x3f, n_ * 2 * sizeof *st); } void pul(int i) { st[i] = max(st[i << 1 | 0], st[i << 1 | 1]); } void update(int i, int x) { st[i += n_] = x; while (i > 1) pul(i >>= 1); } int query(int l, int r) { int x = -1; for (l += n_, r += n_; l <= r; l >>= 1, r >>= 1) { if ((l & 1) == 1) x = max(x, st[l++]); if ((r & 1) == 0) x = max(x, st[r--]); } return x; } int main() { static char cc[N + 1]; static int ll[S][S], ans[N]; int n, q, h, h_, i; scanf("%d%d%s", &n, &q, cc); if (n <= 100 && q <= 100 && 0) { for (h = 0; h < q; h++) { static char s[8]; scanf("%s", s); for (i = 0; i < n; i++) ll[h][i] = cc[i] == '0' ? i + 1 : (i == 0 ? 0 : ll[h][i - 1]); if (s[0] == 't') { scanf("%d", &i), i--; cc[i] = (cc[i] - '0' ^ 1) + '0'; } else { int l, r, cnt; scanf("%d%d", &l, &r), l--, r -= 2; cnt = 0; for (h_ = 0; h_ <= h; h_++) if (ll[h_][r] <= l) cnt++; printf("%d\n", cnt); } } } else { build(n); for (i = 0; i < n; i++) if (cc[i] == '1') update(i, 0); for (h = 1; h <= q; h++) { static char s[8]; scanf("%s", s); if (s[0] == 't') { scanf("%d", &i), i--; update(i, h); if (cc[i] == '0') cc[i] = '1', ans[i] -= h; else cc[i] = '0', ans[i] += h; } else { int l, r; scanf("%d%d", &l, &r), l--, r -= 2; if (l == r) printf("%d\n", ans[l] + (cc[l] == '0' ? 0 : h)); else printf("%d\n", max(h - query(l, r), 0)); } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 1304 KB | Output is correct |
2 | Correct | 101 ms | 2156 KB | Output is correct |
3 | Correct | 124 ms | 2028 KB | Output is correct |
4 | Correct | 175 ms | 7404 KB | Output is correct |
5 | Correct | 158 ms | 7532 KB | Output is correct |
6 | Correct | 141 ms | 7404 KB | Output is correct |
7 | Correct | 149 ms | 6000 KB | Output is correct |
8 | Correct | 161 ms | 7404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 2 ms | 364 KB | Output is correct |
5 | Correct | 134 ms | 5868 KB | Output is correct |
6 | Correct | 153 ms | 6124 KB | Output is correct |
7 | Correct | 176 ms | 6252 KB | Output is correct |
8 | Correct | 207 ms | 6764 KB | Output is correct |
9 | Correct | 101 ms | 1132 KB | Output is correct |
10 | Correct | 128 ms | 4332 KB | Output is correct |
11 | Correct | 112 ms | 4460 KB | Output is correct |
12 | Correct | 194 ms | 11220 KB | Output is correct |
13 | Correct | 215 ms | 12780 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
2 | Incorrect | 2 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |