-
Notifications
You must be signed in to change notification settings - Fork 0
/
10685-Nature.cpp
81 lines (73 loc) · 1.64 KB
/
10685-Nature.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include<bits/stdc++.h>
using namespace std;
#define asgnarr(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define fast ios_base::sync_with_stdio(false)
#define mem(a,x) memset(a,x,sizeof(a))
#define pii pair<int,int>
#define psi pair<string,int>
#define pss pair<string,string>
#define pll pair<long long,long long>
#define pls pair<long long,string>
#define pb push_back
typedef long long lli;
typedef long li;
typedef unsigned long long ulli;
typedef unsigned long int uli;
typedef unsigned int ui;
typedef long double ld;
inline int iseven(int x){return x&1?0:1;}
inline bool is_double(double x){
double y=x-(int)x;
return (y==x?true:false);
}
map<string,string> par;
string findpar(string s)
{
if(par[s]==s)
return s;
string x=par[s];
return par[s]=findpar(x);
}
int main()
{
fast;
int c,r;
ofstream out("G:\\ab.txt");
while(cin>>c>>r)
{
string a;
if(c==0 && r==0)
break;
vector<string >v;
for(int i=0;i<c;i++)
{
cin>>a;
par[a]=a;
v.pb(a);
}
string b,x,y;
for(int i=0;i<r;i++)
{
cin>>a>>b;
x=findpar(a);
y=findpar(b);
par[y]=x;
}
map<string,int> mp;
for(int i=0;i<v.size();i++)
{
mp[findpar(v[i])]++;
}
int max=0;
for(int i=0;i<v.size();i++)
{
if(mp[v[i]]>max)
max=mp[v[i]];
}
cout<<max<<endl;
out<<max<<endl;
map<string,string> temp;
par=temp;
}
out.close();
}