Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

naïve simulation 16ms accepted

Posted by miklcct at 2011-06-22 19:58:53 on Problem 2894
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator