Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Correcto
|
0.002 s | 0 KBi |
#3 |
Correcto
|
0.004 s | 0 KBi |
#4 |
Correcto
|
0.002 s | 0 KBi |
#5 |
Correcto
|
0.002 s | 0 KBi |
#6 |
Correcto
|
0.132 s | 25 KBi |
#7 |
Correcto
|
0.052 s | 25 KBi |
#8 |
Correcto
|
0.004 s | 0 KBi |
#9 |
Correcto
|
0.002 s | 0 KBi |
#10 |
Correcto
|
0.001 s | 0 KBi |
#11 |
Correcto
|
0.001 s | 0 KBi |
#12 |
Correcto
|
0.004 s | 3 KBi |
#13 |
Correcto
|
0.012 s | 3 KBi |
#14 |
Correcto
|
0.012 s | 3 KBi |
#15 |
Correcto
|
0.005 s | 3 KBi |
#16 |
Correcto
|
0.012 s | 3 KBi |
#17 |
Correcto
|
0.005 s | 0 KBi |
#18 |
Correcto
|
0.002 s | 0 KBi |
#19 |
Correcto
|
0.003 s | 0 KBi |
#20 |
Correcto
|
0.001 s | 0 KBi |
#21 |
Correcto
|
0.278 s | 25 KBi |
#22 |
Correcto
|
0.42 s | 25 KBi |
#23 |
Correcto
|
0.44 s | 25 KBi |
#24 |
Correcto
|
0.207 s | 30 KBi |
#25 |
Correcto
|
0.491 s | 25 KBi |
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define pb push_back #define ff first #define ss second #define ii pair<int, int> #define vi vector<int> #define vii vector<ii> #define lli long long int #define fast_io \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; ostream &operator<<(ostream &os, const vector<int> &v) { for (auto const &i : v) { os << i << " "; } os << endl; return os; } const lli mod = (1e9) + 7; const int N = 1e5 + 5; const lli LOG2 = 62; int jump[N][LOG2]; int go(int u, lli R){ int ans = u; for(int i = 0;R;R >>= 1, i++){ if(R & 1){ ans = jump[ans][i]; } } return ans; } int main() { fast_io; lli n, r; cin >> n >> r; lli v; REP(u, n) { cin >> v; jump[u][0] = v; } for (lli j = 1; j < LOG2; j++) { for (lli u = 0; u < n; u++) { jump[u][j] = jump[jump[u][j - 1]][j - 1]; } } vi ans(n); REP(i, n) { lli pos = go(i, r); ans[pos] = i + 1; } cout << ans << endl; return 0; }