Cod sursa(job #1536873)

Utilizator LegionHagiu Stefan Legion Data 26 noiembrie 2015 18:56:33
Problema Abc2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <string>
using namespace std;
unordered_map<string,bool> 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[x] = 1;
	}
	d = s.substr(0, x.length());
	if (a[d]==1){ total++; }
	for (i = x.length(); i < s.size(); i++)
	{
		d.push_back(s[i]);
		d.erase(d.begin());
		if (a[d]==1){ total++; }
	}
	out << total;
}