This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 200000
int main() {
static int aa[N * 2], bb[N * 2];
int n, r, h, h_, i, i_, j;
scanf("%d%d", &n, &r), r = (r - n * 2) % n + n * 2;
if (n > 200) {
printf(":(\n");
return 0;
}
for (i = 0; i < n * 2; i++)
scanf("%d", &aa[i]);
i_ = -1, h_ = 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 (j = 0; j < r; j++) {
for (h = 0; h < n * 2; h += 2)
if (bb[h] > bb[h + 1])
tmp = bb[h], bb[h] = bb[h + 1], bb[h + 1] = tmp;
for (h = 2; h < n * 2; h++)
tmp = bb[h], bb[h] = bb[h - 1], bb[h - 1] = tmp;
}
for (h = 0; h < n * 2; h++)
if (bb[h] == aa[i]) {
h /= 2;
break;
}
if (h_ >= h)
h_ = h, i_ = i / 2;
}
printf("%d\n", i_ + 1);
return 0;
}
Compilation message (stderr)
archery.c: In function 'main':
archery.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%d%d", &n, &r), r = (r - n * 2) % n + n * 2;
| ^~~~~~~~~~~~~~~~~~~~~
archery.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d", &aa[i]);
| ^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |