zoukankan      html  css  js  c++  java
  • Tju 4119. HDFS

    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;
    }
  • 相关阅读:
    BAPI_TRANSACTION_COMMIT的使用方法(转)
    Win7 64bit系统下未能加载文件或程序集“System.Data.SQLite”的解决办法
    在Windows XP环境中配置OPC服务器时的设置方式
    关于异常“The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine”的处理
    MSChart使用做折线图饼图(转)
    C#如何导入内文至SAP(转)
    经典Sql大全转
    工程师突击:SAP ABAP实用程序开发攻略(转)
    如何使用ExtJS Design中生成的代码
    ExtJS 4 学习(1)环境配置及注意点
  • 原文地址:https://www.cnblogs.com/pk28/p/5617142.html
Copyright © 2011-2022 走看看