diff --git a/Easy/Day4/Solution.cpp b/Easy/Day4/Solution.cpp index e69de29..3633c3c 100644 --- a/Easy/Day4/Solution.cpp +++ b/Easy/Day4/Solution.cpp @@ -0,0 +1,45 @@ +#include +#define ll long long +using namespace std; + +const int maxx=30; +int f[maxx]; +string s; +int n,len; + +inline void init() +{ + for(int i=0;i<=26;i++) f[i]=i; +} +inline int getf(int u) +{ + return u==f[u]?u:f[u]=getf(f[u]); +} +inline void merge(int u,int v) +{ + int t1=getf(u); + int t2=getf(v); + if(t1!=t2) f[t1]=t2; +} +int main() +{ + scanf("%d",&n); + init(); + set se; + for(int i=1;i<=n;i++) + { + cin>>s; + len=s.length(); + for(int j=1;j mp; + int ans=0; + for(set ::iterator it=se.begin();it!=se.end();it++) + { + int zz=getf(*it); + if(!mp[zz]) mp[zz]=1,ans++; + } + cout<