이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define N 200000
int main() {
static int aa[N * 2], bb[N * 2], pp[N * 2];
static char used[N];
int n, r, p, p_, i, i_, a;
scanf("%d%d", &n, &r);
if (n > 200) {
printf(":(\n");
return 0;
}
for (i = 0; i < n * 2; i++)
scanf("%d", &aa[i]), aa[i]--;
i_ = -1, p_ = n * 2;
for (i = 0; i < n * 2; i++) {
int tmp;
if (i > 0)
tmp = aa[i], aa[i] = aa[i - 1], aa[i - 1] = tmp;
memcpy(bb, aa, n * 2 * sizeof *aa);
for (p = 0; p < n * 2; p++)
pp[aa[p]] = p / 2;
if (aa[i] == 0)
p = 0;
else if (aa[i] >= n + 1) {
memset(used, 0, n * sizeof *used), used[0] = 1;
for (a = n * 2 - 1; a >= aa[i]; a--) {
p = pp[a];
while (used[p])
p = (p - 1 + n) % n;
used[p] = 1;
}
} else {
memset(used, 0, n * sizeof *used);
for (a = 0; a <= aa[i]; a++) {
p = pp[a];
while (used[p] && (p != pp[0] || pp[a] < p))
p = (p + 1) % n;
used[p] = 1;
}
p = (p - r % n + n) % n;
}
if (p_ >= p)
p_ = p, i_ = i / 2;
}
printf("%d\n", i_ + 1);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
archery.c: In function 'main':
archery.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%d%d", &n, &r);
| ^~~~~~~~~~~~~~~~~~~~~
archery.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | scanf("%d", &aa[i]), aa[i]--;
| ^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |