CodeForces 500 A. New Year Transportation】的更多相关文章

Description New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the ce…
\(>Codeforces \space 500 E. New Year Domino<\) 题目大意 : 数轴上有序排列着 \(n\) 块多米诺骨牌, 第 \(i\) 块骨牌坐标为 \(p_i\) 长度为 \(l_i\) 如果推倒坐标为 \(p_i\) 的多米诺骨牌,那么区间 \([p_i, p_i + x_i]\) 中的多米诺骨牌都会被推倒,从而发生连锁反应. 现在有 \(q\) 组询问,每次询问之前可以让一些多米诺骨牌增加任意长度,代价是增加的长度之和. 询问的内容是每次推倒第 \(x\…
题目传送门:洛谷P5089. 题意简述: 一张 \(n \times m\) 的表格,有一些格子有标记,另外一些格子没有标记. 如果 \((r_1,c_1),(r_1,c_2),(r_2,c_1)\) (满足 \(r_1\ne r_2,c_1\ne c_2\))都有标记,那么可以不花费任何代价使得 \((r_2,c_2)\) 也有标记. 你也可以花费 \(1\) 的代价使得任意一个格子有标记. 问使得所有格子都有标记的最小花费 题解: 比赛时这题我想了很久,猜了一个奇怪的结论交上去就对了. 这里…
目录 #1. A + B Problem #2. Hello, World! #3. Copycat #4. Quine #7. Input Test #100. 矩阵乘法 #101. 最大流 #102. 最小费用流 #103. 子串查找 #104. 普通平衡树 #108. 多项式乘法 #119. 非负权单源最短路 #130. 树状数组 1 :单点修改,区间查询 #139. 树链剖分 #161. 乘法逆元 2 #556. 「Antileaf's Round」咱们去烧菜吧 #2030. 「SDOI…
题目链接:http://codeforces.com/problemset/problem/500/A 题目意思:给出 n-1 个 cell,每个 cell 有一个值 ai,表示在这个编号为 i 的 cell,能到达i + ai 的cell,但不能反过来,即从 i+ai 到达 i 这个 cell.问从第一个cell 开始,是否可以到达 t 这个cell. 第一次过不了pretest 是因为没有考虑到,如果 t = 1的情况,后来被人 hack 之后就不知道原因了...原来是因为第 n 个 cel…
Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<node>::iterator #define sqr(x) (…
题目链接: http://codeforces.com/gym/100825 题目大意: N(N<=600)个点,每个点有个名字Si,R(R<=200)个生产商在R个点上,F(F<=200)个工厂在F个点上,不会有一个点既有生产商又有工厂 有T(T<=1000)个公司,每个公司能够到达Ci个点,并且一个只能运输一个生产商的货物.比如生产商1给工厂1运输货物需要用到公司1,那么其余生产商就不能用公司1 一个工厂需要任意一个生产商供应货物,求最多能够给多少个工厂供应货物. 题目思路:…
从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemical table Problem E Hills Problem F AB-Strings 瞎扯 打比赛,发现自己越来越菜. 差点C题都不会了,怀疑人生... 发现自己C的贪心挂了两次然后D题不会怀疑不应来打这场比赛. 然后看到E.出题人的仁慈啊..终于不考智商了.提高组的送分dp(好吧,应该是省选里…
[题目链接] http://codeforces.com/problemset/problem/724/E [题目大意] 每个城市有pi的物品可以运出去卖,si个物品可以买, 编号小的城市可以往编号大的城市最多运送c的物品,问最多有多少物品可以被买卖 [题解] 源点向每个城市引pi的流,每个城市向汇点引si的流, 小编号的城市往大编号的城市引c的流,那么全图的最大流就是答案, 但是数据量过大,我们考虑转化. 因为最大流等于最小割,我们发现对于这个图,最后每个点不是跟s连就是跟t连, 那么我们设d…
CodeForces 1013B And CodeForces 1013C  Photo of The Sky B 可以发现只有一次与操作是有意义的,所以答案只有-1,0,1,2四种情况 #include <bits/stdc++.h> #define show(a) cout << #a << " = " << a << endl; ; ; ; typedef long long ll; using namespace st…
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People w…
[题目链接]:http://codeforces.com/problemset/problem/724/E [题意] 有n个城市; 这个些城市每个城市有pi单位的物品; 然后已知每个城市能卖掉si单位单位的物品: 且每个城市i能向城市j最多运送c单位的物品(这里j严格大于i); 问你最多能在这n个城市里面卖掉多少单位的物品; [题解] 可以转化为最大流模型; 虚拟一个起点s和源点t; 在s和n个城市之间分别建n条边pi; 在n个城市和t之间分别建n条边si; 在n个城市之间(x,y)建n*(n-…
Description 有 \(n\) 个点,每个点有一个入流和出流,每个点与编号比它大的点连边,容量为 \(c\) ,求最大流. Sol DP. 这种特殊的图可以DP,把最大流转化成最小割. 最小割就是 \(\sum s_i,i\in S + \sum p_j,j \in T + c \sum [i \in S][j\in T]\) . 最后一个式子其实就是 \(S\) 与 \(T\) 的割边. \(f[i][j]\) 表示前 \(i\) 个点有 \(j\) 个点 \(\in S\) 转移就是…
题意:给出n个数,终点t 从第i点能够跳到i+a[i],问能否到达终点 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set> #include<queue> #include<algor…
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int read() { ,f=;char c=getchar(); ;c=getchar();} )+(x<<)+(c^),c=getchar(); ret…
首先我们如果满足三缺一,那么必有同行和同列的点 如果两行有同列的数,我们可以设想,他们最后会全部填充成为两者啥都有的情况 显然这个是个并查集 现在我们有了很多集合,每个集合自己可以进行三缺一操作,但是集合有缺陷,集合里面的人都没有的列数,那就没法搞 可以贪心的想,一共k个集合的话,把k个集合连接起来需要k-1个新点,如果还有列没有,那就需要这些列需要新店 除此之外,一开始没有讨论有些行压根没有点,这些行也需要点去开辟疆土 综上所述,一开始论述的时候将行和列交换也是合理的 人总喜欢在伤心,劳累,挫…
妙啊 首先暴力建图跑最大流非常简单,s向每个i连流量为p[i]的边,每个i向t连流量为s[i]的边,每个i向j连流量为c的边(i<j),但是会又T又M 考虑最大流=最小割 然后dp求最小割,设f[i][j]为割到第i个点,有j条连着s(因为最小割中一个点不是连s就是连t),转移是 \[ f[i][j]=min(f[i-1][j]+1*j*c+p[i],f[i-1][j-1]+s[i]) \] #include<iostream> #include<cstdio> using…
题目 Source http://codeforces.com/problemset/problem/717/G Description You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the un…
Description Tom is a commander, his task is destroying his enemy’s transportation system. Let’s represent his enemy’s transportation system as a simple directed graph G with n nodes and m edges. Each node is a city and each directed edge is a directe…
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 n * n 的矩阵A,当且仅当 Aij = 1 时,pi 与 pj 可以交换数值.现在问如何交换数值,使得最后得到的排列字典序最小. 比赛的时候不会做,看了Tutorial 1 的解法,觉得别人做得太巧妙了,出题者也出得很好 ^_^ 可以看这个:http://codeforces.com/blog…
题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张,分别为:y1, y2, ...yk2:(n<=10&&k1+k2==n,所有牌的数字都不同): 依次比较x1, y1的大小,若x1>y1,依次将x1, y1加入x牌最底下:反之则将y1,x1依次加入y牌最底下:直至有方的牌输完为止:输出总共游戏的步数和赢方: 如果两方都不能赢,则…
B - Hongcow Solves A Puzzle 题目连接: http://codeforces.com/contest/745/problem/B Description Hongcow likes solving puzzles. One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be…
D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to…
题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that pla…
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/B Description Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500,…
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m g…
传送门 D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when you have to make a hard decision — to rest…
E. Correct Bracket Sequence Editor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbrev…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsmemory limit per test 512 megabytes 问题描述 A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is th…