G. The Declaration of Independence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In 1776, a Committee of Five was chosen to draft the Declaration of Independence of the USA, among them Jo…
[Link]:http://codeforces.com/contest/831/problem/D [Description] 有n个人,它们都要去一个终点,终点位于p; 但是,在去终点之前,他们都要先拿到一把钥匙; 钥匙散落在k个位置(k>=n) 然后告诉你n个人的起始位置; 然后每个人,每秒钟移动一个单位长度; 问你最少需要多长时间,可以使得,每个人都拿到钥匙,且都走到终点; [Solution] 把初始位置a数组和钥匙位置b数组,都分别升序排; 假设有一个长度为n的窗口; 用这个窗口,一…
题目 Source http://codeforces.com/contest/663/problem/E Description You are given a table consisting of n rows and m columns. Each cell of the table contains either 0 or 1. In one move, you are allowed to pick any row or any column and invert all value…
source : Pertozavodsk Winter Training Camp 2016 Day 1: SPb SU and SPb AU Contest, Friday, January 29, 2016 url:https://codeforces.com/gym/100956/attachments ----------------------------------------------------- 题意: 有一个1~n的全排列p1~pn,问有多少个长度为n的数组,满足 1.数…
Problem description Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phra…
C.Sleep Buddies It is nighttime in the Earth Colony on Mars and everyone is getting ready to sleep. It is common to sleep in pairs, so that if anything were to happen during the night people could aid each other. To decide who is a suitable candidate…
模拟Canada Cup 2016,ABC三题,Rank1376 第三题卡住了 Codeforces 725 C 求出两个相同字符的位置,记为x和y. 然后考虑把相同的那个字符放在第一行的什么地方, 然后把x+1..y-1的部分一折两半,放在第一行的末尾再折回第二行. 再把1..x-1和y+1..n放下来就可以了. Codeforces 725 D 题意:有n个队伍,你是第一个队伍的一员,然后你可以把你们队伍拿到的一些气球给其他的队伍,如果一个队伍的气球数量大于他们的质量,那么他们就会被删除.…
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问,最少删除多少个字符,使得串中符合ugly串? 思路:定义dp(i, j),其中i=5,j=5,因为只需要删除2016当中其中一个即可,所以一共所需要删除的字符和需要的字符为20176,因此i和j只要5就够了. 然后转移就是dp(i,i) = 0, 如果说区间大小为1的话,那么如果是2017中的一个…
链接:http://codeforces.com/gym/101116 学弟写的,以后再补 #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <map> #include <vector> using namespace std; map<string,int>v,ans; vector<in…
链接:http://codeforces.com/gym/101116 题意:给出n个点,要求一个矩形框将(n/2)+1个点框住,要面积最小 解法:先根据x轴选出i->j之间的点,中间的点(包括两边)按照y排序,固定一边X=(xj-xi),Y就枚举点两端的Y坐标,细节是注意要取(n/2)+1个点 事实上这样取里面一定符合要求 #include <iostream> #include <cstdio> #include <algorithm> #include &l…