12 2018 档案
摘要:A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is
阅读全文
摘要:All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d1,d2,…,dk can be used to form ticket
阅读全文
摘要:Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length n consisting of lowercase La
阅读全文
摘要:题意:现在有包括了Bob在内的N个小朋友,M种游戏卡片,Bob可以和其他人交换卡片,除了Bob,每个人的交换原则都是只给出自己拥有大于1的卡片,接受自己没有的卡片。问他最多有多少不同的卡片。 N<=10; M<=25; 思路:最大流,卡片流向玩家表示Bob付出卡片,玩家流向卡片,边数玩家给Bob卡片
阅读全文
摘要:We consider problems concerning the number of ways in which a number can be written as a sum. If the order of the terms in the sum is taken into accou
阅读全文
摘要:The Wall has down and the King in the north has to send his soldiers to sentinel. The North can be regard as a undirected graph (not necessary to be c
阅读全文
摘要:As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of b
阅读全文
摘要:You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in the city you know whom he
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Jolly and Emily are two bees studying in Computer Science. Unlike other bees they are fond of playing two-player games. They used to play Tic-tac-toe,
阅读全文
摘要:描述 小Hi和小Ho经常一起结对编程,他们通过各种对弈游戏决定谁担任Driver谁担任Observer。 今天他们的对弈是在一棵有根树 T 上进行的。小Hi和小Ho轮流进行删除操作,其中小Hi先手。 游戏的规则是:每次删除,小Hi或小Ho都可以选择一个非根节点,将以该节点为根的子树从 T 中删除。如
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:D1. Great Vova Wall (Version 1): 题意:给定长度为N的墙,以及每个位置的一些高度,现在让你用1*2的砖和2*1的砖去铺,问最后能否铺到高度一样。 思路:分析其奇偶性,在一个位置加1*2的砖,其奇偶性不变。在相邻的而且高度相同的位置加2*1的砖,两个奇偶行都改变。那么我
阅读全文
摘要:题意:N,K,L,以及给定长度为N的序列,表示其对应的颜色,-1表示还没有涂色,现在让你去涂色,使得最后没有大于等于L的连续的同色的情况。 思路:我们用dp[i][j]表示第i个位置颜色为j的合法方案数,用sum[i]表示dp[i][1]+dp[i][2]+...dp[i][k]。 那么a[i]==
阅读全文
摘要: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++)
阅读全文
摘要:题意:给定无向图,让你给点加权(1,2,3),使得每条边是两端点点权和维奇数。 思路:一个连通块是个二分图,判定二分图可以dfs,并查集,2-sat染色。 这里用的并查集(还可以带权并查集优化一下,或者干脆用dfs)。 计数的时候每个连通块单独考虑,我们从连通块的第一个点开始dfs,如果是该填奇数点
阅读全文
摘要:题意:给定N个K维的点,Q次操作,或者修改点的坐标;或者问[L,R]这些点中最远的点。 思路:因为最后一定可以表示维+/-(x1-x2)+/-(y1-y2)+/-(z1-z2)..... 所以我们可以保存到线段树里,每次求区间最大值和最小值即可。 注意到我们可以先确定一个点的正负号,所以时间和空间节
阅读全文
摘要:题意:给定长度为N的a数组,和b数组,a和b都是1到N的排列; 有两种操作,一种是询问[L1,R1],[L2,R2];即问a数组的[L1,R1]区间和b数组的[L2,R2]区间出现了多少个相同的数字。 一种是修改b数组两个位置的值。 思路:如果把b数组每个数取对应a数组对应数的位置,即按照b的下标建
阅读全文
摘要:题意:有N堆石子,每次可以取一堆的不超过半数的石子,没有可取的为输。 思路:假设只有一堆,手推出来,数量x可以表示为2^p-1形式的必输。 但是没什么用,因为最后要的不是0和1,而是SG函数;所以必输的为0,那么其他的呢? 我们可以发现SG=0的位置是1,3,7,15,31.... SG=1, 2,
阅读全文
摘要:2243: [SDOI2011]染色 Description 给定一棵有n个节点的无根树和m个操作,操作有2类: 1、将节点a到节点b路径上所有点都染成颜色c; 2、询问节点a到节点b路径上的颜色段数量(连续相同颜色被认为是同一段), 如“112221”由3段组成:“11”、“222”和“1”。 请
阅读全文
摘要:There are N boxes on the ground, which are labeled by numbers from 1 to N. The boxes are magical, the size of each one can be enlarged or reduced arbi
阅读全文
摘要:几个符号的认识: 或 | , c=a|b,二进制下c的第i位为1,当且当a和b的第i位不同时为0,即至少有一个1。 异或 ^ , c=a^b,二进制下c的第i位为1,当且当a和b的第i位不相同。 且 & , c=a|b,二进制下c的第i位为1,当且当a和b的第i位同时为1。 性质: ‘或’具有扩散性
阅读全文
摘要:A. The Fair Nut and the Best Path 题意:给定有点权,有边权的树,让你选择一条链(也可以是只有一个点),使得点权之和-边权最大。 思路:裸的树形DP,我们用dp[i]表示i的子树里某个点到i这条链的最大值,然后用次大值更新答案即可。 具体的,每个dp[i]初始化=a[
阅读全文
摘要:签到题这里久懒得写了。 B - 缺失的数据范围 Total Submission(s): 2602 Accepted Submission(s): 559 题意:求最大的N,满足N^a*[log2(N)]^b<=K; 思路:二分即可,log2要手写,然后就是注意判pow是否超过long long。
阅读全文
摘要:Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous s
阅读全文
摘要:Two students are playing the following game. There are 2· n points on the plane, given with their coordinates ( xi, yi). Each move player paints the p
阅读全文
摘要:2186: [Sdoi2008]沙拉公主的困惑 Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票。房地产第一大户沙拉公主决定预测一下大富翁国现在所有真钞票的数量。现在,请你帮助沙拉公主解决这个问
阅读全文
摘要:2121: 字符串游戏 Description BX正在进行一个字符串游戏,他手上有一个字符串L,以及其他一些字符串的集合S,然后他可以进行以下操作:对 于一个在集合S中的字符串p,如果p在L中出现,BX就可以选择是否将其删除,如果删除,则将删除后L分裂成的左右 两部分合并。举个例子,L='abcd
阅读全文
摘要:2118: 墨墨的等式 Description 墨墨突然对等式很感兴趣,他正在研究a1x1+a2y2+…+anxn=B存在非负整数解的条件,他要求你编写一个程序,给定N、{an}、以及B的取值范围,求出有多少B可以使等式存在非负整数解。 墨墨突然对等式很感兴趣,他正在研究a1x1+a2y2+…+an
阅读全文
摘要:2140: 稳定婚姻 Description 我国的离婚率连续7年上升,今年的头两季,平均每天有近5000对夫妇离婚,大城市的离婚率上升最快,有研究婚 姻问题的专家认为,是与简化离婚手续有关。25岁的姗姗和男友谈恋爱半年就结婚,结婚不到两个月就离婚,是典 型的“闪婚闪离”例子,而离婚的导火线是两个人
阅读全文
摘要:2124: 等差子序列 Description 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…<pLen<=N (Len>=3), 使得Ap1,Ap2,Ap3,…ApLen是一个等差序列。 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…
阅读全文
摘要: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
阅读全文
摘要:3298: [USACO 2011Open]cow checkers Description 一天,Besssie准备和FJ挑战奶牛跳棋游戏。这个游戏上在一个M*N的棋盘上, 这个棋盘上在(x,y)(0<=x棋盘的左下角是(0,0)坐标,棋盘的右上角是坐标(M-1,N-1)。 Bessie每次都是第
阅读全文