Pagini recente »
Clasament lasm_29_10_2019_10_12b
|
Istoria paginii runda/lmk_11_vs/clasament
|
Cod sursă (job #546354)
|
Rating Arseniu VIctor Stefan (ArseniuVictor)
|
Cod sursă (job #98035)
Cod sursă (job
#98035)
//Iisuse miluieste - ma
#include<fstream>
#include<cctype>
#define GOD 100000
#define Saint -7
using namespace std;
long int a[ GOD ] , i , k , p , r , gasit ;
//Doamne ajuta!
int searchopen( long int v[ ] , long int n )
{
i = n - 2;
gasit = 0;
while( ( i >= 0 ) && ( !gasit ) )
{
if ( !v[ i ] )
gasit = 1;
i --;
}
return ( i + 1 );
}
//Doamne ajuta!
int searchclose( long int v[ ] , long int n )
{
i = 0;
gasit = 0;
while( ( i < n ) && ( !gasit ) )
{
if( v[ i ] == -1 )
gasit = 1;
i ++;
}
return ( i - 1 );
}
//Doamne ajuta!
int main()
{
ifstream f("bizar.in");
ofstream g("bizar.out");
char next;
i = 0;
while( !f.eof() )
{
f>>next;
if( !isspace( next ) )
{
if( isdigit( next ) )
{
r = 0;
while( isdigit( next ) )
{
r = r * 10 + ( next - '0' );
f>>next;
}
a[ i ] = r;
i ++;
}
if( next == '(' )
{
a[ i ] = 0 ;
i ++;
}
if( next == ')' )
{
a[ i ] = -1;
i ++;
}
}
}
gasit = i ;
while( gasit > 1 )
{
k = searchclose( a , i );
p = searchopen ( a , k );
a[ p - 1 ] = a[ ( a[ p - 1 ] % ( k - p - 1 ) ) + p ];
for( r = p ; r <= k ; r ++ )
a[ r ] = Saint;
gasit = 0;
for( r = 0 ; r < i ; r ++ )
{
if ( a[ r ] != Saint )
a[ gasit ] = a[ r ];
gasit ++;
}
i = gasit;
}
g<<a[ 0 ];
f.close();
g.close();
return 0;
//Doamne ajuta!
}