답안 #491072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491072 2021-11-30T12:43:59 Z rainboy Tenis (COI19_tenis) C
51 / 100
500 ms 4884 KB
#include <stdio.h>
#include <string.h>

#define N	100000

int max(int a, int b) { return a > b ? a : b; }

int aa[N], xx[N], yy[N], zz[N], n; char win[N];

void solve() {
	int i, y, z;

	memset(win, 0, n * sizeof *win);
	y = z = -1;
	for (i = 0; i < n; i++) {
		win[aa[i]] = 1;
		y = max(y, yy[aa[i]]);
		z = max(z, zz[aa[i]]);
		if (y == i && z == i)
			break;
	}
}

int main() {
	int q, i, j, a, b;

	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]), aa[i]--;
		xx[aa[i]] = i;
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &a), a--;
		yy[a] = i;
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &a), a--;
		zz[a] = i;
	}
	solve();
	while (q--) {
		int t;

		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &a), a--;
			printf(win[a] ? "DA\n" : "NE\n");
		} else {
			int tmp;

			scanf("%d%d%d", &t, &a, &b), a--, b--;
			if (t == 1) {
				i = xx[a], j = xx[b];
				tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
				xx[a] = j, xx[b] = i;
			} else if (t == 2)
				tmp = yy[a], yy[a] = yy[b], yy[b] = tmp;
			else
				tmp = zz[a], zz[a] = zz[b], zz[b] = tmp;
			solve();
		}
	}
	return 0;
}

Compilation message

tenis.c: In function 'main':
tenis.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
tenis.c:29:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d", &aa[i]), aa[i]--;
      |   ^~~~~~~~~~~~~~~~~~~
tenis.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d", &a), a--;
      |   ^~~~~~~~~~~~~~~
tenis.c:37:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d", &a), a--;
      |   ^~~~~~~~~~~~~~~
tenis.c:44:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |   scanf("%d", &t);
      |   ^~~~~~~~~~~~~~~
tenis.c:46:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |    scanf("%d", &a), a--;
      |    ^~~~~~~~~~~~~~~
tenis.c:51:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |    scanf("%d%d%d", &t, &a, &b), a--, b--;
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 35 ms 3600 KB Output is correct
14 Correct 33 ms 3552 KB Output is correct
15 Correct 31 ms 3524 KB Output is correct
16 Correct 31 ms 3660 KB Output is correct
17 Correct 29 ms 3584 KB Output is correct
18 Correct 30 ms 3600 KB Output is correct
19 Correct 31 ms 3612 KB Output is correct
20 Correct 32 ms 3564 KB Output is correct
21 Correct 32 ms 3608 KB Output is correct
22 Correct 33 ms 3632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 4628 KB Output is correct
2 Correct 56 ms 4680 KB Output is correct
3 Correct 53 ms 4628 KB Output is correct
4 Correct 60 ms 4884 KB Output is correct
5 Correct 54 ms 4636 KB Output is correct
6 Correct 56 ms 4712 KB Output is correct
7 Correct 78 ms 4632 KB Output is correct
8 Correct 51 ms 4616 KB Output is correct
9 Correct 51 ms 4632 KB Output is correct
10 Correct 64 ms 4772 KB Output is correct
11 Correct 51 ms 4628 KB Output is correct
12 Correct 56 ms 4636 KB Output is correct
13 Correct 59 ms 4632 KB Output is correct
14 Correct 64 ms 4712 KB Output is correct
15 Correct 50 ms 4636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 35 ms 3600 KB Output is correct
14 Correct 33 ms 3552 KB Output is correct
15 Correct 31 ms 3524 KB Output is correct
16 Correct 31 ms 3660 KB Output is correct
17 Correct 29 ms 3584 KB Output is correct
18 Correct 30 ms 3600 KB Output is correct
19 Correct 31 ms 3612 KB Output is correct
20 Correct 32 ms 3564 KB Output is correct
21 Correct 32 ms 3608 KB Output is correct
22 Correct 33 ms 3632 KB Output is correct
23 Correct 57 ms 4628 KB Output is correct
24 Correct 56 ms 4680 KB Output is correct
25 Correct 53 ms 4628 KB Output is correct
26 Correct 60 ms 4884 KB Output is correct
27 Correct 54 ms 4636 KB Output is correct
28 Correct 56 ms 4712 KB Output is correct
29 Correct 78 ms 4632 KB Output is correct
30 Correct 51 ms 4616 KB Output is correct
31 Correct 51 ms 4632 KB Output is correct
32 Correct 64 ms 4772 KB Output is correct
33 Correct 51 ms 4628 KB Output is correct
34 Correct 56 ms 4636 KB Output is correct
35 Correct 59 ms 4632 KB Output is correct
36 Correct 64 ms 4712 KB Output is correct
37 Correct 50 ms 4636 KB Output is correct
38 Execution timed out 1078 ms 3800 KB Time limit exceeded
39 Halted 0 ms 0 KB -