-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00496.cpp
More file actions
74 lines (72 loc) · 1.65 KB
/
00496.cpp
File metadata and controls
74 lines (72 loc) · 1.65 KB
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
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
char input[4096],*p;
int a[500],b[500];
bool visit[500];
while(cin.getline(input,4096))
{
fill_n(visit,500,false);
int anum(1),bnum(1),equ(0);
p=strtok(input," ");
a[0]=atoi(p);
while(1)
{
p=strtok(NULL," ");
if(p==NULL)
break;
a[anum++]=atoi(p);
}
cin.getline(input,4096);
p=strtok(input," ");
b[0]=atoi(p);
while(1)
{
p=strtok(NULL," ");
if(p==NULL)
break;
b[bnum++]=atoi(p);
}
sort(a,a+anum);
sort(b,b+bnum);
for(int i=0;i<bnum;i++)
{
for(int j=0;j<anum;j++)
{
if(a[j]>b[i])
break;
if(a[j]==b[i]&&!visit[i])
{
equ++;
visit[i]=true;
break;
}
}
}
if(anum==bnum&&anum==equ)
{
cout<<"A equals B"<<endl;
}
else if(equ==0)
{
cout<<"A and B are disjoint"<<endl;
}
else if(bnum==equ&&anum>equ)
{
cout<<"B is a proper subset of A"<<endl;
}
else if(anum==equ&&bnum>equ)
{
cout<<"A is a proper subset of B"<<endl;
}
else
{
cout<<"I'm confused!"<<endl;
}
}
return 0;
}