답안 #1067871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067871 2024-08-21T04:56:42 Z sleepntsheep Archery (IOI09_archery) C++17
10 / 100
2000 ms 472 KB
#include <cstdio>
#include <array>
using namespace std;

int n, r, s[400], ans = 1e9, q[400], opt;

int check() {
	array<int, 400> p, e;
	for (int i = 0; i < n * 2; ++i) p[i] = q[i];

	for (int ii = 0; ii < r; ++ii) {
		int u = p[0], v = p[1];
		if (s[u] < s[v]) e[0] = u, e[n * 2 - 1] = v;
		else e[0] = v, e[n * 2 - 1] = u;

		for (int j = 2; j < n * 2; j += 2) {
			int u = p[j], v = p[j + 1];
			if (s[u] < s[v]) {
				e[(j - 2) + 1] = u;
				e[j] = v;
			} else {
				e[1 + (j - 2)] = v;
				e[j] = u;
			}
		}
		p = e;
	}

	for (int i = 0; i < 400; ++i) if (e[i] == 0) return (i + 1) / 2;
	__builtin_unreachable();
}

int main() {
	scanf("%d%d", &n, &r);
	for (int i = 0; i < n * 2; ++i)
		scanf("%d", s + i), q[i] = i;

	if (ans >= check()) ans = check(), opt = 1;

	for (int i = 1; i < n * 2; ++i) {
		int o = 0;
		for (int j = 1; j <= i; ++j) q[o++] = j;
		q[o++] = 0;
		for (int j = i + 1; j < n * 2; ++j) q[o++] = j;

		if (ans >= check()) ans = check(), opt = (i + 2) / 2;
	}

	printf("%d", opt);
}

Compilation message

archery.cpp: In function 'int main()':
archery.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d%d", &n, &r);
      |  ~~~~~^~~~~~~~~~~~~~~~
archery.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d", s + i), q[i] = i;
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Execution timed out 2032 ms 344 KB Time limit exceeded
4 Runtime error 1 ms 348 KB Execution killed with signal 11
5 Correct 1 ms 348 KB Output is correct
6 Execution timed out 2088 ms 348 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Execution timed out 2089 ms 348 KB Time limit exceeded
3 Runtime error 2 ms 344 KB Execution killed with signal 11
4 Runtime error 1 ms 348 KB Execution killed with signal 11
5 Runtime error 2 ms 472 KB Execution killed with signal 11
6 Execution timed out 2028 ms 344 KB Time limit exceeded
7 Runtime error 1 ms 348 KB Execution killed with signal 11
8 Runtime error 1 ms 348 KB Execution killed with signal 11
9 Runtime error 1 ms 348 KB Execution killed with signal 11
10 Runtime error 1 ms 348 KB Execution killed with signal 11
11 Runtime error 1 ms 348 KB Execution killed with signal 11
12 Runtime error 1 ms 348 KB Execution killed with signal 11
13 Runtime error 1 ms 348 KB Execution killed with signal 11
14 Runtime error 1 ms 348 KB Execution killed with signal 11
15 Runtime error 1 ms 348 KB Execution killed with signal 11
16 Correct 101 ms 348 KB Output is correct
17 Runtime error 1 ms 348 KB Execution killed with signal 11
18 Incorrect 7 ms 348 KB Output isn't correct
19 Runtime error 0 ms 348 KB Execution killed with signal 11
20 Runtime error 0 ms 348 KB Execution killed with signal 11
21 Runtime error 1 ms 348 KB Execution killed with signal 11
22 Runtime error 1 ms 344 KB Execution killed with signal 11
23 Runtime error 1 ms 436 KB Execution killed with signal 11
24 Correct 46 ms 348 KB Output is correct
25 Runtime error 1 ms 348 KB Execution killed with signal 11
26 Runtime error 1 ms 344 KB Execution killed with signal 11
27 Runtime error 2 ms 344 KB Execution killed with signal 11
28 Runtime error 1 ms 348 KB Execution killed with signal 11
29 Runtime error 1 ms 440 KB Execution killed with signal 11
30 Runtime error 1 ms 348 KB Execution killed with signal 11
31 Runtime error 0 ms 348 KB Execution killed with signal 11
32 Runtime error 1 ms 348 KB Execution killed with signal 11
33 Correct 76 ms 412 KB Output is correct
34 Execution timed out 2058 ms 348 KB Time limit exceeded
35 Runtime error 1 ms 348 KB Execution killed with signal 11
36 Runtime error 1 ms 348 KB Execution killed with signal 11
37 Runtime error 1 ms 348 KB Execution killed with signal 11
38 Runtime error 1 ms 348 KB Execution killed with signal 11
39 Execution timed out 2097 ms 348 KB Time limit exceeded
40 Runtime error 0 ms 344 KB Execution killed with signal 11
41 Runtime error 0 ms 348 KB Execution killed with signal 11
42 Runtime error 1 ms 348 KB Execution killed with signal 11
43 Runtime error 0 ms 348 KB Execution killed with signal 11
44 Runtime error 1 ms 348 KB Execution killed with signal 11
45 Runtime error 1 ms 348 KB Execution killed with signal 11
46 Runtime error 1 ms 428 KB Execution killed with signal 11
47 Runtime error 0 ms 348 KB Execution killed with signal 11