给出n个循环位置,每个位置有一定数量的盒子,每次操作可以使一个盒子转移到相邻位置,问最少需要转移多少次使得所有位置上的盒子的数量不会超过1个。简单题。对于每个位置,加边(s,i,a[i],0),(i,t,1,0)。对于相邻的位置加边(i,i+1,inf,1),(i,i-1,inf,1) 。显然最后我...
分类:
其他好文 时间:
2014-07-28 13:49:10
阅读次数:
189
题目:Codeforces Round #258 (Div. 2)Devu and Flowers
题意:n个boxes ,第i个box有fi个flowers,每个boxes中的flowers完全相同,不同boxes的flowers不同,求从n个boxes中取出s个flowers的方案数。n
排列组合的题目,一解法可用容斥原理(inclusion
exclusion principle)...
分类:
其他好文 时间:
2014-07-27 11:38:24
阅读次数:
198
用STL中的list写的,TLE
#include
#include
#include
#include
#include
using namespace std;
list l;
list::iterator it1,it2,it3,it4,it5,it;
void work(int a,int a1=1,int a2=1)
{
it1=find(l.begin(),l.end(...
分类:
其他好文 时间:
2014-07-26 17:23:02
阅读次数:
815
题目大意你有一行盒子,从左到右依次编号为1, 2, 3,…, n。你可以执行四种指令:1 X Y表示把盒子X移动到盒子Y左边(如果X已经在Y的左边则忽略此指令)。2 X Y表示把盒子X移动到盒子Y右边(如果X已经在Y的右边则忽略此指令)。3 X Y表示交换盒子X和Y的位置。4 表示反转整条链。盒子个...
分类:
其他好文 时间:
2014-07-24 12:20:15
阅读次数:
264
Frame StackingTime Limit:1000MSMemory Limit:10000KTotal Submissions:4034Accepted:1352DescriptionConsider the following 5 picture frames placed on an 9...
分类:
其他好文 时间:
2014-07-21 00:04:17
阅读次数:
399
双向链表注意:如果算法是最后处理翻转情况时,注意指令4翻转后1,2两个指令也要翻转处理; 指令3 中交换盒子要注意两个盒子相邻的情况 1 #include 2 #include 3 using namespace std; 4 5 int ri[100010],le[100010]; 6 ...
分类:
其他好文 时间:
2014-07-19 17:15:13
阅读次数:
154
There are two identical boxes. One of them contains n balls, while the other box contains one ball. Alice and Bob invented a game with the boxes and b...
分类:
其他好文 时间:
2014-07-19 14:25:51
阅读次数:
228
Marbles
Input: standard input
Output: standard output
I have some (say, n) marbles (small glass balls) and I am going to buy some boxes to store them. The boxes are of two types:
Type 1: each ...
分类:
其他好文 时间:
2014-07-19 08:01:10
阅读次数:
264
??
Description
Petya has k matches, placed in n matchboxes lying in a line from left to right.
We know that k is divisible by n. Petya wants all boxes to have the same number of matches in...
分类:
其他好文 时间:
2014-07-17 20:35:53
阅读次数:
249
Description
Imagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move north, south, east or west one cell at a step. T...
分类:
其他好文 时间:
2014-07-08 21:04:29
阅读次数:
347