forked from shashank077/Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TWOGRS.cpp
63 lines (62 loc) · 975 Bytes
/
TWOGRS.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
//Correct BUT TLE SOLUTION SORRY!!
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool Sum (ll arr[], ll x, ll sum)
{
if (sum == 0)
return true;
if (x == 0 && sum != 0)
return false;
if (arr[x-1] > sum)
return Sum (arr, x-1, sum);
return Sum (arr, x-1, sum) ||
Sum (arr, x-1, sum-arr[x-1]);
}
bool Part (ll arr[], ll x)
{
ll sum = 0;
for (ll i = 0; i < x; i++)
sum += arr[i];
if (sum%2 != 0)
return false;
return Sum (arr, x, sum/2);
}
int main()
{
ll testcase=0;
cin>>testcase;
while(testcase--)
{ll a=0,b=0,c=0,x=1,y=2,z=3;
//ll ct=0;
cin>>a>>b>>c;
//ll u=0,v=0,w=0;
ll n=a+b+c;
ll arr[n];
for(int i=0;i<a;i++)
{
arr[i]=x;
cout<<arr[i];
}
for(int i=a;i<=(b+a)-1;i++)
{
arr[i]=y;
cout<<arr[i];
}
for(int i=b+a;i<=(c+b+a)-1;i++)
{
arr[i]=z;
cout<<arr[i];
}
sort(arr,arr+n);
/*for(int i=0;i<n;i++)
{
cout<<arr[i]<<' ';
}*/
if (Part(arr, n) == true)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}