-
Notifications
You must be signed in to change notification settings - Fork 0
/
11222_IdidIT.cpp
102 lines (92 loc) · 2.23 KB
/
11222_IdidIT.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int MAX(int a,int b)
{
return a>b?a:b;
}
int main()
{
int T,count,count1,count2,count3,i,k,a[5][10030],arr[5][10030],cnt[10],Case=1,temp,max;
cin>>T;
while(T--)
{
count1=count2=count3=0;
memset(arr,0,sizeof arr);
for(i=1;i<=3;i++)
{
cin>>count;
for(k=1;k<=count;k++)
{
cin>>temp;
if(temp>0&&temp<=10000)
{
a[i][k]=temp;
arr[i][a[i][k]]=1;
}
else
count--;
}
cnt[i]=count;
sort(a[i],a[i]+count+1);
}
for(i=1;i<=cnt[1];i++)
{
if(!(arr[2][a[1][i]]||arr[3][a[1][i]]))
count1++;
}
for(i=1;i<=cnt[2];i++)
{
if(!(arr[1][a[2][i]]||arr[3][a[2][i]]))
count2++;
}
for(i=1;i<=cnt[3];i++)
{
if(!(arr[2][a[3][i]]||arr[1][a[3][i]]))
count3++;
}
cout<<"Case #"<<Case++<<":"<<endl;//Case #1:
max=MAX(count1,MAX(count2,count3));
if(max==count1)
{
cout<<1<<" "<<count1<<" ";//1
for(i=1;i<=cnt[1];i++)
{
if(!(arr[2][a[1][i]]||arr[3][a[1][i]]))
cout<<a[1][i];
if(i+1>cnt[1])
cout<<endl;
else
cout<<" ";
}
}
if(max==count2)
{
cout<<2<<" "<<count2<<" ";//2
for(i=1;i<=cnt[2];i++)
{
if(!(arr[1][a[2][i]]||arr[3][a[2][i]]))
cout<<a[2][i];
if(i+1>cnt[2])
cout<<endl;
else
cout<<" ";
}
}
if(max==count3)
{
cout<<3<<" "<<count3<<" ";//3
for(i=1;i<=cnt[3];i++)
{
if(!(arr[2][a[3][i]]||arr[1][a[3][i]]))
cout<<a[3][i];
if(i+1>cnt[3])
cout<<endl;
else
cout<<" ";
}
}
}
return 0;
}