hiho week 201 register

Ended

Participants:146

Verdict:Accepted
Score:100 / 100
Submitted:2018-05-08 21:59:35

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>
#include<sstream> //istringstream stm(string); stm >> x;
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
int wrong[26][26];
int last[26];
int main() {
    int i,j,n,m,t;
    string s;
    cin >> n;
    cin >> s;
    cin >> m;
    while(m--) {
        string a;
        cin >> a;
        wrong[a[0] - 'a'][a[1] - 'a'] = 1;
        wrong[a[1] - 'a'][a[0] - 'a'] = 1;
    }
    int len = s.size();
    for(i=0; i<len; i++) {
        int temp = 0;
        for(j=0; j<26; j++) {
            if(!wrong[s[i] - 'a'][j]) {
//              if(last[j]+1 > last[s[i] - 'a'])
//                  printf("%c %c %d\n",i+'a',j+'a',last[j] + 1);
                temp = max(temp,last[j] + 1);
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX