Thanks for that. I got the problem. Thanks very much again
Whatâs wrong with my code? I was getting wrong answer during submissionâŚPlease Help!!
#include <bits/stdc++.h>
#include <vector>
using namespace std;
class Cube
{
public:
void getColors();
void Test();
private:
string ptr[6];
};
void Cube::getColors()
{
cin>>ptr[0]>>ptr[1]>>ptr[2]>>ptr[3]>>ptr[4]>>ptr[5];
for(int i=0;i<6;++i)
{
if(ptr[i]=="black"||ptr[i]=="blue"||ptr[i]=="red"||ptr[i]=="green"||ptr[i]=="yellow"||ptr[i]=="orange");
else
{
cout<<"Wrong Colour, Exiting....";
exit(1);
}
}
}
void Cube::Test()
{
if((ptr[0]==ptr[2])||(ptr[0]==ptr[3]))
{
if((ptr[0]==ptr[4])||(ptr[0]==ptr[5]))
cout<<"YES";
}
else if((ptr[1]==ptr[2])||(ptr[1]==ptr[3]))
{
if((ptr[1]==ptr[4])||(ptr[1]==ptr[5]))
cout<<"YES";
}
else
cout<<"NO";
}
int main()
{
int T; vector<Cube> ch(1); Cube a;
cin>>T;
if(T<1 || T>50000)
{
cout<<"Number of test cases are out of available limits, exiting....";
exit(0);
}
for(int i=0;i<T;++i)
{
if(i>0)
ch.push_back(a);
ch[i].getColors();
}
for(int j=0;j<T;++j)
{
cout<<endl;
ch[j].Test();
}
return 0;
}
Help , I still canât figure out why my solution still WA even I have already tested it on ideone and the output is same with the problem statement
Here is the link to the code : http://ideone.com/mDoLO0
You have written check = false
outside the test cases loop. So once the check flag is set to true (in some test case), there is no way it can go false and will always be true for all the test cases afterwards.
So your output would be something like:
NO
NO
NO
.
.
.
YES
YES
YES
YES
.
.
.
YES
Write that line inside the test cases loop. That would solve the problem.
I am getting WA. please tell me the mistake.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
string s[6];
int i,j,co=0,c1=0,flag=0;
for(i=0;i<6;i++)
{
cin>>s[i];
}
for(i=0;i<6;i+=2)
{
if(!s[i].compare(s[i+1]))
c1++;
}
for(i=0;i<6;i+=1)
{ if(i+1<6)
{
if(!s[i].compare(s[i+1]))
flag++;
}
}
for(i=0;i<6;i++)
{
for(j=i+1;j<6;j++)
{
if(!s[i].compare(s[j]))
{
co++;
}
}
}
if(co>=3)
{
if(c1>2 && flag==5)
cout<<"YES"<<endl;
else if(c1<2)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
else
cout<<"NO"<<endl;
}
return 0;
}