题目链接:https://nanti.jisuanke.com/t/41384

这题暴力能过,我用的是并查集的思想,这个题的数据是为暴力设置的,所以暴力挺快的,但是当他转移的点多了之后,我觉得还是我这种方法更好一点。注意这里一定要用内部是hash的unordered_map 做,因为查询为o(1)

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <unordered_map>
#include <cmath>
#include <map>
#define N 100010
using namespace std;
typedef long long ll;
unordered_map<int,int>fa;
int n,q;
int get(int x)
{if(fa.count(x)==0) return x;fa[x]=get(fa[x]);
}
int main()
{scanf("%d%d",&n,&q);//  for(int i=1;i<=n+1;i++)fa[i]=i;int a,b;while(q--){scanf("%d%d",&a,&b);if(a==1)fa.insert(make_pair(b,b+1));else{printf("%d\n",get(b));}}
}

The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 B so easy相关推荐

  1. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team

    XKC , the captain of the basketball team , is directing a train of nn team members. He makes all mem ...

  2. [The Preliminary Contest for ICPC Asia Xuzhou 2019 - 徐州网络赛E] XKC's basketball team

    XKC's basketball team XKC , the captain of the basketball team , is directing a train of nn team mem ...

  3. The Preliminary Contest for ICPC Asia Xuzhou 2019

    小   银   川,给大爷们AK穿了 比赛地址:https://www.jisuanke.com/contest/3005?view=challenges A.(待补) B.1e9的数据范围,一开始从 ...

  4. The Preliminary Contest for ICPC Asia Xuzhou 2019 - C Buy Watermelon | 读题

    They want to cut the watermelon in two parts, and each part weighs two times as much as a kilogram . ...

  5. The Preliminary Contest for ICPC Asia Xuzhou 2019【B. so easy】(set 解法 与正解 unordered_map+并查集)

    so easy 题目大意 给你两个操作,op=1时,将那个数不可用,op=2时进行查询功能 找到从x开始第一个存在的数 非官方题解 set 内置红黑树,有默认从小到大排序功能,所以我们可以暴力一发,不 ...

  6. The Preliminary Contest for ICPC Asia Nanjing 2019ICPC南京网络赛

    B.super_log (欧拉降幂) •题意 定一个一个运算log*,迭代表达式为 给定一个a,b计算直到迭代结果>=b时,最小的x,输出对m取余后的值 •思路 $log*_{a}(a^{a}) ...

  7. The Preliminary Contest for ICPC Asia Nanjing 2019 B. super_log (广义欧拉降幂)

    In Complexity theory, some functions are nearly O(1)O(1), but it is greater then O(1)O(1). For examp ...

  8. H. Holy Grail(The Preliminary Contest for ICPC Asia Nanjing 2019题解)

    题目链接 As the current heir of a wizarding family with a long history,unfortunately, you find yourself ...

  9. The Preliminary Contest for ICPC Asia Shanghai 2019 B. Light bulbs(卡了线段树空间的思维题)

    传送门:https://nanti.jisuanke.com/t/41399 题目描述 There are NNN light bulbs indexed from 000 to N−1N−1N−1. ...

  10. The Preliminary Contest for ICPC Asia Shanghai 2019 Light bulbs

    https://nanti.jisuanke.com/t/41399 离散差分 #include <iostream> #include <cstring> #include ...

最新文章

  1. 解决Failed to execute goal org.apache.maven.plugins
  2. 多返回值函数的编写方法
  3. 数字化转型的认识模型
  4. Mac下好用的批量文件扩展名修改工具
  5. 编辑器eslint格式_vscode保存代码,自动按照eslint规范格式化代码设置
  6. mysql人事管理系统源代码_人事管理系统(源代码.doc
  7. Intellij IDEA15:建立Scala的Maven项目
  8. shell if判断语句
  9. Node.js 系列翻译---console
  10. 卓岚zlan系列串口服务器,卓岚信息技术隔离型串口服务器ZLAN5143BI概述
  11. sqlserver2008彻底卸载
  12. SQL数据库基础知识复习
  13. HTML和CSS面试题—整理过的48题,关注收藏,持续更新
  14. python回归分析
  15. 有关vista系统的激活工具
  16. THREE.js(二):设置材质线条宽度(lineWidth) 无效
  17. 双稳态电路的两个稳定状态是什么_单稳态电路与双稳态电路
  18. 解码mmo游戏服务器二:地图自动寻路
  19. ActiveSync同步Emulator
  20. 2008服务器系统配置dns,2008系统如何配置dns服务器

热门文章

  1. mysql修改my.ini_MySQL配置文件(my.ini)详解
  2. HTML5游戏 看你有多“色” 开发
  3. RK3568开发板固态硬盘测试
  4. 数据结构——二叉树错题集
  5. 在线java编译器 api_代码在线编译器(上)- 编辑及编译
  6. Fetcher failure for URL: ‘gitsm://github.com/Xilinx/qemu.git;protocol=https petalinux build 问题
  7. [python] 获取股票信息
  8. Idea 编译报错:Ambiguous method call. Both...
  9. 大话设计模式C++实现-第7章-代理模式
  10. 【Word】去掉“项目符号/编号”之后的制表符