File tree 1 file changed +65
-0
lines changed
1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Problem Link: https://www.codechef.com/LTIME91B/problems/SWAP10HG
3
+ */
4
+
5
+
6
+
7
+
8
+
9
+ #include < bits/stdc++.h>
10
+ using namespace std ;
11
+ int main ()
12
+ {
13
+ int t;
14
+ cin>>t;
15
+ while (t--)
16
+ {
17
+ int n;
18
+ cin>>n;
19
+ string s1,s2;
20
+ cin>>s1>>s2;
21
+ int one1=count (s1.begin (),s1.end (),' 1' );
22
+
23
+ int zero1=count (s1.begin (),s1.end (),' 0' );
24
+ int one2=count (s2.begin (),s2.end (),' 1' );
25
+
26
+ int zero2=count (s2.begin (),s2.end (),' 0' );
27
+ int p=1 ,cnt=0 ;
28
+ if (one1==one2 && zero1==zero2)
29
+ {
30
+ // cout<<"*"<<endl;
31
+ for (int i=0 ; i<n; i++)
32
+ {
33
+ if (s1[i]!=s2[i])
34
+ {
35
+ if (s1[i]==' 0' )
36
+ {
37
+ cnt--;
38
+ if (cnt<0 )
39
+ {
40
+ p=0 ;
41
+ break ;
42
+ }
43
+ }
44
+ else
45
+ {
46
+ cnt++;
47
+ }
48
+ }
49
+ }
50
+ }
51
+ else
52
+ {
53
+ p=0 ;
54
+ }
55
+ if (p==0 )
56
+ {
57
+ cout<<" No" <<endl;
58
+ }
59
+ else
60
+ {
61
+ cout<<" Yes" <<endl;
62
+ }
63
+
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments