이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N 200000
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int ll[N], rr[N], n; char active[N];
void add(int i) {
active[i] = 1;
}
void remove_(int i) {
active[i] = 0;
}
int query(int l, int r, int k) {
int i, cnt;
cnt = 0;
for (i = 0; i < n; i++)
if (active[i] && rr[i] - ll[i] + 1 >= k) {
cnt++;
if (r - ll[i] + 1 < k)
cnt--;
if (rr[i] - l + 1 < k)
cnt--;
}
return cnt;
}
int main() {
int q, online, h, i, ans;
scanf("%d%d", &q, &online);
ans = 0;
for (h = 0; h < q; h++) {
int t, l, r, k, tmp;
scanf("%d", &t);
if (t == 1) {
scanf("%d%d", &l, &r);
if (online)
l ^= ans, r ^= ans;
if (l > r)
tmp = l, l = r, r = tmp;
ll[n] = l, rr[n] = r;
add(n++);
} else if (t == 2) {
scanf("%d", &i), i--;
remove_(i);
} else {
scanf("%d%d%d", &l, &r, &k);
if (online)
l ^= ans, r ^= ans;
if (l > r)
tmp = l, l = r, r = tmp;
printf("%d\n", ans = query(l, r, k));
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
segments.c: In function 'main':
segments.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d%d", &q, &online);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
segments.c:41:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
segments.c:43:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%d%d", &l, &r);
| ^~~~~~~~~~~~~~~~~~~~~
segments.c:51:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | scanf("%d", &i), i--;
| ^~~~~~~~~~~~~~~
segments.c:54:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | scanf("%d%d%d", &l, &r, &k);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |