| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
naïve simulation 16ms accepted#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(int argc, char **) {
if (argc > 1) {
freopen("2894.in", "r", stdin);
}
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
set<char> sequence[1001];
while (n--) {
int a, b;
char c;
scanf(" %c%d%d", &c, &a, &b);
sequence[a].insert(c);
sequence[b].insert(c);
}
int count = 0;
bool used[26] = {};
for (const set<char> *p = sequence; p != (&sequence)[1]; ++p) {
for (set<char>::const_iterator q = p->begin(); q != p->end(); ++q) {
bool &cell = used[*q - 'A'];
if (cell) {
--count;
} else {
++count;
}
cell = !cell;
}
if (count) {
putchar('A' + (count - 1));
}
}
putchar('\n');
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator