hzwer 模拟题 祖孙询问】的更多相关文章

祖孙询问 题目描述 已知一棵n个节点的有根树.有m个询问.每个询问给出了一对节点的编号x和y,询问x与y的祖孙关系. 输入输出格式 输入格式: 输入第一行包括一个整数n表示节点个数. 接下来n行每行一对整数对a和b表示a和b之间有连边.如果b是-1,那么a就是树的根. 第n+2行是一个整数m表示询问个数. 接下来m行,每行两个正整数x和y. 输出格式: 对于每一个询问,如果x是y的祖先,输出1:如果y是x的祖先,输出2:否则输出0. 输入输出样例 输入样例#1: 复制 10 234 -1 12…
一:成绩 Day1 score=100+100+20 Day2 score=100+30+0 这成绩还是不行啊,仍需继续加油(抱怨一句暴力分有点少#滑稽) 二:题目分析 Day1 T1祖孙询问: 已知一棵 n 个节点的有根树.有 m 个询问.每个询问给出了一对节点的编号 x 和 y,询问 x与 y 的祖孙关系. 分析: 这道题用一个lca随便就可以水过啦...(我一开始把祖先理解成了父亲orz) T2比赛: 由 A 中的一个选手与 B 中的一个选手对抗.同一个人不会参加多场比赛,每个人的对手都是…
\(NOIP\)模拟题汇总(加厚版) T1 string 描述 有一个仅由 '0' 和 '1' 组成的字符串 \(A\),可以对其执行下列两个操作: 删除 \(A\)中的第一个字符: 若 \(A\)中 '1' 出现的次数为奇数,则在 \(A\) 的末尾插入 '1',否则在 \(A\) 的末尾插入 '0'. 现在给出一个同样仅由 '0' 和 '1' 组成的字符串 \(B\),请你判断 \(A\) 能否在任意多次操作后转化为 \(B\). 输入 输入文件第一行一个正整数 \(T\),表示有 \(T\…
In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are usually designed to serve as an educational exercise to give participants experience in securing a machine, as well as conducting and reacting to the so…
Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, profes…
Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 Description A crossword puzzle consists of a rectangular grid of black and white squares and two lists of definitions (or descriptions). One list of de…
Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of t…
The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Now it's 20000 A.D., and the androids also participate in the ACM Inter-national Collegiate Programming Contest (ACM/ICPC). In order to sele…
题目名称 正确答案  序列问题 长途旅行 英文名称 answer sequence travel 输入文件名 answer.in sequence.in travel.in 输出文件名 answer.out sequence.out travel.out 时间限制 1s 1s 1s 空间限制   256M 256M 256M 测试点数目 20 20 10 测试点分值 5 5 10 是否有部分分 无 无 无 题目类型 传统 传统 传统 是否有 SPJ 无 无 无 正确答案 全国信息学奥林匹克联赛(…
Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2223 Descriptionww.co For a dance to be proper in the Altered Culture of Machinema, it must abide by the following rules: A dip…