E. Little Girl and Problem on Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little girl loves problems on trees very much. Here's one of them. A tree is an undirected connected g…
传送门:http://codeforces.com/contest/1108/problem/E2 E2. Array and Segments (Hard version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions i…
题解看这里 liouzhou_101的博客园 更简洁的代码看这里: #include <bits/stdc++.h> using namespace std; typedef long long LL; #define X first #define Y second inline void read(int &x) { int flag = 1; char ch; while(!isdigit(ch=getchar()))if(ch=='-')flag=-flag; for(x=0;…
题解请看 Felix-Lee的CSDN博客 写的很好,不过最后不用判断最小值是不是1,因为[i,i]只有一个点,一定满足条件,最小值一定是1. CODE 写完就A,刺激. #include <bits/stdc++.h> using namespace std; typedef long long LL; #define X first #define Y second inline void read(int &x) { int flag = 1; char ch; while(!i…
题目链接 G. Yash And Trees time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Yash loves playing with trees and gets especially excited when they have something to do with prime numbers. On his 2…
CodeForces 877E DFS序+线段树 题意 就是树上有n个点,然后每个点都有一盏灯,给出初始的状态,1表示亮,0表示不亮,然后有两种操作,第一种是get x,表示你需要输出x的子树和x本身一共有几个灯是亮的.pow x,表示你需要改变x的子树和x本身上的灯的状态. 题解思路 这个题肯定是用DFS序了,为啥?因为树不好操作啊(我也不会啊),使用DFS序可以把树压成一维的一串数,这样就可以使用线段树来进行区间操作了. 话说这个题是我暑假限时训练中做的,看到这个题老开心了,但是让我万万没想…
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最多上一次,所有客人菜单不能相同.给出三种菜的数量,问最多能接收多少客人. 思路: 一人一道 → 一人两道 → 一人三道. #include <bits/stdc++.h> using namespace std; int main() { int t;cin>>t; while(t--…
题目链接:http://codeforces.com/problemset/problem/838/B You are given a directed weighted graph with n nodes and 2n - 2 edges. The nodes are labeled from 1 to n, while the edges are labeled from 1 to 2n - 2. The graph's edges can be split into two parts.…
A. Lunch Rush 模拟. B. Little Girl and Game 因为可以打乱顺序,所以只关心每种数字打奇偶性. 若一开始就是回文,即奇数字母为0或1种,则先手获胜. 若奇数字母大于1,则只需要考虑奇数字母个数的奇偶性.因为后手可以保证奇数字母个数的奇偶性. C. Little Girl and Maximum Sum 考虑每个位置覆盖次数,显然覆盖次数多分配大权值. D. Little Girl and Maximum XOR 找到 \(l,r\) 不相同的最高位,那么为了异…
A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time u…