# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481417 | rainboy | Političari (COCI20_politicari) | C11 | 25 ms | 2216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]), t = 0;
while (t < t_)
k = kk[j][i], i = j, j = k, t++;
}
printf("%d\n", i + 1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |