hiho week 201 register

Ended

Participants:146

Verdict:Accepted
Score:100 / 100
Submitted:2018-05-07 21:03:56

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int g[27][27];
int n,m;
char s[100005],c1[3];
int f[100005][27];
int solve_min(int a,int b){
    if(a==-1)return b;
    return a<b?a:b;
}
int main()
{
    while(~scanf("%d\n%s",&n,s))
    {
        memset(f,-1,sizeof(f));
        memset(g,0,sizeof(g));
        scanf("%d",&m);
        for(int i=0;i<m;i++)
        {
            scanf("%s",c1);
            g[c1[0]-'a'][c1[1]-'a']=1;
            g[c1[1]-'a'][c1[0]-'a']=1;
        }
        f[0][s[0]-'a']=0;
        for(int i=1;i<n;i++)
        {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX