[BZOJ 2759] 一个动态树好题 题目描述 首先这是个基环树. 然后根节点一定会连出去一条非树边.通过一个环就可以解除根的答案,然后其他节点的答案就可以由根解出来. 因为要修改\(p_i\),所以我们用\(lct\). 还是有点难写的. 代码: #include<bits/stdc++.h> #define ll long long #define N 30005 #define ls ch[v][0] #define rs ch[v][1] using namespace std; i
http://poj.org/problem? id=1741 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called va
Description 有N个未知数x[1..n]和N个等式组成的同余方程组: x[i]=k[i]*x[p[i]]+b[i] mod 10007 其中,k[i],b[i],x[i]∈[0,10007)∩Z 你要应付Q个事务,每个是两种情况之一: 一.询问当前x[a]的解 A a 无解输出-1 x[a]有多解输出-2 否则输出x[a] 二.修改一个等式 C a k[a] p[a] b[a] Input N 下面N行,每行三个整数k[i] p[i] b[i] Q 下面Q行,每行一个事务,格式见题目描
Implement a trie with insert, search, and startsWith methods. 实现字典树,前面好像有道题做过类似的东西,代码如下: class TrieNode { public: // Initialize your data structure here. TrieNode():isLeaf(false) { for(auto & t : dic){ t = NULL; } } TrieNode * dic[]; bool isLeaf; };