Pagini recente » Cod sursa (job #2066860) | Cod sursa (job #834373) | Cod sursa (job #2268703) | Cod sursa (job #375336) | Cod sursa (job #748616)
Cod sursa(job #748616)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("stramosi.in");
ofstream out("stramosi.out");
int const N=250025;
int n,m,mat[N][N];
void citire ()
{
in>>n>>m;
for(int i=1;i<=n;i++)
in>>mat[1][i];
}
void complet ()
{
for(int i=2;i<=m;i++)
for(int j=1;j<=n;j++)
mat[i][j]=mat[i-1][mat[i-1][j]];
//mat[2][j]=mat[1][mat[1][j]];
}
int afla (a,b)
{
if()
}
void rezult ()
{
int a,b;
for(int i=1;i<=m;i++)
{
in>>a>>b;
out<<afla(a,b)<<"\n";
}
}
int main()
{
citire();
complet();
rezult();
return 0;
}