Pagini recente »
Diferențe pentru runda/2014-12-09-clasa-5-tema-18 între reviziile 2 și 1
|
Monitorul de evaluare
|
Monitorul de evaluare
|
Monitorul de evaluare
|
Cod sursă (job #377145)
Cod sursă (job
#377145)
#include <bits/stdc++.h>
using namespace std;
char const in [] = "bart.in";
char const out [] = "bart.out";
int const NM = 5000007;
char v [NM];
int st [NM];
ifstream f (in);
ofstream g (out);
int main()
{
int n , atpos = 0 , i , att = 1;
f >> v ;
n = strlen (v );
for(i = 1 ; i <= n ; ++ i)
{
while (atpos && (v [atpos] != v [att]))
{
atpos = st [atpos - 1];
}
if (v [atpos] == v [att])
++ atpos;
st [att ++ ] = atpos;
}
v [n - st[n - 1]] = '\0';
g << v ;
f.close();
g.close();
return 0;
}