hiho week 201 register

Ended

Participants:146

Verdict:Accepted
Score:100 / 100
Submitted:2018-05-07 09:45:41

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<bits/stdc++.h>
int main()
{
    char s[100010],t[10];
    int N,M;
    int cp[26][26];
    int max[26],ans;
    int i,j,k,l;
    while(scanf("%d %d",&N)!=EOF)
    {
        memset(cp,0,sizeof(cp));
        memset(max,0,sizeof(max));
        ans=0;
        scanf("%s",&s);
        scanf("%d",&M);
        for(i=0;i<M;i++)
        {
            scanf("%s",&t);
            cp[t[0]-'a'][t[1]-'a']=1;
            cp[t[1]-'a'][t[0]-'a']=1;
        }
        for(i=N-1;i>=0;i--)
        {
            l=0;
            k=s[i]-'a';
            for(j=0;j<26;j++)
            {
                if(cp[k][j]==0 && max[j]+1>l)
                {
                    l=max[j]+1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX