http://codeforces.com/contest/722/problem/D 题目大意:给你一个没有重复元素的Y集合,再给你一个没有重复元素X集合,X集合有如下操作 ①挑选某个元素*2 ②某个元素*2+1 问:找到一个X集合,里面的元素与Y的元素可以相互转换,且X的max要尽量小. 思路:二分答案找就好了.从Y开始进入,不需要考虑奇偶数,反正每次都/2就行了. //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++…
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format…
B. Verse Pattern 题目连接: http://codeforces.com/contest/722/problem/B Description You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters. We define a syllable as a string that c…
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format…
题目链接:http://codeforces.com/contest/722/problem/D 1 #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> #include <algorithm> #include <string> #include <math.h>…
http://codeforces.com/contest/722/problem/C 题目大意:给你一个串,每次删除串中的一个pos,问剩下的串中,连续的最大和是多少. 思路一:正方向考虑问题,那么就线段树+分类讨论一下就好了,然后代码中flag表示能否转移 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++.h> using namespace std; #define LL long long #define A…
D. Generating Sets 题目连接: http://codeforces.com/contest/722/problem/D Description You are given a set Y of n distinct positive integers y1, y2, ..., yn. Set X of n distinct positive integers x1, x2, ..., xn is said to generate set Y if one can transfo…
C. Destroying Array 题目连接: http://codeforces.com/contest/722/problem/C Description You are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the array one by one. Thus, you are given the permuta…
A. Broken Clock 题目连接: http://codeforces.com/contest/722/problem/A Description You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it…
C. Destroying Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the ar…
D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a set Y of n distinct positive integers y1, y2, ..., yn. Set X of n distinct positive integers x1, x2, ...,…
原题中需要求解的是按照它给定的操作次序,即每次删掉一个数字求删掉后每个区间段的和的最大值是多少. 正面求解需要维护新形成的区间段,以及每段和,需要一些数据结构比如 map 和 set. map<int, LL>interval2Sum来维护区间段(u->v),mulitset<LL>sum 来维护最大值.那么每次删除操作后,都需要去interval2Sum中找到对应区间,然后erase掉, 重新生成left -> delId -> right两个区间段,最后在ma…
C. Destroying Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the ar…
C. Destroying Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the ar…
1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组,每行最多可交换1次,列最多可交换两列,问最终是否可以变换到每行都是1~m. 2.总结:暴力即可. #include<bits/stdc++.h> #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a,b) for (int i=a;i&l…
D. Dense Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a string s, consisting of lowercase English letters, and the integer m. One should choose some symbols fr…
传送门:D Dense Subsequence 题意:输入一个m,然后输入一个字符串,从字符串中取出一些字符组成一个串,要求满足:在任意长度为m的区间内都至少有一个字符被取到,找出所有可能性中字典序最小的情况,并按字典序输出 思路:字典序 例如 aaaaaaab < ab  也就是说,如果满足要求的取法中取到了b 那么所有的a都应该被取到,这样才可以保证字典序最小,那么也就是说在26个字母中找到一定要被取的最大字母,然后再确定最大的字母的个数,比它小的全部要取 AC代码: #include &quo…
链接 题意:输入n,m,表示一个n行m列的矩阵,每一行数字都是1-m,顺序可能是乱的,每一行可以交换任意2个数的位置,并且可以交换任意2列的所有数 问是否可以使每一行严格递增 思路:暴力枚举所有可能的列变换 然后在所有可能的情况下求是否存在一种情况可以使每一行最多进行一次交换最后得到严格递增的矩阵 AC代码: #include "iostream" #include "stdio.h" #include "string.h" using name…
我不告诉你这个链接是什么 分析:模拟可以过,但是好烦啊..不会写.还有一个扩展欧几里得的方法,见下: 假设光线没有反射,而是对应的感应器镜面对称了一下的话 左下角红色的地方是原始的的方格,剩下的三个格子是镜面对称的结果.原来的点是的话,剩下三个点从左上到右下分别是,,.真实情况是一个点不止只有这三个镜像点,一个点可以在平面内生成无数个点,可以用坐标表示为为任意非负整数. 假设光线没有经过反射,那么用函数可以表示为,这样要求包括镜像点在内的所有点,于是就有二元一次方程,可以改成四个二元一次方程式,…
http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射线分别第一次经过这些点的时间. 解法一: (模拟) 射线不管怎么反射,都是和水平方向成45°角的,也就是说每一段射线上的点,横坐标和纵坐标的和或者差相等. 把每一个点放入它所对应的对角线里,然后模拟射线的路径就好. 代码: #include <iostream> #include <cstd…
题目链接:http://codeforces.com/contest/724/problem/E 题目大意: 有n个城市,每个城市有pi件商品,最多能出售si件商品,对于任意一队城市i,j,其中i<j,可以从城市i往j运输最多c件商品. 求最多一共能卖出多少件商品.  n<=10000 解法一(官方解法): 构造网络流,因为边太多,不可能直接跑最大流. 根据图的特殊性,考虑用dp求解最小割. 状态:dp[i,j]表示前i个中有j个和源点相通的最小割. 转移:如果第i个点不和源点相连,那么pi这…
传送门 Description You are given names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next mon…
传送门 Description You are given a table consisting of n rows and m columns. Numbers in each row form a permutation of integers from 1 to m. You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more…
Description You are given a table consisting of n rows and m columns. Numbers in each row form a permutation of integers from 1 to m. You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more tha…
Description You are given names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month w…
题目大意:给你一个n*m的矩阵,再给你一个小球,从(0,0)以sqrt(2)/s的速度向右上角出发,遇到边框会反弹,遇到角落就直接停止,给你一些点,问小球第一次经过这些点所需要的时间. 思路:模拟一下即可...注意爆int //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits/stdc++.h> using namespace std; #define LL long long #define ALL(a) a.begin(), a.…
http://codeforces.com/contest/724/problem/D 题目大意:给你一个串,从串中挑选字符,挑选是有条件的,按照这个条件所挑选出来的字符集合sort一定是最后选择当中最小的. 从pos=0开始挑选,每次挑选pos~pos+m-1这些位置中的字符,然后下一次再从之前挑选字符的位置开始的后面的m个中进行挑选. 思路:先贪心,按照字典序,每次找到该范围区间内最小的字符,因为该字符一定是串中的一部分,所以必然会被挑选的,于是我们先把这个pos的字符放入集合,并且对挑选过…
C 模拟 题意:给的是一个矩形,然后√2 的速度走,如果走到边上就正常反射,走到角上,暂停反射,我们知道要不循环要不暂停,记录走到的点最短时间 /************************************************************************* > File Name: c.cpp > Author: opas_chenxin > Mail: 1017370773@qq.com > Created Time: 2016年10月08日…
E. Goods transportation 题目连接: http://codeforces.com/contest/724/problem/E Description There are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road. The i-th city had produced pi units of goods. No mo…
D. Dense Subsequence 题目连接: http://codeforces.com/contest/724/problem/D Description You are given a string s, consisting of lowercase English letters, and the integer m. One should choose some symbols from the given string so that any contiguous subse…