Connections in Galaxy War----zoj3261】的更多相关文章

Connections in Galaxy War Time Limit: 3 Seconds      Memory Limit: 32768 KB 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3261 Description: In order to strengthen the defense ability, many stars in galaxy allied together and built…
Connections in Galaxy War In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by the monsters from…
Connections in Galaxy War http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3563 Time Limit: 3 Seconds      Memory Limit: 32768 KB In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional…
这两道题长得差不多,都有分裂集合的操作,都是先将所有操作离线,然后从最后一步开始倒着模拟,这样一来,分裂就变成合并,也就是从打击以后最终的零散状态,一步步合并,回到最开始所有星球都被连为一个整体的状态,这就能套并查集了.中途的询问结果用栈存下来,输出的时候一个个出栈就好 还有一个共同点,都是科幻风格的,都是星际战争,通信都靠隧道,不知道出题人有没有借鉴的意思 假装这篇博客是我刚写完星球大战这题时写的(其实是一年零两个月二十多天以后,写了zoj那题以后写的 2019年01月25日16:35:27)…
题目链接:https://vjudge.net/problem/ZOJ-3261 In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by th…
In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by the monsters from another dimension. Then m…
Description In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by the monsters from another dimen…
题目链接:https://cn.vjudge.net/problem/ZOJ-3261 题意 有n个星星,之间有m条边 现一边询问与x星连通的最大星的编号,一边拆开一些边 思路 一开始是真不会,甚至想用dfs模拟 最后查了一下,这个题原来是要离线操作,拆边就变为合并 这很为难哈哈,本以为有个什么更好的数据结构(动态树?) 存边我们用一个set<int>来存一个数字即可(bfs这类写多了就很容易考虑到压缩数据) 还有一个重要的点,就是并查集的join可以用来维护一个最大(小)数据作为跟节点的值…
分析:对于这种删边操作,我们通常可以先读进来,然后转化离线进行倒着加边 #include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> using namespace std; typedef pair<int,int>pii; ; pii p[N<<]; int v[N],fa[N],n,m,q; ]; struct Ask{ int o…
https://cn.vjudge.net/problem/ZOJ-3261 题意 银河系各大星球之间有不同的能量值, 并且他们之间互相有通道连接起来,可以用来传递信息,这样一旦有星球被怪兽攻击,便可通过通道找到能量值最大的星球来帮忙.但是有一些通道被怪兽破坏了. 现在先给出原来的所有通道, 然后进行询问,询问有两种方式: destroy a b: 连接a,b的通道被怪兽破坏了 query a: 询问a能否通过通道找到救兵,只能找能量值比自己大的救兵. 分析 逆向思维,先离线存储所有的输入操作,…