Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#2 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#3 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#4 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#5 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#6 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#7 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#8 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#9 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#10 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#11 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#12 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#13 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#14 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#15 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#16 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#17 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#18 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#19 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#20 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#21 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#22 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#23 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#24 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
||
#25 |
Error de compilación
main.cpp:52:19: error: use of undeclared identifier 'lca' ans = lca[ans][i]; ^ 1 error generated. |
#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) + 1; 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 R) { int ans = u; for(int i = 0;R;R >>= 1, i++){ if(R & 1){ ans = lca[ans][i]; } } return ans; }; vi ans(n); REP(i, n) { lli pos = go(i, r); ans[pos] = i + 1; } cout << ans << endl; return 0; }