[atcoder contest 010] F - Tree Game】的更多相关文章

[atcoder contest 010] F - Tree Game Time limit : 2sec / Memory limit : 256MB Score : 1600 points Problem Statement There is a tree with N vertices, numbered 1 through N. The i-th of the N−1 edges connects vertices ai and bi. Currently, there are Ai s…
题目传送门:https://agc010.contest.atcoder.jp/tasks/agc010_f 题目大意: 给定一棵树,每个节点上有\(a_i\)个石子,某个节点上有一个棋子,两人轮流操作:从棋子所在点上移出一个石子,并将棋子移动到相邻的节点,不能操作的人为输,问哪些节点放棋子使得先手必胜? 性质题--动棋子必定移动到石子数比当前位置少的点,否则该点是个先手必败点,然后\(n^2\)搜索一下就好了-- /*program from Wolfycz*/ #include<cmath>…
AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题解 洛谷认为此题过水,已被隐藏. #include<iostream> #include<cstdio> using namespace std; inline int read() { int x=0;bool t=false;char ch=getchar(); while((ch…
AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\) 思路 首先最大值最小,考虑二分答案. 如何check呢. 只有两个坐标,考虑2-sat. 可是边有点多,存不下来,考虑线段树优化建图. 如何建图. 先按照做坐标排序,我们有两个点的范围 [id[x]-mid,id[x]+mid],[id[y]-mid,id[y]+mid]. 这个显然是z选了,区…
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) \[x=i,g(x)=0\] \[x\ne i ,g(x)=1\] 则我们可以构造 \[f(x)=\sum^{i=0}_{P-1}(-a_i*(x-i)^{P-1}+a_i)\] 对于第\(i\)条式子当且仅当\(a_i=1 \ and \ x=i\)时取到\(1\) 代码写的比较奇怪 const…
传送门:http://codeforces.com/contest/1092/problem/F F. Tree with Maximum Cost time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a tree consisting exactly of nn vertices. Tree is a…
Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/problem/F Solution 设\(v_i\)表示第\(i\)个点的果子数,设\(b_i=v_i-\sum_{x\in son}v_x\),显然依题意要满足\(b_i\geqslant 0\). 根据差分的性质我们可以得到\(\sum b_i=x\). 假设我们硬点树上剩下了\(m\)个点,则…
F. Tree Factory Bytelandian Tree Factory produces trees for all kinds of industrial applications. You have been tasked with optimizing the production of a certain type of tree for an especially large and important order. The tree in question is a roo…
Colorful Tree 思路: 如果强制在线的化可以用树链剖分. 但这道题不强制在线,那么就可以将询问进行差分,最后dfs时再计算每个答案的修改值, 只要维护两个数组就可以了,分别表示根节点到当前节点某个颜色的个数和某个颜色长度和 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1…
Description 题面 Solution HNOI-day2-t2 复制上去,删点东西,即可 \(AC\) #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1000010; int n,a[N],w[N],fa[N]; struct data{ ll w;int s,x; bool operator <(const data &p)const{ if(w*p.s!=…