Cod sursa(job #2292701)
Utilizator | Arhire Andrei Andrei-27 | Data | 29 noiembrie 2018 20:45:34 |
---|---|---|---|
Problema | Stramosi | Scor | 70 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std ;
const int NR = 250005 ;
ifstream f ( "stramosi.in" ) ;
ofstream g ( "stramosi.out" ) ;
int c [ 505 ][ 505 ] ;
int n , m ;
int main ()
{
f >> n >> m ;
for ( int i = 1 ; i <= n ; ++ i ) f >> c[ i / 500 ][ i % 500 ] ;
while ( m -- )
{
int a , b ; f >> a >> b ;
while ( b -- )
{
a = c [ a / 500 ][ a % 500 ] ;
if ( !a ) break ;
}
g << a << "\n" ;
}
return 0 ;
}