Cod sursa(job #1536868)

Utilizator LegionHagiu Stefan Legion Data 26 noiembrie 2015 18:54:39
Problema Abc2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
#include <set>
#include <string>
using namespace std;
set<string> a;
int main()
{
	ifstream in("abc2.in");
	ofstream out("abc2.out");
	string s,x,d;
	int total = 0, i;
	in >> s;
	while (!in.eof())
	{
		in >> x;
		a.insert(x);
	}
	d = s.substr(0, x.length());
	if (a.find(d) != a.end()){ total++; }
	for (i = x.length(); i < s.size(); i++)
	{
		d.push_back(s[i]);
		d.erase(d.begin());
		if (a.find(d) != a.end()){ total++; }
	}
	out << total;
}