Cod sursa(job #1535408)

Utilizator ErikHEErik Henning ErikHE Data 24 noiembrie 2015 18:59:50
Problema Stramosi Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream f("stramosi.in");
ofstream g("stramosi.out");

int a[250000][20], i, j, n, m, k, p, v[250001], q;

int main()
{
    f>>n>>m;
    for (i=1;i<=n;i++)
        f>>v[i];
   //  for ()
    for (i=1;i<=m;i++)  {
        f>>q>>p;
        for(j=1;j<=p;j++)
            q=v[q];
        g<<q<<"\n";
    }
    return 0;
}