답안 #481416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481416 2021-10-20T18:11:51 Z rainboy Političari (COCI20_politicari) C
15 / 70
22 ms 3136 KB
#include <stdio.h>

#define N	500

int main() {
	static int kk[N][N], tt[N][N];
	int n, i, j, k, t;
	long long t_;

	scanf("%d%lld", &n, &t_);
	if (t_ <= 2) {
		printf("%lld\n", t_);
		return 0;
	}
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			scanf("%d", &kk[i][j]), kk[i][j]--;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			tt[i][j] = -1;
	i = 0, j = 1, t = 1;
	while (t < t_ && tt[i][j] == -1) {
		tt[i][j] = t;
		k = kk[j][i], i = j, j = k, t++;
	}
	if (t != t_) {
		t_ = (t_ - t) % (t - tt[i][j]);
		while (t < t_)
			k = kk[j][i], i = j, j = k, t++;
	}
	printf("%d\n", i + 1);
	return 0;
}

Compilation message

politicari.c: In function 'main':
politicari.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%lld", &n, &t_);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
politicari.c:17:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf("%d", &kk[i][j]), kk[i][j]--;
      |    ^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 4 ms 1248 KB Output isn't correct
3 Incorrect 14 ms 2320 KB Output isn't correct
4 Incorrect 19 ms 2708 KB Output isn't correct
5 Incorrect 22 ms 3096 KB Output isn't correct
6 Incorrect 21 ms 3128 KB Output isn't correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 2 ms 844 KB Output isn't correct
9 Incorrect 5 ms 1364 KB Output isn't correct
10 Incorrect 18 ms 2764 KB Output isn't correct
11 Incorrect 21 ms 3136 KB Output isn't correct
12 Correct 22 ms 3076 KB Output is correct
13 Incorrect 0 ms 460 KB Output isn't correct
14 Incorrect 3 ms 764 KB Output isn't correct