#316 div.2】的更多相关文章

D. Tree Requests time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the…
C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem/C Description Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replac…
主要记录下被坑的B.果然大晚上脑子就是不知道在干嘛,明明都测到 “1 1” 这个样例错了都没发现直接给放过去了,白白让人hack爽了... 题意就是给你一个数m,让你从1~n个数中选一个作a,使1~n中的任意选一个数c,满足|c-m| > |c-a|的可能性最大,也就是离m近的数比离a近的数多,多种可能输出小的: 画一下草图就能知道算是个几何概率吧,如果m-1 > n-m,即m离1近,那么在m+1~n中选一个位置a都会有更大的可能使离a近的数比离m近的数多:而其中概率最大的就是m+1 -- 只…
C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem/C Description Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replace…
A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many peopl…
Problem D: 题意:给定一棵n个点树,每个点有一个字母,有m个询问,每次询问某个节点x的子树中所有深度为k的点能否组成一个回文串 分析:一堆点能组成回文串当且仅当数量为奇数的字母不多于1个,显然这个状态可以用二进制表示 那么对于单个询问如何快速找到所有符合要求的点呢? 这里可以考虑树的dfs序,我们把深度相同的点按照dfs序加入集合中,易知在同一颗子树中的点肯定形成了一个连续的区间. 因此每次可以通过二分子树根节点的进入dfs序的时间和出dfs序的时间来找到这个区间 找到区间后可以根据预…
题目:Click here 题意:看一下题目下面的Note就会明白的. 分析:一开始想的麻烦了,用了树状数组(第一次用)优化,可惜没用. 直接判断: #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; ; int n, m; char str[M]; int main() { while( ~scanf("%d %d", &n,…
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; +; int n, m; int main() { while( ~scanf("%d %d", &n, &m ) ) { ) { printf("1\n"); continue; } ) printf( ); else…
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; +; int n, m; ]; ]; int main() { while( ~scanf("%d%d", &n, &m ) ) { memset( b, , sizeof(b) ); ; i<=m; i++ ) { ; j<=n…
B. Simple Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let'…