Codeforces Round #266 (Div. 2)E(判断父子关系+离线)
来源:互联网 发布:淘宝卖大米的营销策略 编辑:程序博客网 时间:2024/04/30 08:11
There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:
- either employee y became the boss of employee x (at that, employee x didn't have a boss before);
- or employee x gets a packet of documents and signs them; then he gives the packet to his boss. The boss signs the documents and gives them to his boss and so on (the last person to sign the documents sends them to the archive);
- or comes a request of type "determine whether employee x signs certain documents".
Your task is to write a program that will, given the events, answer the queries of the described type. At that, it is guaranteed that throughout the whole working time the company didn't have cyclic dependencies.
The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of employees and the number of events.
Each of the next m lines contains the description of one event (the events are given in the chronological order). The first number of the line determines the type of event t (1 ≤ t ≤ 3).
- If t = 1, then next follow two integers x and y (1 ≤ x, y ≤ n) — numbers of the company employees. It is guaranteed that employee xdoesn't have the boss currently.
- If t = 2, then next follow integer x (1 ≤ x ≤ n) — the number of the employee who got a document packet.
- If t = 3, then next follow two integers x and i (1 ≤ x ≤ n; 1 ≤ i ≤ [number of packets that have already been given]) — the employee and the number of the document packet for which you need to find out information. The document packets are numbered started from 1 in the chronological order.
It is guaranteed that the input has at least one query of the third type.
For each query of the third type print "YES" if the employee signed the document package and "NO" otherwise. Print all the words without the quotes.
4 91 4 32 43 3 11 2 32 23 1 21 3 12 23 1 3
YESNOYES
- Codeforces Round #266 (Div. 2)E(判断父子关系+离线)
- Codeforces Round #446 (Div. 2) E. Envy 最小生成树(kruscal原理)(离线查询)
- 解题报告:Codeforces Round #433 (Div. 2) E. Boredom ( 离线处理+树状数组)
- Codeforces Round #221 (Div. 2) E. Circling Round Treasures (搜索+判断点在多边形内)
- Codeforces Round #368 (Div. 2) D. Persistent Bookcase(离线)
- Codeforces 466E Information Graph【Dfs处理父子关系+并查集+离线查询】好题!
- Codeforces Round #266 (Div. 2) Problem E Solution
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces Round #262 (Div. 2)E(贪心+暴搜)
- Codeforces Round #257 (Div. 2)E(数论+构造)
- Codeforces Round #256 (Div. 2)E(DFS暴搜)
- Codeforces Round #FF (Div. 2)E(线段树成段更新)
- Codeforces Round #265 (Div. 2)E(数位dp)
- Codeforces Round #254 (Div. 2)E(线段树懒标记)
- Codeforces Round #281 (Div. 2)E(数学)
- Codeforces Round #249 (Div. 2)E(构造)
- Codeforces Round #291 (Div. 2)E(DP+矩阵)
- Codeforces Round #117 (Div. 2)E---Wooden Fence(dp)
- python处理excel
- linux 命令
- 初学Cocos2d-x3.1物理碰撞(1)
- 言的幸运数 swun1701
- 内部类在迭代器设计模式中的应用
- Codeforces Round #266 (Div. 2)E(判断父子关系+离线)
- 面试总结:用Java搞定面试中的链表题目
- 第一记
- IOS多线程编程之NSOperation和NSOperationQueue的使用
- libsvm在python下的使用及用绘制ROC曲线
- Codeforces Round #266 (Div. 2)C(算是简单计数吧)
- ConCurrentMap的分析和思考 .
- Word中小论文插入自传内容
- 怎么发邮件,javaMail