Contest Duration: - (local time) (100 minutes) Back to Home

Submission #13093461

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N; ll K; int A[201010];
int dp[61][201010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> K;
rep(i, 0, N) cin >> A[i], A[i]--;

rep(cu, 0, N) dp[0][cu] = A[cu];
rep(p, 1, 61) rep(cu, 0, N) dp[p][cu] = dp[p - 1][dp[p - 1][cu]];

int cu = 0;
rrep(p, 60, 0) if (K & (1LL << p)) cu = dp[p][cu];
cout << cu + 1 << endl;
}

```

#### Submission Info

Submission Time 2020-05-10 23:12:28+0900 D - Teleporter hamayanhamayan C++ (GCC 9.2.1) 400 1712 Byte AC 71 ms 52332 KB

#### Judge Result

Score / Max Score 0 / 0 400 / 400
Status
 AC × 2
 AC × 57
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt, sub1_49.txt, sub1_50.txt, sub1_51.txt, sub1_52.txt, sub1_53.txt, sub1_54.txt, sub1_55.txt
Case Name Status Exec Time Memory
sample_01.txt AC 2 ms 3848 KB
sample_02.txt AC 2 ms 3788 KB
sub1_01.txt AC 11 ms 10148 KB
sub1_02.txt AC 36 ms 35764 KB
sub1_03.txt AC 13 ms 8400 KB
sub1_04.txt AC 63 ms 52320 KB
sub1_05.txt AC 55 ms 52160 KB
sub1_06.txt AC 38 ms 36568 KB
sub1_07.txt AC 40 ms 33768 KB
sub1_08.txt AC 56 ms 52296 KB
sub1_09.txt AC 39 ms 33416 KB
sub1_10.txt AC 53 ms 46180 KB
sub1_11.txt AC 30 ms 23948 KB
sub1_12.txt AC 61 ms 52172 KB
sub1_13.txt AC 65 ms 52292 KB
sub1_14.txt AC 65 ms 52220 KB
sub1_15.txt AC 40 ms 36352 KB
sub1_16.txt AC 56 ms 52268 KB
sub1_17.txt AC 39 ms 36516 KB
sub1_18.txt AC 60 ms 52220 KB
sub1_19.txt AC 16 ms 13192 KB
sub1_20.txt AC 56 ms 52156 KB
sub1_21.txt AC 46 ms 34764 KB
sub1_22.txt AC 53 ms 39580 KB
sub1_23.txt AC 29 ms 24576 KB
sub1_24.txt AC 55 ms 42936 KB
sub1_25.txt AC 52 ms 41620 KB
sub1_26.txt AC 42 ms 33556 KB
sub1_27.txt AC 39 ms 30916 KB
sub1_28.txt AC 44 ms 36576 KB
sub1_29.txt AC 19 ms 15568 KB
sub1_30.txt AC 39 ms 28880 KB
sub1_31.txt AC 8 ms 6416 KB
sub1_32.txt AC 44 ms 35696 KB
sub1_33.txt AC 20 ms 17120 KB
sub1_34.txt AC 38 ms 31216 KB
sub1_35.txt AC 7 ms 6540 KB
sub1_36.txt AC 62 ms 49452 KB
sub1_37.txt AC 59 ms 49168 KB
sub1_38.txt AC 65 ms 50200 KB
sub1_39.txt AC 63 ms 47916 KB
sub1_40.txt AC 17 ms 13004 KB
sub1_41.txt AC 66 ms 52224 KB
sub1_42.txt AC 67 ms 52224 KB
sub1_43.txt AC 70 ms 52332 KB
sub1_44.txt AC 70 ms 52200 KB
sub1_45.txt AC 66 ms 52280 KB
sub1_46.txt AC 55 ms 52216 KB
sub1_47.txt AC 71 ms 52196 KB
sub1_48.txt AC 71 ms 52172 KB
sub1_49.txt AC 65 ms 52264 KB
sub1_50.txt AC 60 ms 52264 KB
sub1_51.txt AC 52 ms 47124 KB
sub1_52.txt AC 32 ms 29024 KB
sub1_53.txt AC 19 ms 15676 KB
sub1_54.txt AC 62 ms 52264 KB
sub1_55.txt AC 58 ms 52332 KB