hiho week 284 register

Ended

Participants:81

Verdict:Accepted
Score:100 / 100
Submitted:2019-12-10 00:37:12

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 <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;
const int N = 55;
int n, inf = 0x3f3f3f3f;
unordered_map<char, int> ma, mb, mc;
vector<string> v;
int cur[N][3], cnt[N];;
int match(const char * a, const char * b) {
    int len = strlen(a);
    // cout << "len:" << len << endl;
    bool vis[N];
    memset(vis, 0, sizeof vis);
    int res = 0;
    ma.clear(), mb.clear();
    for (int i = 0; i < len; ++i) {
        ma[a[i]] = i;
        mb[b[i]] = i;
    }
    for (int i = 0; i < len; ++i) {
        if (a[i] == b[i]) continue;
        else if (vis[i]) continue;
        int j = i;
        while (b[j] != a[i]) {
            vis[j] = true;
            res++;
            j = ma[b[j]];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX