/***
Md. Nazmul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include <iomanip>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
int test,p,n,cs=1,big,frnd;
int data[10010],cntuser[5];
sc("%d",&test);
while(test--)
{
memset(data,0,sizeof(data));
int mx=0,mn=120000;
memset(cntuser,0,sizeof(cntuser));
for(int i=1 ; i<=3; i++)
{
sc("%d",&n);
for(int j=1 ; j<=n ; j++)
{
sc("%d",&p);
if(mx<p)
mx=p;
if(mn>p)
mn=p;
if(data[p] || data[p]==-1)
{
data[p]=-1;
continue;
}
else
{
data[p] =i;
}
}
}
for(int i=mn ; i<=mx ; i++)
{
if(data[i]==1 || data[i]==2 || data[i]==3)
{
if(data[i]==1) cntuser[1]++;
else if(data[i]==2) cntuser[2]++;
else cntuser[3]++;
}
}
if(cntuser[1]>=cntuser[2])
{
big = cntuser[1];
}
else
{
big = cntuser[2];
}
if(big>=cntuser[3])
{
big = big;
}
else
{
big = cntuser[3];
}
pf("Case #%d:\n",cs++);
for(int i=1 ; i<=3 ; i++)
{
if(cntuser[i]==big)
{
pf("%d %d",i,big);
for(int j=mn ; j<=mx ; j++)
{
if(data[j]==i)
pf(" %d",j);
}
pf("\n");
}
}
}
return 0;
}
Md. Nazmul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include <iomanip>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
int test,p,n,cs=1,big,frnd;
int data[10010],cntuser[5];
sc("%d",&test);
while(test--)
{
memset(data,0,sizeof(data));
int mx=0,mn=120000;
memset(cntuser,0,sizeof(cntuser));
for(int i=1 ; i<=3; i++)
{
sc("%d",&n);
for(int j=1 ; j<=n ; j++)
{
sc("%d",&p);
if(mx<p)
mx=p;
if(mn>p)
mn=p;
if(data[p] || data[p]==-1)
{
data[p]=-1;
continue;
}
else
{
data[p] =i;
}
}
}
for(int i=mn ; i<=mx ; i++)
{
if(data[i]==1 || data[i]==2 || data[i]==3)
{
if(data[i]==1) cntuser[1]++;
else if(data[i]==2) cntuser[2]++;
else cntuser[3]++;
}
}
if(cntuser[1]>=cntuser[2])
{
big = cntuser[1];
}
else
{
big = cntuser[2];
}
if(big>=cntuser[3])
{
big = big;
}
else
{
big = cntuser[3];
}
pf("Case #%d:\n",cs++);
for(int i=1 ; i<=3 ; i++)
{
if(cntuser[i]==big)
{
pf("%d %d",i,big);
for(int j=mn ; j<=mx ; j++)
{
if(data[j]==i)
pf(" %d",j);
}
pf("\n");
}
}
}
return 0;
}
No comments:
Post a Comment