Monday, April 18, 2016

Google Code Jam 2016 Round 1A 2016 Problem B. Rank and File

// Google Code Jam 2016 Round 1A 2016 Problem B. Rank and File
// Problem URL: https://code.google.com/codejam/contest/4304486/dashboard#s=p1&a=0

#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <limits>

using namespace std;

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<long long> vll;

//==================================
void solve()
{
    int numCases = 1;
    cin >> numCases;

    for ( int ncase=1; ncase <= numCases; ncase++ )
    {
        //===== start case
        int N;
        cin >> N;
        int num[2501];
        for (int i=0; i<=2500; i++)
            num[i]=0;
        int x;
        for (int i=0; i<2*N-1; i++) {
            for (int j=0; j<N; j++) {
                cin >> x;
                num[x]+=1;
            }
        }
        vector<int> v;
        for (int i=1; i<=2500; i++) {
            if (num[i]%2==1)
                v.push_back(i);
        }

        sort(v.begin(),v.end());

        cout << "Case #" << ncase << ": ";
        for (int i=0; i<N; i++) {
            cout << v[i] << " ";
        }
        cout << endl;

        //===== end case

    }
}

int main()
{
    solve();
    return 0;

}



1 comment: