Cod sursă (job #93590)

Utilizator avatar dummy contdezactivat dummy IP ascuns
Problemă Bart (clasele 9-10) Compilator cpp | 0,57 kb
Rundă Tema 8 clasele 9-10 2014/15 Status evaluat
Dată 29 nov. 2014 23:17:40 Scor 0
//Iisuse miluieste - ma
#include<fstream>
#define GOD 500000
using namespace std;
int main()
{
ifstream f("bart.in");
ofstream g("bart.out");
char p[ GOD ];
int pi[ GOD ] , k, i , q, m;
i = 0;
while(!f.eof())
      {
       f>>p[ i ];
       i ++;
       }
f.close();
k = 0;
pi[ 0 ] = 0;
for( q = 1; q < i ; q ++ )
    {
     while(( k > 0 ) && ( p[ k ] != p[ q ]))
           k = pi[ k - 1 ];
     if( p[ k ] == p[ q ] )
        k ++;
     pi[ q ] = k;
     }
for( q = 0 ; q < i - k ;q ++ )
    g<<p[ q ]; 
g.close();
return 0;
}