Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.072 s | 63 KBi |
#3 |
Correcto
|
0.001 s | 0 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.003 s | 1 KBi |
#6 |
Correcto
|
0.25 s | 63 KBi |
#7 |
Incorrecto
|
0.15 s | 63 KBi |
#8 |
Correcto
|
0.002 s | 0 KBi |
#9 |
Correcto
|
0.002 s | 0 KBi |
#10 |
Correcto
|
0.004 s | 1 KBi |
#11 |
Incorrecto
|
0.001 s | 0 KBi |
#12 |
Correcto
|
0.033 s | 6 KBi |
#13 |
Incorrecto
|
0.012 s | 7 KBi |
#14 |
Correcto
|
0.016 s | 6 KBi |
#15 |
Correcto
|
0.048 s | 8 KBi |
#16 |
Correcto
|
0.019 s | 7 KBi |
#17 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.068 s | 66 KBi |
#18 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.023 s | 63 KBi |
#19 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.023 s | 63 KBi |
#20 |
Error en tiempo de ejecución (NZEC)
Exited with error status 139 run: line 1: 3 Segmentation fault (core dumped) ./a.out |
0.028 s | 63 KBi |
#21 |
Tiempo límite excedido
|
1.057 s | 74 KBi |
#22 |
Tiempo límite excedido
|
1.092 s | 85 KBi |
#23 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed ./a.out |
0.768 s | 125 KBi |
#24 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed ./a.out |
0.437 s | 125 KBi |
#25 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed ./a.out |
0.633 s | 125 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 = 1e4 + 1; int main() { fast_io; lli n, r; cin >> n >> r; const lli LOG2 = log2(1e18) + 10; vector<vector<lli>> g(n); vector<vector<lli>> jump(n, vector<lli>(LOG2, -1)); vi visited(n, false); lli v; REP(u, n) { cin >> v; g[u].pb(v); jump[u][0] = v; } for (lli j = 1; j < LOG2; j++) { for (lli u = 0; u < n; u++) { // cout << "start "<< u << " : " << j << endl; // cout << jump[u][j] << endl; // cout << jump[u][j-1] << endl; // cout << jump[jump[u][j-1]][j-1] << endl; jump[u][j] = jump[jump[u][j - 1]][j - 1]; } } function<lli(lli, lli)> go = [&](lli u, lli pasos) { if (pasos == 0) return u; for (lli j = LOG2-1 ; j >= 0; j--) { if ((1ll << j) <= pasos) { return go(jump[u][j], pasos - (1ll << j)); } } return u; }; vi ans(n); REP(i, n) { lli pos = go(i, r); ans[pos] = i + 1; } cout << ans << endl; return 0; }