-
-
Save theortsac/3b4d579f2f6c0aa99377244b021a9adb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int MAXN = 2e5 + 10; | |
const int MAXLOG = 30; | |
int prox[MAXLOG + 1][MAXN]; | |
int main() { | |
int n, q; | |
cin >> n >> q; // só usaremos o valor q no futuro | |
for (int x = 1; x <= n; x++) { | |
cin >> prox[0][x]; | |
} | |
for (int i = 1; i <= MAXLOG; i++) { | |
for (int x = 1; x <= n; x++) { | |
prox[i][x] = prox[i-1][[prox[i-1][x]]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment