Codeforces G. Ciel the Commander】的更多相关文章

题目描述: Ciel the Commander time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undire…
Ciel the Commander Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 321C64-bit integer IO format: %I64d      Java class name: (Any) Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its na…
E. Ciel the Commander Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/322/problem/E Description Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undirected ro…
树链剖分可以看成是树的边分治,什么是点分治呢? CF322E - Ciel the Commander 题目:给出一棵树,对于每个节点有一个等级(A-Z,A最高),如果两个不同的节点有相同等级的父节点(节点不一定相同),则两个节点的路径上最少有一个比他们两的等级都高的节点.要求输出1~n的等级. 分析:考虑一条链的情况,如果把A放中间,把数列分成两段,对于每一段,中间放B,这样分成了四段,对于每一段继续这样分,显然26个字母可以安放2^26个位置. 对于树这种结构的话,如何安放? 类似于一条链的…
E. Ciel the Commander Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undirected roads, and for any two cities there always exists a path between them. Fox Ciel needs to assign an officer…
链接 大意: 给定n结点树, 求构造一种染色方案, 使得每个点颜色在[A,Z], 且端点同色的链中至少存在一点颜色大于端点 (A为最大颜色) 直接点分治即可, 因为最坏可以涂$2^{26}-1$个节点, 所以方案一定存在 #include <iostream> #include <algorithm> #include <cstdio> #include <vector> #define REP(i,a,n) for(int i=a;i<=n;++i)…
传送门:http://codeforces.com/problemset/problem/321/E [题解] 首先有一个$O(n^2k)$的dp. # include <stdio.h> # include <string.h> # include <iostream> # include <algorithm> // # include <bits/stdc++.h> using namespace std; typedef long lon…
题目链接:http://codeforces.com/problemset/problem/322/B 题目意思:给定红花.绿花和蓝花的朵数,问组成四种花束(3朵红花,3朵绿花,3朵蓝花,1朵红花+1朵绿花+1朵蓝花)的总数最大为多少. 一开始以为是水题,其实很多情况都没有考虑到,反反复复修改终于过了. 其实要考虑两种情况,这两种情况较好的那种就是最优解.姑且把四种花束分为两种类型:清一色型(3朵红,3朵绿,3朵蓝)和混杂型(红绿蓝各一朵). 第一种情况就是,保证清一色型最多(3种花都要除以3)…
题目链接   Ciel and Flipboard 题意  给出一个$n*n$的正方形,每个格子里有一个数,每次可以将一个大小为$x*x$的子正方形翻转 翻转的意义为该区域里的数都变成原来的相反数. 求经过若干次操作之后整个正方形的所有数之和. 这题关键就是要知道这个结论. 假设$st[i][j]$为$a[i][j]$的翻转情况($st[i][j] = 0$ 不翻转  $st[i][j] = 1$ 翻转) 那么一定有 $st[i][j]$ xor $st[i][x]$ xor $st[i][j…
题目链接:http://codeforces.com/problemset/problem/321/A 题意:在一个二维平面中,開始时在(0,0)点,目标点是(a.b),问能不能通过反复操作题目中的指令,从原点移动到目标点. 分析:如果一次完毕全部的命令后.移动到了(xx,yy),而且从(Xi.Yi)反复操作k次指令到达目标点.则能够列出方程 Xi + k * xx = a && Yi + k * yy = b.然后解出k.推断k是否大于等于0就可以. #include <cstdi…