I have solved the problem496 and submit it more than 10 times.But i always get wrong answers. I can't understand my problem.Can anybody help me.I get frustated.Is there any data that does not match?Please help me.Here is my code:
cnt=0;
if(l>=k)
{
for (i=0;i<k;i++)
for (j=0;j<l;j++)
{
if(d==c[j])
{
cnt++;
for (n=j;n<l;n++)
if (c[n]==d) c[n]='a';
for (p=i+1;p<k;p++)
if (d[p]==d)
{
cnt++;
flag=1;
d[p]='b';
}
}
}
if(cnt==l && cnt ==k) printf("A equals B\n");
else if(cnt==k ) printf("B is a proper subset of A\n");
else if(cnt==1 || flag==1) printf("I'm confused!\n");
else printf("A and B are disjoint\n");
}
if(l<k)
{
for (i=0;i<l;i++)
for (j=0;j<k;j++)
{
if(c==d[j])
{
cnt++;
for (n=j;n<k;n++)
if (d[n]==c) d[n]='a';
for (p=i+1;p<l;p++)
if (c[p]==c)
{
cnt++;
flag=1;
c[p]='b';
}
}
}
if(cnt==l && cnt ==k) printf("A equals B\n");
else if(cnt==l ) printf("A is a proper subset of B\n");
else if(cnt==1 || flag==1) printf("I'm confused!\n");
else printf("A and B are disjoint\n");
Thank you very much supermin for your kind reply. I was almost gave up any hope of getting any reply of this topic. I have checked your sample input and corrected my program but it gives me still wrong answer. Can you or anybody give me some more test cases to check my code. I think i do not have to wait so much long getting next reply.
I tested following soluition on such tests:
1
1 1 - A equals B
1
(an empty line) - B is a proper subset of
(an empty line)
(an empty line) A equals B
1 2 2 2 3 3
2 1 1 3 - A equals B
1 2 3
1 3 3 - B is a proper subset of A
1 2
3 4 - A and B are disjoint
1 1 1 2 2
2 2 3 - I'm confused!
Can anybody give me some critical test and/or check my code:
[cpp]
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <fstream.h>
#include <string.h>
#ifndef ONLINE_JUDGE
#include <conio.h>
#endif
int finish;
long caseNo;
#ifdef ONLINE_JUDGE
const long MAX = 200000;
#else
const long MAX = 100;
#endif
finish = cin.eof();
if (finish)
return;
while (cin.peek() != '\n' && !cin.eof()){
cin >> a[ai++];
finish = cin.eof();
if (finish)
return;
}
cin.get();
while (cin.peek() != '\n' && !cin.eof()){
cin >> b[bi++];
if (cin.eof()){
bi--;
return;
}
}
cin.get();
}
int aissubofb(t a, t b, int ad, int bd){
int flag = 1;
if (ad == 0)
return 1;
for (int i = 0; i < ad; i++){
flag = 0;
for (int j = 0; j < bd; j++)
if (a == b[j]) {flag = 1; break;}
if (!flag)
return 0;
}
return 1;
}
int disj(t a, t b, int ad, int bd){
int flag = 1;
if (!ad || !bd)
return 0;
for (int i = 0; i < ad; i++){
flag = 0;
for (int j = 0; j < bd; j++)
if (a == b[j]) {flag = 1; break;}
if (flag)
return 0;
}
return 1;
}
void Solve(){
if (aissubofb(a, b, ai, bi) && aissubofb(b, a, bi, ai))
cout << "A equals B";else
if (aissubofb(a, b, ai, bi))
cout << "A is a proper subset of B";else
if (aissubofb(b, a, bi, ai))
cout << "B is a proper subset of A";else
if (disj(a, b , ai, bi))
cout << "A and B are disjoint";
else
cout << "I'm confused!";
}
void Output()
{
}
#define DEBUG_
#define MULTIINPUT
int main(){
#ifndef ONLINE_JUDGE
ifstream is = "input.txt";
cin = is;
#ifdef DEBUG
clrscr();
cout << endl;
#else
ofstream os = "output.txt";
cout = os;
#endif
#endif
Can anybody explain me from mathematical point of view why 1 3 3 equals to 1 2 3? Set A equals to set B if and only if A is a subset of B and B is a subset of A. May be I don't understand completely a meaning of phrase ``proper subset''. I assume this equals to ``subset''. Can anybody help me?
hai, eXon's I/O is true, and I think for this problem the tricky I/O only the blank line. Check your input or your output again, I think (if I'm not wrong, because I don't check your program with specific) your algo is true.
Doesn't the problem state the the lines are composed of "distinct" integers? Why is everybodies test input contain duplicates?
LL Cool Jay
The Formula Wizard
Jason Winokur
hey here is some part of my check function . take a look and correct u r mistake . u must also check wither index 1(k in u r code) == index 2(l in u r code).
[c]
void check(){
register int i , j ;
register int flag,nequal=0,equal=0;
MoreOver i did not counter the following conditions
1 1 2 3
1 2 3
some one said it must be" A equals B " but
My Output is "B is The proper Sub Set of A" . so there is no test cases where the above things happen. more over no black line is given as input so dont worry about it .
Best Regards
Riyad
HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN
I am having problems with this problem... I have tried out for null inputs also like set 1 = {1,2,3} set2={} then set2 is proper subset of set1..
Please tell me why i am getting WA......
Frustrated
Aakash
[cpp]
# include<stdio.h>
# include<string.h>
# include<math.h>
char a[1000];
long long x[100],y[100];
int ac;
aakash_mandhar wrote:I am having problems with this problem... I have tried out for null inputs also like set 1 = {1,2,3} set2={} then set2 is proper subset of set1..
Please tell me why i am getting WA......
Actually the empty set is defined as improper subset of any set. So probably (I didn't try to solve 496) set2 should be considered disjoint...