-
Notifications
You must be signed in to change notification settings - Fork 125
/
UVa1610.cc
31 lines (30 loc) · 842 Bytes
/
UVa1610.cc
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
// UVa1610 Party Games
// 陈锋
#include <cassert>
#include <algorithm>
#include <string>
#include <iostream>
#define _for(i,a,b) for( int i=(a); i<(b); ++i)
#define _rep(i,a,b) for( int i=(a); i<=(b); ++i)
using namespace std;
int main() {
const int MAXN = 1000 + 4;
int n; string P, D[MAXN];
while(cin>>n && n) {
_for(i, 0, n) cin>>D[i];
sort(D, D + n);
const string &l = D[n/2-1];
P = "A";
int i = 0, sl = l.size();
while(i < sl){
while (P[i] <= 'Z' && P < l) ++P[i];
if (P[i] <= 'Z' && P >= l && P < D[n/2]) break;
if (l[i] != P[i]){ assert(P[i] == l[i] + 1); --P[i]; }
P += 'A';
++i;
}
cout<<P<<endl;
}
return 0;
}
// 15163524 1610 Party Games Accepted C++ 0.022 2015-03-17 14:17:25