# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
253852 | 2020-07-28T22:34:22 Z | blacktulip | Političari (COCI20_politicari) | C++17 | 42 ms | 3448 KB |
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define endl "\n" #define int long long #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 505; const lo mod = 1000000007; int n,m,b[li],a[li][li],k,flag,t,vis[li][li]; int cev; string s; vector<int> v; main(void){ scanf("%lld %lld",&n,&k); FOR{ for(int j=1;j<=n;j++){ scanf("%lld",&a[i][j]); } } if(k==1){printf("1\n");return 0;} int gel=1; int node=2; cev=2; v.pb(1); v.pb(2); while(cev<k){ int at=node; if(vis[node][gel]){ printf("%lld\n",v[vis[node][gel]+(k-vis[node][gel])%(cev-vis[node][gel])-1]); return 0; } vis[node][gel]=cev; node=a[node][gel]; gel=at; cev++; v.pb(node); } printf("%lld\n",node); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 7 ms | 2048 KB | Output is correct |
3 | Correct | 20 ms | 2688 KB | Output is correct |
4 | Correct | 26 ms | 2956 KB | Output is correct |
5 | Correct | 31 ms | 3192 KB | Output is correct |
6 | Correct | 30 ms | 2944 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 1152 KB | Output is correct |
9 | Correct | 8 ms | 2048 KB | Output is correct |
10 | Correct | 24 ms | 2816 KB | Output is correct |
11 | Correct | 42 ms | 3448 KB | Output is correct |
12 | Correct | 33 ms | 3320 KB | Output is correct |
13 | Correct | 1 ms | 640 KB | Output is correct |
14 | Correct | 3 ms | 1280 KB | Output is correct |