Cod sursa(job #1315959)
| Utilizator | Data | 13 ianuarie 2015 13:16:04 | |
|---|---|---|---|
| Problema | Lista lui Andrei | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 1 kb |
#include <stdio.h>
#include <iostream>
int n,m;
bool fol[27][27];
int nr[27],sc[27];
int main()
{
freopen ("nrcuv.in","r",stdin);
freopen ("nrcuv.out","w",stdout);
scanf("%d%d",&n,&m);
char p1,p2;
scanf("%c",&p1);
for(int i=1;i<=m;i++)
{
scanf("%c%c%c",&p1,&p2,&p2);
p1-='a';
p2-='a';
p1++;
p2++;
if(fol[p1][p2]==0)
{
fol[p1][p2]=1;
sc[p1]++;
}
if(fol[p2][p1]==0)
{
fol[p2][p1]=1;
sc[p2]++;
}
scanf("%c",&p1);
}
int s=0;
for(int i=2;i<=n;i++)
{
for(int j=1;j<=26;j++)
{
nr[j]+=26;
nr[j]-=sc[j];
nr[j]%=104659;
}
}
for(int i=1;i<=26;i++) s+=nr[i];
printf("%d\n",s);
}
