CodeForces - 356A Knight Tournament】的更多相关文章

http://codeforces.com/problemset/problem/356/A 首先理解题意 每次给出l 和r  在l - r之间还有资格的选手中得出一个胜者 暴力思路: 首先维护还有资格的选手的集合 用一个数组 表示 这个选手被谁击败 每次遍历 l - r 然后把不是胜者 且 还在集合中的选手踢出 并更新这个选手的数组值 最终 输出这个数组即可 这样会TLE 1. 如果用数组维护这个集合的话 每次遍历都是这样就是O(n^2) -->> 所以用set维护这个集合 2.使用set后…
 Knight Tournament time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights…
Knight Tournament Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event. As for you, you're just a simple pea…
Description Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event. As for you, you're just a simple peasant.…
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event. As for you, you're just a simple peasant. There's no s…
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event. As for you, you're just a simple peasant. There's no s…
Problem description Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event. As for you, you're just a simple p…
[链接] 我是链接,点我呀:) [题意] n个人矩形m场比赛 每场比赛由编号为li~ri且之前没有被淘汰的人进行. 已知第i场的winner是xi winner会把这一场其他所有的人都淘汰. 问你n个人每个人都是被谁给淘汰的. [题解] 并查集 初始条件f[i] = i,nex[i] = i + 1; 每一轮战斗,让输的人的f[find_father(i)]变成x[i] 但是在执行f[find_father(i)]=x[i]的时候 我们要记录一下ans[find_father(i)] = x[i…
题目:http://codeforces.com/problemset/problem/356/A 题意:首先给你n,m,代表有n个人还有m次描述,下面m行,每行l,r,x,代表l到r这个区间都被x所击败了(l<=x<=r),被击败的人立马退出游戏让你最后输出每个人是被谁击败的,最后那个胜利者没被 人击败就输出0 思路:他的每次修改的是一个区间的被击败的人,他而且只会记录第一次那个被击败的人,用线段树堕落标记的话他会记录最后一次的,所以我们倒着来修改, 然后因为那个区间里面还包含了自己,在线段…
脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> #include <set> using namespace std; ]; set<int>se; set<int>::iterator it1,it,it2; int main() { int i,x,y,num,n,m; scanf("%d%d"…