-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDCE205.java
More file actions
29 lines (28 loc) · 768 Bytes
/
DCE205.java
File metadata and controls
29 lines (28 loc) · 768 Bytes
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
import java.util.*;
class DCE205{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t=Integer.parseInt(sc.nextLine());
for(;t>0;t--){
int n=Integer.parseInt(sc.nextLine());
int noj=0,nos=0;
for(int i=0;i<n;i++){
String in=sc.nextLine();
for(int j=0;j<in.length();j++){
if(in.charAt(j)=='J'||in.charAt(j)=='j')noj++;
if(in.charAt(j)=='S'||in.charAt(j)=='s')nos++;
}
}
int noj2=0,nos2=0;
for(int i=0;i<n;i++){
String in=sc.nextLine();
for(int j=0;j<in.length();j++){
if(in.charAt(j)=='J'||in.charAt(j)=='j')noj2++;
if(in.charAt(j)=='S'||in.charAt(j)=='s')nos2++;
}
}
if(nos==nos2 && noj==noj2){System.out.println("YES");}
else{System.out.println("NO");}
}
}
}