A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have eq…
A. Alyona and copybooks Problem Description: Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs…
题目描述: Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive int…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each…
C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is…
C. Alyona and Spreadsheet time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit table…
题目链接:http://codeforces.com/problemset/problem/682/C 题意:如果点v在点u的子树上且dist(u,v)>a[v]则u和其整个子树都将被删去,求被删去的点数. 思路:1为根节点,从1开始DFS遍历,记录距离dis为到祖宗节点的最大距离. #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+5; int a[N],num[N],a…
Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Aly…
Alyona and the Tree 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/C Description Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every v…
Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. re…
Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers - the first column containing inte…
Alyona and Triangles 题目连接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/J Description You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n point…
Alyona and towers 这个题写起来真的要人命... 我们发现一个区间被加上一个d的时候, 内部的结构是不变的, 改变的只是左端点右端点的值, 这样就能区间合并了. 如果用差分的话会简单一些, 就变成了求前一段是负数,后一段是正数的最长段多长. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<…
D. Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive in…
Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on. The girl noticed that some of the tree…
题目链接 Alyona and a tree 比较考验我思维的一道好题. 首先,做一遍DFS预处理出$t[i][j]$和$d[i][j]$.$t[i][j]$表示从第$i$个节点到离他第$2^{j}$近的祖先,$d[i][j]$表示从$i$开始到$t[i][j]$的路径上的路径权值总和. 在第一次DFS的同时,对节点$x$进行定位(结果为$dist(x, y)<=a(y)$)的离$x$最远的$x$的某个祖先,然后进行$O(1)$的差分. 第一次DFS完成后,做第二次DFS统计答案(统计差分后的结…