My Bruteforce solution got 100 points.
Solution-Click here
Were test cases weak for this problem?
Your code will fail on this test case:
1
3
011
101
Expected output : No
Your Output : Yes
You canβt swap a β0β with β1β if 0 is present behind 1.
While
You can swap a β0β with β1β if 0 is present after 1.
thanks I got it
Hey Everybody,
Link for my solution
Solution: 40830211 | CodeChef
Can anybody help me get why this solution is wrong because this solution got 20 pts initially but after CodeChef removed some test cases the same solution got 70 pts but I am not able to get how this solution is getting WA is some cases?
Hi, you are only counting number of 1βs and 0βs in S and P, and comparing them. But the question is βCan we convert S into Pβ, but there is a condition un that conversion also.
You have to convert the string SS into PP using zero or more operations. In one operation, you should choose two indices ii and jj (1β€i<jβ€N1β€i<jβ€N) such that SiSi is β1β and SjSj is β0β, and swap SiSi with SjSj
Would anyone be able to find the error in the following code? It is failing on two tests
submission - CodeChef: Practical coding for everyone
LOGIC
why 1st test case is WA what is wrong in this code CodeChef: Practical coding for everyone can any one check it
hello
bool good = count(all(s), β1β) == count(all(t), β1β);
someone please tell me functionality of all() and what is it that is getting stored in good variable?
//Please tell me in which case my code fails
#include <bits/stdc++.h>
using namespace std;
signed main()
{
int t; cin>>t;
while(t--){
int n, i, p0=0, p1=0, c0=0, c1=0;
cin>>n;
string s, p;
cin>>s>>p;
for(i=0;i<n;i++){
if(s[i]=='1') c1++;
if(p[i]=='1') p1++;
}
if(c1==p1 && s>=p){
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
}