| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 773204 | rainboy | Alternating Heights (CCO22_day1problem1) | C11 | 427 ms | 13844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#define N 3000
#define M 3000
int *ej[N], eo[N], fo[N], n;
void append(int i, int j) {
int o = eo[i]++;
if (o >= 2 && (o & o - 1) == 0)
ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
ej[i][o] = j;
}
int ii[M], m;
int check(int l, int r) {
static int qu[N];
int cnt, h, i, j, o;
for (i = 0; i < n; i++)
ej[i] = (int *) malloc(2 * sizeof *ej[i]), eo[i] = 0, fo[i] = 0;
for (h = l; h < r; h++)
if (h % 2 == 0)
append(ii[h], ii[h + 1]), fo[ii[h + 1]]++;
else
append(ii[h + 1], ii[h]), fo[ii[h]]++;
cnt = 0;
for (i = 0; i < n; i++)
if (fo[i] == 0)
qu[cnt++] = i;
for (h = 0; h < cnt; h++) {
i = qu[h];
for (o = eo[i]; o--; ) {
j = ej[i][o];
if (--fo[j] == 0)
qu[cnt++] = j;
}
}
for (i = 0; i < n; i++)
free(ej[i]);
return cnt == n;
}
int main() {
static int rr[M];
int q, h, l, r;
scanf("%d%d%d", &m, &n, &q);
for (h = 0; h < m; h++)
scanf("%d", &ii[h]), ii[h]--;
for (l = 0, r = 0; l < m; l++) {
while (r < m && check(l, r))
r++;
rr[l] = r;
}
while (q--) {
scanf("%d%d", &l, &r), l--, r--;
printf(r < rr[l] ? "YES\n" : "NO\n");
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
