Result: Accepted
Time: 0ms
Memory: 1704kB
# include <iostream>
# include <string>
# include <stdio.h>
using namespace std;
struct friends{
int n;
char name[20];
int a ,b ,c ;
};
int main(){
friends array[100];
int arr[100];
bool visited[100] ;
for(int i = 0;i <100;++i)
visited [i] = 0;
int n,m,i = 0,a,b,c,count=0,l;
char ch;
scanf("%d",&n);
l = n;
for(int j = 0;j<n;++j)
{
array[j].a=0;
array[j].b=0;
array[j].c=0;
}
for(;n;--n)
{
cin >>m;
cin >> array[i].name;
for(int j = 0;j <m;++j)
{
scanf("%d-%d-%d",&a,&b,&c);
if(a==b && b==c)
++array[i].a;
else if(a/10>a%10&&a%10>b/10&&b/10>b%10&&b%10>c/10&&c/10>c%10)
++array[i].b;
else
++array[i].c;
}
++i;
}
n = l;
for(int j = 0; j <n ;++j)
arr[j] = array[j].a;
for(int s = 0;s<n;++s)
{
for(int t = 0;t <n;++t)
{
if(arr[s] >= arr[t])
{
int cou = arr[s];
arr[s] = arr[t];
arr[t] = cou;
}
}
}
for(int t= 0;t <n ;++t)
{
if(arr[t] == arr[0])
++count;
}
printf("If you want to have a keyboard, you should call: ");
for(int t = 0;t <n &&count;++t)
{
if(array[t].a == arr[0] && !visited[t] )
{
cout << array[t].name;
visited[t] = 1;
--count;
if(count)
printf(", ");
else
printf(".");
}
}
printf("\n");
for(int i = 0;i <100;++i)
visited [i] = 0;
count = 0;
for(int j = 0; j <n ;++j)
arr[j] = array[j].b;
for(int s = 0;s<n;++s)
{
for(int t = 0;t <n;++t)
{
if(arr[s] >arr[t])
{
int cou = arr[s];
arr[s] = arr[t];
arr[t] = cou;
}
}
}
for(int t= 0;t <n ;++t)
{
if(arr[t] == arr[0])
++count;
}
printf("If you want to order a Watchdog2, you should call: ");
for(int t = 0;t <n &&count;++t)
{
if(array[t].b == arr[0] && !visited[t] )
{
cout << array[t].name;
visited[t] = 1;
--count;
if(count)
printf(", ");
else
printf(".");
}
}
printf("\n");
for(int i = 0;i <100;++i)
visited [i] = 0;
count = 0;
for(int j = 0; j <n ;++j)
arr[j] = array[j].c;
for(int s = 0;s<n;++s)
{
for(int t = 0;t <n;++t)
{
if(arr[s] >arr[t])
{
int cou = arr[s];
arr[s] = arr[t];
arr[t] = cou;
}
}
}
for(int t= 0;t <n ;++t)
{
if(arr[t] == arr[0])
++count;
}
printf("If you want to have a cup of coffee with a girl, you should call: ");
for(int t = 0;t <n &&count;++t)
{
if(array[t].c == arr[0] && !visited[t] )
{
cout << array[t].name;
visited[t] = 1;
--count;
if(count)
printf(", ");
else
printf(".");
}
}
}