cf.VK CUP 2015.C.Name Quest(贪心)】的更多相关文章

Name Quest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys loo…
Mean Requests time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output In this problem you will have to deal with a real algorithm that is used in the VK social network. As in any other company tha…
VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/529/problem/E Description ATMs of a well-known bank of a sm…
http://codeforces.com/contest/967/problem/E 题目大意: 给你一个数组a,a的长度为n 定义:b(i) = a(1)^a(2)^......^a(i), 问,是否存在一种情况,使得a(i)重新排列以后以后,满足b(i)是严格单调递增的. 思路: 对于二进制位操作来说,如果异或后值增加,即 p^q > p,必然满足两种情况(假定一个为p,一个为q) ①q的最高位>p的最高位 ②q的最高位(假定第k为最高) < p的最高位,但是p的第k位为0 这样,…
http://codeforces.com/contest/967/problem/D 题目大意: 有n个服务器,标号为1~n,每个服务器有C[i]个资源.现在,有两个任务需要同时进行,令他为x1,x2. 运行任务的条件: ①每个服务器只能同时运行一个任务 ②任务可以同时分配到多个服务器中执行.假设任务x1分配到a个服务器中,则每个服务器都需要使用x1/a的资源(该资源可以为小数) 问能否满足以上条件,使得x1,x2同时在服务器中运行? 思路: 将所有服务器按照资源增序排列,定义dp(i)表示从…
是一道很有趣的题目 给出地图和起始点 与要求的步数k 要求走k步 正好回到起始点 输出字典序最小的移动路径 DLRU这样 可以想到DU LR都是相同数量的 于是k必须是一个偶数 然后走了弯路QAQ 从这个地方入手 可以想到贪心按顺序DLRU去四个方向挨个跑 跑k/2次 然后原路返回 然而因为走了k/2步之后 可能接着DLRU走回去 所以原路返回可能不是最优的 但是k是1e6 肯定不能dfs 后来发现可以bfs处理一下起始点到每个点的最短距离 代表从这个点走到起始点最少多少步 然后每一步都去贪心的…
题目链接:http://codeforces.com/contest/522/problem/D 题目大意:  给你一个长度为n的序列,然后有m次查询,每次查询输入一个区间[li,lj],对于每一个查询,输出在这个区间内的两个相等的数的最短距离,如果没有相等的则输出-1. 线段树+扫描线,线段树维护的值是区间的最小值,从后往前扫,然后每次要做的事有两个: 1.判断当前这个位置 i 的数刚刚是不是出现过,假设刚刚出现的位置是 l ,如果出现过,则在线段树中把l这个位置的值更新为 l - i,同时更…
E. Correcting Mistakes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/533/E Description Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guarant…
D. Restructuring Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/566/problem/D Description Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, disca…
题意: n * m的棋盘, k个位置有"rook"(车),q次询问,问是否询问的方块内是否每一行都有一个车或者每一列都有一个车? 满足一个即可 先考虑第一种情况, 第二种类似,swap一下就可以了. #include <bits/stdc++.h> using namespace std; ; inline int GetIdx(int l, int r){ return l + r | l != r; } ]; void update(int l, int r, int…