摘要:
Farthest Nodes in a Tree Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are w 阅读全文
摘要:
复健,时间有限题解比较简陋 A. Middle of the Contest 将小时转成分钟,得到起止时间在一天中的分钟数,取平均值即可,复杂度O(1)。平均值转换会时间的时候注意前导0。 void solve(int x) { x /= 2; printf("%02d:%02d\n", x / 6 阅读全文
摘要:
堆栈是一种经典的后进先出的线性结构,相关的操作主要有“入栈”(在堆栈顶插入一个元素)和“出栈”(将栈顶元素返回并从堆栈中删除)。本题要求你实现另一个附加的操作:“取中值”——即返回所有堆栈中元素键值的中值。给定 N 个元素,如果 N 是偶数,则中值定义为第 \(\frac{N}2\) 小元;若是奇数 阅读全文