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 << ;
const double eps=1e-;
using namespace std; bitset<>b;
vector<int>v;
bitset<>c;
int main()
{
// freopen("in.txt","r",stdin);
int t,n,x;
cin>>t;
while(t--){
cin>>n;
b.reset();
c.reset();
int w=;
for(int i=;i<=n*-;i++){
scanf("%d",&x);
w^=x;
if(b[x]==){
b[x]=;
c[x]=;
}
else{
b[x]=;
c[x]=;
}
}
v.clear();
if(w==){
for(int i=;i<=n;i++){
if(c[i]==){
v.push_back(i);
v.push_back(i);
break;
}
}
}
else{
for(int i=;i<=n;i++){
if(b[i]==){
v.push_back(i);
}
}
}
cout<<v[]<<" "<<v[]<<endl;
}
return ;
}
Tju 4119. HDFS的更多相关文章
- HDFS(数学题)
题目连接:http://acm.tju.edu.cn/toj/showp.php?pid=4119 4119. HDFS Time Limit: 5.0 Seconds Memory Limi ...
- hadoop 2.7.3本地环境运行官方wordcount-基于HDFS
接上篇<hadoop 2.7.3本地环境运行官方wordcount>.继续在本地模式下测试,本次使用hdfs. 2 本地模式使用fs计数wodcount 上面是直接使用的是linux的文件 ...
- Hadoop学习之旅二:HDFS
本文基于Hadoop1.X 概述 分布式文件系统主要用来解决如下几个问题: 读写大文件 加速运算 对于某些体积巨大的文件,比如其大小超过了计算机文件系统所能存放的最大限制或者是其大小甚至超过了计算机整 ...
- python基础操作以及hdfs操作
目录 前言 基础操作 hdfs操作 总结 一.前言 作为一个全栈工程师,必须要熟练掌握各种语言...HelloWorld.最近就被"逼着"走向了python开发之路, ...
- C#、JAVA操作Hadoop(HDFS、Map/Reduce)真实过程概述。组件、源码下载。无法解决:Response status code does not indicate success: 500。
一.Hadoop环境配置概述 三台虚拟机,操作系统为:Ubuntu 16.04. Hadoop版本:2.7.2 NameNode:192.168.72.132 DataNode:192.168.72. ...
- HDFS的架构
主从结构 主节点,只有一个: namenode 从节点,有很多个: datanodes 在版本1中,主节点只有一个,在 版本2中主节点有两个. namenode 负责(管理): 接收用户操作请求 维护 ...
- hdfs以及hbase动态增加和删除节点
一个知乎上的问题:Hbase的Region server和hadoop的datanode是否可以部署在一台服务器上?如果是的话,二者是否是一对一的关系?部署在同一台服务器上,可以减少数据跨网络传输的流 ...
- hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///
Java代码如下: FileSystem fs = FileSystem.get(conf); in = fs.open(new Path("hdfs://192.168.130.54:19 ...
- 01 HDFS 简介
01.HDFS简介 大纲: hadoop2 介绍 HDFS概述 HDFS读写流程 hadoop2介绍 框架的核心设计是HDFS(存储),mapReduce(分布式计算),YARN(资源管理),为海量的 ...
随机推荐
- POJ 1511 Invitation Cards (最短路的两种方法spfa, Dij)
题意: 给定n个点, m条路, 求1到 2 ~n的最短路之和加上2~n到1的最短路之和 分析: 裸最短路, 求其他点到源点的距离只需要把边方向再从源点求一次即可 spfa代码 #include< ...
- 算法导论 第八章 线性时间排序(python)
比较排序:各元素的次序依赖于它们之间的比较{插入排序O(n**2) 归并排序O(nlgn) 堆排序O(nlgn)快速排序O(n**2)平均O(nlgn)} 本章主要介绍几个线性时间排序:(运算排序非比 ...
- openstack创建虚拟机之后使用ssh登陆的解决办法
创建一个虚机之后:若果想要在horizon的控制台上登录操作,第一步.需要先使用ssh从controller上修改密码 从controller上登录: ssh ubuntu@虚机ip sudo su ...
- Web前端静态页面示例
目录结构: Web25\ |—css\ reset.css.common.css.index.css.login.css.reg.css |—js\ jquery-3.3.1.js.index.js. ...
- Codeforces Round #387 (Div. 2) A+B+C+D!
A. Display Size 水题,暴力(数据都是水题).0:04 int main() { int n; while(~scanf("%d",&n)) { int mi ...
- 《TC训练赛一》题解!
以下题目标题就是此题题目链接,题目内容为了节省篇幅就不粘上去了.整套题的链接:https://acm.bnu.edu.cn/v3/contest_show.php?cid=8679#info 密码:7 ...
- hdu 3940
#include<stdio.h> #include<math.h> #include<string.h> double first(double vx,doubl ...
- dispatching(bzoj 2008)
Description 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿.在这个帮派里,有一名忍者被称之为 Master.除了 Master以外,每名忍者都有且仅有一个上级. ...
- [NOIP1999] 提高组 洛谷P1016 旅行家的预算
题目描述 一个旅行家想驾驶汽车以最少的费用从一个城市到另一个城市(假设出发时油箱是空的).给定两个城市之间的距离D1.汽车油箱的容量C(以升为单位).每升汽油能行驶的距离D2.出发点每升汽油价格P和沿 ...
- Codevs 队列练习 合并版
3185 队列练习 1 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 给定一个队列(初始为空),只有两种操作入队和出队,现给出这 ...