TWOGRS - Editorial

@manoj_269 There are too many test cases where your solution failed.

Here few of them:

0 5 2
4 1 6
6 5 6
6 7 8
8 3 8
4 9 4
6 1 2
1 Like

@rudransh_bt Check out the following test cases:

0 4 4
0 7 4
0 4 2

Your code maybe failed for a = 0 condition only, Here is a logic to solve it:

if ((a + c) % 2 == 0) {
    if (a == 0 and b > 1)
      cout << "YES"<< "\n";
    else
      cout << "NO"<< "\n";
  }
//You must use your logic for two of a, b, c are 0 before checking a = 0

My logical solution here

@anon79977241 Check out the following test cases:

1 2 9
0 7 0
0 1 4
1 2 3

and so on…
You should use capital letter, ex- YES, NO (According to problem statement).

1 Like

@ukt1997 Check out the following test cases:

0 5 0
5 0 5
3 0 1
0 1 6
0 1 4
2 Likes

You must use * between to variable/constant to get their product.

Check out the following test case:

0 7 2
0 5  6

Check out your solution for a = 0 case.

variable j is to ensure outer loop doesn’t execute more than twice, and jj is to ensure that inner loop does not execute more than three times.

They serve no other purpose.

yes I copied incorrectly… the program outputs No for both the testcases…:frowning:

Check out // try this way.

Tester’s solution seems to be very easy to understand but their is one thing which i am not getting i.e he has reduce A,B,C below 30 how come the answer is not affected by reducing them below 30

I don’t think so.
For every test case answer should be yes.

Yeah @anon55659401 this solution will take expo time and indeed weak test cases . I read your Solution sir nice work .

1 Like

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int a,b,c,s;
cin>>a>>b>>c;
s=(1a+2b+3*c);
if(s%2==1)
cout<<“NO”<<endl;
else
{
s=s/2;
if(b>=s/2)
{
if(s%2==0)cout<<“YES”<<endl;
else
{
if(a>=1||c>=1)cout<<“YES”<<endl;
else
cout<<“NO”<<endl;

            }
        } 
        else
        {
            s=s-2*b;
            if(c>=s/3)
          {       
            if(s%3==0)cout<<"YES"<<endl;
            else if(s%3==1 && a>=1)cout<<"YES"<<endl;
            else if(s%3==2 && a>=2)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
          }    
            else
            {
                s=s-3*c;
                if(a>=s)cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
               
            }
        }
    }
      
}
return 0;

}
can anyone help me find my mistake??

Thanks man ,It really helped , finally accepted after so many attempts .

1 Like

https://www.codechef.com/viewsolution/26793598

What about this now?(now works fine with the given test cases)

My pleasure :heart_eyes:

@tushar0609 Nope bro, You can’t fix your solution for a = 0 case.

Check out the following test cases:

0 4 4
0 4 2
0 7 6
0 6 2
0 10 10
1 Like

@manoj_269 Umm Answer should be YES but your solution provide NO

Explanation for last test case:

6 1 2 means => {1, 1, 1, 1, 1, 1, 2, 3, 3}
Group 1 = {1, 3, 3}
Group 2 = {1, 1, 1, 1, 1, 2}
Group 1 = Group 2 (= 7) Therefore answer should be YES

Thanks man! for giving your time.
#respect

1 Like

can you please help me ?
https://www.codechef.com/viewsolution/26808696

@tushar0609 my pleasure :heart_eyes: