#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 = (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;
}
Compilation message
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 |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Execution timed out |
2071 ms |
204 KB |
Time limit exceeded |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Correct |
7 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
21 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
22 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
24 |
Correct |
6 ms |
308 KB |
Output is correct |
25 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
28 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
29 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
30 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
33 |
Correct |
5 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
36 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
38 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
39 |
Correct |
8 ms |
204 KB |
Output is correct |
40 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
42 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
43 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
46 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
47 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |