[Offer收割]编程练习赛88 register

Ended

Participants:49

Verdict:Wrong Answer
Score:0 / 100
Submitted:2018-12-23 14:25: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 <bits/stdc++.h>
using namespace std;
#define L 100001
int n,fa[L],ans;
void build(int qwq) {for(int i=1;i<=qwq;i++) fa[i]=i;return ;}
int find(const int &x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
bool che(const int &x,const int &y){return find(x)==find(y);}
void mer(const int &x,const int &y) {if(!che(x,y)) fa[fa[x]]=fa[y];return ;}
void solve()
{
    ans=0;
    string a;
    vector < int > b;
    cin>>a;
    build(n);
    while(n--)
    {
        char x,y;
        cin>>x>>y;
        mer(x-'a',y-'a');
    }
    for (n=0;n<26;n++)
        if (n!=7&&che(n,7))
            b.push_back(n);
    for (int i=0;i<a.length();i++)
    {
        int tag=0;
        for (int j=0;j<b.size();j++)
            if (b[j]+'a'==a[i]) {tag=1;break;}
        if (tag) ans++;
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX