| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 749927 | Trunkty | Političari (COCI20_politicari) | C++14 | 239 ms | 128432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,k;
int jump[250005][65];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
if(k<=2){
cout << k << "\n";
return 0;
}
k -= 2;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
int a;
cin >> a;
if(a){
jump[(i-1)*n+(j-1)][0] = (a-1)*n+(i-1);
}
}
}
for(int j=1;j<=63;j++){
for(int i=0;i<n*n;i++){
jump[i][j] = jump[jump[i][j-1]][j-1];
}
}
int curr = 1*n+0;
for(int j=63;j>=0;j--){
if(k&(1LL<<j)){
curr = jump[curr][j];
}
}
cout << curr/n+1 << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
