CodeChef Practice Problem - TRUEDARE [closed]











up vote
-4
down vote

favorite












Qn - Why am i getting yes for all the test cases given in the problem? One more thing if t=1 and if I check the test cases it gives the correct answer, why? Please I am not that much efficient in programming. Any help would be appreciated.



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



My attempt -



#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>::iterator it;
vector <int> vrt;
vector <int> vrd;
vector <int> vst;
vector <int> vsd;

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

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

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

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

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

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

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

cout<<(flag?"yesn":"non");
}
}









share|improve this question













closed as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal Nov 19 at 5:47


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.













  • So...many downvotes..?? I wish if there would be a community for beginners too :(
    – CodeHackeRツ
    Nov 19 at 7:12















up vote
-4
down vote

favorite












Qn - Why am i getting yes for all the test cases given in the problem? One more thing if t=1 and if I check the test cases it gives the correct answer, why? Please I am not that much efficient in programming. Any help would be appreciated.



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



My attempt -



#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>::iterator it;
vector <int> vrt;
vector <int> vrd;
vector <int> vst;
vector <int> vsd;

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

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

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

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

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

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

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

cout<<(flag?"yesn":"non");
}
}









share|improve this question













closed as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal Nov 19 at 5:47


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.













  • So...many downvotes..?? I wish if there would be a community for beginners too :(
    – CodeHackeRツ
    Nov 19 at 7:12













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











Qn - Why am i getting yes for all the test cases given in the problem? One more thing if t=1 and if I check the test cases it gives the correct answer, why? Please I am not that much efficient in programming. Any help would be appreciated.



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



My attempt -



#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>::iterator it;
vector <int> vrt;
vector <int> vrd;
vector <int> vst;
vector <int> vsd;

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

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

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

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

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

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

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

cout<<(flag?"yesn":"non");
}
}









share|improve this question













Qn - Why am i getting yes for all the test cases given in the problem? One more thing if t=1 and if I check the test cases it gives the correct answer, why? Please I am not that much efficient in programming. Any help would be appreciated.



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



My attempt -



#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>::iterator it;
vector <int> vrt;
vector <int> vrd;
vector <int> vst;
vector <int> vsd;

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

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

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

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

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

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

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

cout<<(flag?"yesn":"non");
}
}






c++14






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 3:31









CodeHackeRツ

11




11




closed as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal Nov 19 at 5:47


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal Nov 19 at 5:47


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Sᴀᴍ Onᴇᴌᴀ, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.












  • So...many downvotes..?? I wish if there would be a community for beginners too :(
    – CodeHackeRツ
    Nov 19 at 7:12


















  • So...many downvotes..?? I wish if there would be a community for beginners too :(
    – CodeHackeRツ
    Nov 19 at 7:12
















So...many downvotes..?? I wish if there would be a community for beginners too :(
– CodeHackeRツ
Nov 19 at 7:12




So...many downvotes..?? I wish if there would be a community for beginners too :(
– CodeHackeRツ
Nov 19 at 7:12















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар