제출 #481416

#제출 시각아이디문제언어결과실행 시간메모리
481416rainboyPolitičari (COCI20_politicari)C11
15 / 70
22 ms3136 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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]--;
      |    ^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...