-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1397A-Juggling Letters.cpp
66 lines (53 loc) · 1.11 KB
/
1397A-Juggling Letters.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
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int t,i,j,k;
cin>>t;
int n,by[t];
for(i=0;i<t;i++)
{
cin>>n;
char ch[n][1005];
for(j=0;j<n;j++)
cin>>ch[j];
int chck[30];
for(j=0;j<30;j++)
chck[j]=0;
for(j=0;j<n;j++)
{
for(k=0;k<strlen(ch[j]);k++)
{
int x=ch[j][k]-97;
// cout<<ch[j][k]<<"& "<<x<<endl;
chck[x]+=1;
}
}
int counter=0;
for(j=0;j<30;j++)
{ // cout<<j<<"="<<chck[j]<<endl;
if(chck[j]>=n)
counter++;
}
by[i]=0;
for(j=0;j<26;j++)
{
if(chck[j]!=0 && chck[j]%n==0)
{
by[i]++;
}
else if(chck[j]!=0 && chck[j]%n!=0)
{
by[i]=0;
break;
}
}
}
for(i=0;i<t;i++)
{
if(by[i]!=0)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}