Live2d Test Env

随笔分类 -  CodeForces

摘要:Mr. Kitayuta has just bought an undirected graph with n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely ed 阅读全文
posted @ 2018-12-26 11:13 nimphy 阅读(565) 评论(0) 推荐(0)
摘要:n players are going to play a rock-paper-scissors tournament. As you probably know, in a one-on-one match of rock-paper-scissors, two players choose t 阅读全文
posted @ 2018-12-25 20:37 nimphy 阅读(414) 评论(0) 推荐(0)
摘要:Piegirl found the red button. You have one last chance to change the inevitable end. The circuit under the button consists of n nodes, numbered from 0 阅读全文
posted @ 2018-12-21 13:54 nimphy 阅读(495) 评论(3) 推荐(1)
摘要:Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote t 阅读全文
posted @ 2018-12-20 17:11 nimphy 阅读(364) 评论(0) 推荐(0)
摘要:In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush 阅读全文
posted @ 2018-12-20 15:35 nimphy 阅读(450) 评论(0) 推荐(0)
摘要:As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent N 阅读全文
posted @ 2018-12-20 15:24 nimphy 阅读(245) 评论(0) 推荐(0)
摘要:Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r 阅读全文
posted @ 2018-12-20 15:09 nimphy 阅读(352) 评论(0) 推荐(0)
摘要:D1. Great Vova Wall (Version 1): 题意:给定长度为N的墙,以及每个位置的一些高度,现在让你用1*2的砖和2*1的砖去铺,问最后能否铺到高度一样。 思路:分析其奇偶性,在一个位置加1*2的砖,其奇偶性不变。在相邻的而且高度相同的位置加2*1的砖,两个奇偶行都改变。那么我 阅读全文
posted @ 2018-12-19 12:30 nimphy 阅读(445) 评论(0) 推荐(0)
摘要:题意:N,K,L,以及给定长度为N的序列,表示其对应的颜色,-1表示还没有涂色,现在让你去涂色,使得最后没有大于等于L的连续的同色的情况。 思路:我们用dp[i][j]表示第i个位置颜色为j的合法方案数,用sum[i]表示dp[i][1]+dp[i][2]+...dp[i][k]。 那么a[i]== 阅读全文
posted @ 2018-12-17 15:26 nimphy 阅读(498) 评论(0) 推荐(0)
摘要:A. Definite Game: 题意:输入N,输出最小的结果N-x,其中x不少N的因子。 思路:N=2时,输出2;其他情况输出1;因为N>2时,N-1不会是N的因子。 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) 阅读全文
posted @ 2018-12-17 10:24 nimphy 阅读(239) 评论(0) 推荐(0)
摘要:题意:给定无向图,让你给点加权(1,2,3),使得每条边是两端点点权和维奇数。 思路:一个连通块是个二分图,判定二分图可以dfs,并查集,2-sat染色。 这里用的并查集(还可以带权并查集优化一下,或者干脆用dfs)。 计数的时候每个连通块单独考虑,我们从连通块的第一个点开始dfs,如果是该填奇数点 阅读全文
posted @ 2018-12-16 14:38 nimphy 阅读(565) 评论(0) 推荐(0)
摘要:题意:给定N个K维的点,Q次操作,或者修改点的坐标;或者问[L,R]这些点中最远的点。 思路:因为最后一定可以表示维+/-(x1-x2)+/-(y1-y2)+/-(z1-z2)..... 所以我们可以保存到线段树里,每次求区间最大值和最小值即可。 注意到我们可以先确定一个点的正负号,所以时间和空间节 阅读全文
posted @ 2018-12-16 14:33 nimphy 阅读(486) 评论(0) 推荐(0)
摘要:题意:给定长度为N的a数组,和b数组,a和b都是1到N的排列; 有两种操作,一种是询问[L1,R1],[L2,R2];即问a数组的[L1,R1]区间和b数组的[L2,R2]区间出现了多少个相同的数字。 一种是修改b数组两个位置的值。 思路:如果把b数组每个数取对应a数组对应数的位置,即按照b的下标建 阅读全文
posted @ 2018-12-16 12:52 nimphy 阅读(431) 评论(0) 推荐(0)
摘要:A. The Fair Nut and the Best Path 题意:给定有点权,有边权的树,让你选择一条链(也可以是只有一个点),使得点权之和-边权最大。 思路:裸的树形DP,我们用dp[i]表示i的子树里某个点到i这条链的最大值,然后用次大值更新答案即可。 具体的,每个dp[i]初始化=a[ 阅读全文
posted @ 2018-12-11 14:00 nimphy 阅读(366) 评论(0) 推荐(0)
摘要:You are given two integers l l and r r (l≤r l≤r ). Your task is to calculate the sum of numbers from l l to r r (including l l and r r ) such that eac 阅读全文
posted @ 2018-12-01 20:04 nimphy 阅读(448) 评论(0) 推荐(0)
摘要:You are a given a list of integers a 1 ,a 2 ,…,a n a1,a2,…,an and s s of its segments [l j ;r j ] [lj;rj] (where 1≤l j ≤r j ≤n 1≤lj≤rj≤n ). You need t 阅读全文
posted @ 2018-11-30 19:23 nimphy 阅读(550) 评论(0) 推荐(0)
摘要:Vasya has a tree consisting of n n vertices with root in vertex 1 1 . At first all vertices has 0 0 written on it. Let d(i,j) d(i,j) be the distance b 阅读全文
posted @ 2018-11-30 11:40 nimphy 阅读(281) 评论(0) 推荐(0)
摘要:Graph constructive problems are back! This time the graph you are asked to build should match the following properties. The graph is connected if and 阅读全文
posted @ 2018-11-29 15:16 nimphy 阅读(853) 评论(0) 推荐(0)
摘要:Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of n n vertices and m m edges. The weight of the i i -th vertex 阅读全文
posted @ 2018-11-29 15:05 nimphy 阅读(781) 评论(0) 推荐(2)
摘要:You are given array a a of length n n . You can choose one segment [l,r] [l,r] (1≤l≤r≤n 1≤l≤r≤n ) and integer value k k (positive, negative or even ze 阅读全文
posted @ 2018-11-29 14:12 nimphy 阅读(495) 评论(0) 推荐(0)