Mai intai trebuie sa te autentifici.
Cod sursa(job #3310636)
| Utilizator | Data | 15 septembrie 2025 17:52:52 | |
|---|---|---|---|
| Problema | Stramosi | Scor | 60 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream in("stramosi.in");
ofstream out("stramosi.out");
const int nmax = 250000, lgmax = 18;
int n, nrq, node, topp, father[nmax + 2];
int main(){
in>>n>>nrq;
for(int i = 1; i <= n; i++){
in>>father[i];
}
for(int i = 1; i <= nrq; i++){
in>>node>>topp;
for(int it = 1; it <= topp; it++)
node = father[node];
out<<node<<"\n";
}
return 0;
}
