# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
340091 | 2020-12-26T21:19:30 Z | Hazem | Političari (COCI20_politicari) | C++14 | 365 ms | 140416 KB |
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 5e2 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; pair<int,int> nxt[N][N][70]; int main() { //freopen("out.txt","w",stdout); LL n,k; scanf("%lld%lld",&n,&k); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++){ int x;cin>>x; nxt[i][j][0] = {x,i}; } if(k==1){ puts("1"); return 0; } for(int j=1;j<=60;j++) for(int i=1;i<=n;i++) for(int k=1;k<=n;k++){ if(k==i)continue; pair<int,int>p = nxt[i][k][j-1]; nxt[i][k][j] = nxt[p.F][p.S][j-1]; } k -= 2; pair<int,int>cur = {2,1}; for(LL i=60;i>=0;i--) if((1ll<<i)<=k) cur = nxt[cur.F][cur.S][i],k -= 1ll<<i; printf("%d\n",cur.F); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 46 ms | 27244 KB | Output is correct |
3 | Correct | 222 ms | 88940 KB | Output is correct |
4 | Correct | 286 ms | 113900 KB | Output is correct |
5 | Correct | 365 ms | 140268 KB | Output is correct |
6 | Correct | 353 ms | 140268 KB | Output is correct |
7 | Correct | 1 ms | 620 KB | Output is correct |
8 | Correct | 18 ms | 10988 KB | Output is correct |
9 | Correct | 54 ms | 30700 KB | Output is correct |
10 | Correct | 283 ms | 113900 KB | Output is correct |
11 | Correct | 352 ms | 140416 KB | Output is correct |
12 | Correct | 353 ms | 140268 KB | Output is correct |
13 | Correct | 2 ms | 2028 KB | Output is correct |
14 | Correct | 16 ms | 10860 KB | Output is correct |