Cod sursa(job #2293953)

Utilizator richard26Francu Richard richard26 Data 1 decembrie 2018 19:02:16
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <bits/stdc++.h>

using namespace std;

char s[10000001], vocabular[50001], ch[50001], aux[10000001];
int main()

{
	ifstream f("abc2.in");
	ofstream g("abc2.out");

	unordered_map<string, int > mp;
	int l, nr = 0;
	f>>s;
	strcpy(aux, s);
	while(f>>vocabular)
	{
		mp[vocabular] = 1;
		l = strlen(vocabular);
		
	}

	int ll = strlen(s) ;
	int LL = ll;
	for (int i = 1; i <= (ll - 1) / (l - 1); i++)
	{
		strcpy(aux, s);
		strcpy(aux + l, aux + LL);
		strcpy(ch,aux);
		if(mp.find(ch) != mp.end()) nr++;
		strcpy(s, s + 1);
		LL--;
	}
	g<<nr;
	return 0;


}