Pagini recente » Solutii Autumn Warmup, Runda 2 | Cod sursa (job #729306) | Cod sursa (job #2110511)
#include<fstream>
using namespace std;
ifstream f("nrcuv.in");
ofstream g("nrcuv.out");
int n, sol, m, viz[30][30], fr[30];
char a, b;
int main()
{
f>>n>>m;
for(int i=1;i<=m;i++)
{
f>>a>>b;
if(viz[a-'a'][a-'a']==0)
{
if(a==b)
fr[a-'a']++;
else
{
fr[a-'a']++;
fr[b-'a']++;
}
}
viz[a-'a'][b-'a']=viz[b-'a'][a-'a']=1;
}
/*sol=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<26;j++)
sol=(sol*(26-fr[j]))%104659;
}*/
for(int i=0;i<26;i++)
for(int j=0;j<26;j++)
if(viz[i][j]==0)
{
sol=(sol+1)%104659;
}
g<<sol;
return 0;
}