#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define piii pair<int, pair<int, int>>
#define v(int) vector<int>
#define si size()
#define foe(i,a,b) for(int i=a;i<=b;++i)
#define fol(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define Bit(mask,i) (1<<i)&mask
#define offBit(mask,i) (1<<i)^mask
#define onBit(mask,i) (1<<i)mask
#define CNT(x) __builtin_popcountll(x)
const int mod = 1e9+7;
const int base = 2309;
const int inf = 1e18;
const int N = 1e6+10;
const int LG = 20;
// ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄▄ ▄ ▄▄▄▄
// █▄▄█ █ █ █ █ █▄▄█ █ █ ██ █ █ ▄▄
// █ █ █▄▄█ █▄▄█ █ █ █▄▄█ █ ██ █▄▄█
int n, k;
int a[500][500];
int dem = 2;
int ans;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
foe(i,1,n)
{
foe(j,1,n)
{
cin >> a[i][j];
}
}
if(k == 1)
{
cout << 1;
return 0;
}
if(k == 2)
{
cout << 2;
return 0;
}
int i = 2;
int j = 1;
while(dem < k)
{
// cout << i << " " << j << "\n";
ans = a[i][j];
int x = i;
int y = j;
i = a[x][y];
j = x;
++ dem;
}
cout << ans;
cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
1075 ms |
1116 KB |
Time limit exceeded |
3 |
Execution timed out |
1016 ms |
1880 KB |
Time limit exceeded |
4 |
Execution timed out |
1054 ms |
2136 KB |
Time limit exceeded |
5 |
Runtime error |
14 ms |
4440 KB |
Execution killed with signal 11 |
6 |
Runtime error |
14 ms |
4444 KB |
Execution killed with signal 11 |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
3 ms |
1368 KB |
Output is correct |
10 |
Correct |
11 ms |
2136 KB |
Output is correct |
11 |
Runtime error |
14 ms |
4440 KB |
Execution killed with signal 11 |
12 |
Runtime error |
15 ms |
4364 KB |
Execution killed with signal 11 |
13 |
Execution timed out |
1012 ms |
600 KB |
Time limit exceeded |
14 |
Execution timed out |
1048 ms |
856 KB |
Time limit exceeded |