Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 1ms
Memory: 1712kB
In contest: 1075

#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
using namespace std;

struct con
{
	string name;
	int a,b,c;
};
int cmp(char a,char b)
{
	return a > b;
}
int cmpa(con a,con b)
{
	return a.a>b.a;
}
int cmpb(con a,con b)
{
	return a.b>b.b;
}
int cmpc(con a,con b)
{
	return a.c>b.c;
}
int main()
{
	int t,y;
	cin >> t;
	y=t;
	con *c = new con[t];
	int pos = 0;
	while(y--) {
		int m;
		string str;
		cin >> m >> str;
		c[pos].name = str;
		c[pos].a = 0;
		c[pos].b = 0;
		c[pos].c = 0;
		string *phone = new string[m];
		char **abc = new char*[m];
		for (int i=0;i<m;i++){
			cin >> phone[i];
			abc[i] = new char[6];
			sscanf(phone[i].c_str(),"%c%c-%c%c-%c%c",&abc[i][0],&abc[i][1],&abc[i][2],&abc[i][3],&abc[i][4],&abc[i][5]);
			string f(abc[i]);
			sort(abc[i],abc[i]+6,cmp);
			string g(abc[i]);
			if(f == g){
				int flaga = 1;
				int flagb = 1;
				for(int i=1;i<6;i++){
					if (f[i] != f[i-1])
						flaga = 0;
					if (f[i] == f[i-1])
						flagb = 0;
				}
				if (flaga){
					c[pos].a++;
					continue;
				}
				if (flagb){
					c[pos].b++;
					continue;
				}
				c[pos].c++;
			}
			else {
				c[pos].c++;
			}
		}
		pos++;
	}

	con *d = new con[t];
	con *e = new con[t];
	for(int i=0;i<t;i++){
		d[i]=e[i]=c[i];
	}

	cout << "If you want to have a keyboard, you should call: ";
	sort(c,c+t,cmpa);
	cout << c[0].name;
	for(int i=1;i<t;i++){
		if(c[i].a == c[i-1].a)
			cout << ", " << c[i].name;
		else
			break;
	}
	cout << "." << endl;
	cout << "If you want to order a Watchdog2, you should call: ";
	sort(d,d+t,cmpb);
	cout << d[0].name;
	for(int i=1;i<t;i++){
		if(d[i].b == d[i-1].b)
			cout << ", " << d[i].name;
		else
			break;
	}
	cout << "." << endl;
	cout <<	"If you want to have a cup of coffee with a girl, you should call: ";
	sort(e,e+t,cmpc);
	cout << e[0].name;
	for(int i=1;i<t;i++){
		if(e[i].c == e[i-1].c)
			cout << ", " << e[i].name;
		else
			break;
	}
	cout << "." << endl;
}