## c ++ 14 – CodeChef Exercise Problem – TRUEDARE

Qn – Why do I get a yes for all test cases specified in the problem? One more thing, if t = 1 and if I check the test cases, there is the right answer. Why? Please, I'm not that efficient in programming. Any help would be appreciated.

Link to the problem – https://www.codechef.com/problems/TRUEDARE

My attempt –

``````#include
using namespace std;
int main ()
{
vector:: iterator it;
vector  vrt;
vector  vrd;
vector  vst;
vector  vsd;

int t, rt, rd, st, sd, x, i;
bool flag;

cin >> t;
while (t--)
{
Flag = 1;
cin >> rt;
for (i = 0; i> x;
vrt.push_back (x);
}

cin >> rd;
for (i = 0; i> x;
vrd.push_back (x);
}

cin >> st;
for (i = 0; i> x;
vst.push_back (x);
}

cin >> sd;
for (i = 0; i> x;
vsd.push_back (x);
}

for (i = 0; i <st; i ++)
{
it = find (vrt.begin (), vrt.end (), vst.at (i));
if (it! = vrt.end ()) {}
otherwise
{
Flag = 0;
break;
}
}

if (flag)
for (i = 0; i <sd; i ++)
{
it = find (vrd.begin (), vrd.end (), vsd.at (i));
if (it! = vrd.end ()) {}
otherwise
{
Flag = 0;
break;
}
}

cout << (flag? "yes  n": "no  n");
}
}
``````

Posted on Categories Articles