码迷,mamicode.com
首页 > 其他好文 > 详细

Tju 4119. HDFS

时间:2016-06-26 00:25:57      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

4119.   HDFS
Time Limit: 5.0 Seconds   Memory Limit: 5000K
Total Runs: 225   Accepted Runs: 77



In HDFS( Hadoop Distributed File System), each data may have a lot of copies in case of data lose.
This problem, every data has its own id, from 1 to n. To make things simple, each data has only two copies.
This time, the HDFS is cracked by some stupid reason. Fortunately, tmeteorj knows that there are actually 2 data lost by his keen intuition.
Now, it is your time to show your value of life. You should tell tmeteorj the id of lost data.

INPUT

First line, there will a number T(1≤T≤10), means the test case of this problem.
After this, each line is first a number n(1≤n≤5000000), means data id is from 1 to n. Then there will be 2(n-1) numbers means the id of data in health state.

OUTPUT

For each case, print the lost id of data. The smaller id is in the front of the bigger one.

Sample Input

 


3
4 1 1 2 3 4 4
4 1 2 3 1 2 4
4 2 3 4 2 3 1

 

Sample Output

 


2 3
3 4
1 4

 

题目大意:求数据中没有出现两次的那两个数。

这题主要是卡内存...坑

对于这种题目,set map都会爆内存,所以考虑用biset记录一下出现没有。

/* ***********************************************
Author        :guanjun
Created Time  :2016/6/25 12:20:55
File Name     :tju4119.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;

bitset<5010000>b;
vector<int>v;
bitset<5010000>c;
int main()
{
   // freopen("in.txt","r",stdin);
    int t,n,x;
    cin>>t;
    while(t--){
        cin>>n;
        b.reset();
        c.reset();
        int w=0;
        for(int i=1;i<=n*2-2;i++){
            scanf("%d",&x);
            w^=x;
            if(b[x]==1){
                b[x]=0;
                c[x]=1;
            }
            else{
                b[x]=1;
                c[x]=1;
            }
        }
        v.clear();
        if(w==0){
            for(int i=1;i<=n;i++){
                if(c[i]==0){
                    v.push_back(i);
                    v.push_back(i);
                    break;
                }
            }
        }
        else{
        for(int i=1;i<=n;i++){
            if(b[i]==1){
                v.push_back(i);
            }
        }
        }
        cout<<v[0]<<" "<<v[1]<<endl;
    }
    return 0;
}

 

 

Tju 4119. HDFS

标签:

原文地址:http://www.cnblogs.com/pk28/p/5617142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!