[题目链接]:http://codeforces.com/contest/777/problem/C [题意] 给你n行m列的矩阵: 然后给你k个询问[l,r]; 问你在第l到第r行,是否存在一个列,这一列的第l到第r行是升序的; 是输出YES,否则输出NO [题解] /* 对于每一列; 从小到大枚举行; 对于第i行; 看看从第i个元素能有序多长,dp[i]; 然后对于j (j∈[i..i+dp[i]-1]),dp[j] = dp[i]-(i-j); 然后i = i+dp[i]; 记录下第i行,…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so afte…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The…
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…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wr…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 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, rea…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 设dis[v]表示v以上的点到达这个点的最大权值(肯定是它的祖先中的某个点到这个点) 类似于最大连续累加和 当往下走(x,y)这条边的时候,设其权值为w,以及到目前为止走过的最大权值和cur 如果cur<0,那么就不要之前的路径了,直接加上cur. 否则连着之前的路径加上去就好. 这样就能贪心地求出来dis[v]了 如果dis[x]>a[x]那么它以及它下面的所有节点都要删掉(因为要从叶子节点开始删) 如果dis[x]<=a[x]…
During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables. Now she has a table filled with integers. The table consists of n rows and m columns. By \(a_{i, j}\) we will denote the integer loc…
http://codeforces.com/problemset/problem/777/C 题意:给一个矩阵,对于每一列定义一个子序列使得mp[i][j] >= mp[i-1][j],即如果满足这样的情况,那么序列长度+1.给出q个询问,问[l,r]的行区间内是否有一个这样的子序列. 思路:用两个数组,第一个数组row记录每一列到第i行的序列长度,第二个数组ans记录每一行到第j列最长的序列长度.然后询问的时候判断ans[r]是否有区间长度大就可以了. 5 41 2 3 53 1 3 24 5…
Alyona and the Tree Descriptions 小灵决定节食,于是去森林里摘了些苹果.在那里,她意外地发现了一棵神奇的有根树,它的根在节点 1 上,每个节点和每条边上都有一个数字. 小灵注意到树上有一些节点不开心,所以她决定和它们一起玩. 如果节点 v 的子树中有一个节点 u 使得dist(v, u) > au ,那么节点 v 就会不开心.au 代表节点 u 上的数字,dist(v, u)代表连接节点 v 到节点 u 的所有边上的数字和,也就是两个节点的距离. 通过 1 条边连…