Pagini recente » Cod sursa (job #3215505) | Cod sursa (job #1100361) | Cod sursa (job #3190017) | Cod sursa (job #1422382) | Cod sursa (job #3278641)
#include <fstream>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <string>
using namespace std;
ifstream fin("sponsor.in");
ofstream fout("sponsor.out");
unordered_map<string, int> M;
vector<string> sol = {"IF","OI","LN","AI","MO","PR","IM","AA","DT","DC","EA","IF"};
int main()
{
int task, n;
fin >> task >> n;
fin.get();
for (int i = 1; i <= n; i++)
{
string s;
getline(fin, s);
string aux;
aux += s[0];
aux += s.back();
M[aux]++;
}
int p = 1;
for (auto it : sol)
if (M[it])
p *= M[it], M[it] = 0;
if (task == 1)
fout << p;
return 0;
}