Codeforces 555D Case of a Top Secret】的更多相关文章

Case of a Top Secret 感觉除了两个点在那循环的部分, 其他时候绳子的长度每次变为一半一下, 就变成了Log(l)步.. 然后就暴力找就好啦, 循环的部分取个模. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, in…
D. Top Secret Task time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. Acc…
D. Top Secret Task time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. Acc…
题目传送门 /* 构造+暴力:按照题目意思,只要10次加1就变回原来的数字,暴力枚举所有数字,string大法好! */ /************************************************ Author :Running_Time Created Time :2015-8-3 8:43:02 File Name :A.cpp *************************************************/ #include <cstdio>…
[Codeforces 555E]Case of Computer Network(Tarjan求边-双连通分量+树上差分) 题面 给出一个无向图,以及q条有向路径.问是否存在一种给边定向的方案,使得这q条路径都能被满足.(如果有一条边是从a->b),而经过它的路径是从b->a,那么久不满足).只需要判断,不用输出方案. 分析 对于一个有向环,显然它可以允许各个方向的路径通过.所以我们只要把无向图里的边-双联通分量建成环,然后就不用考虑了.影响答案的只有桥. 所以我们求出所有桥,然后缩点,把图…
题目连接: http://codeforces.com/problemset/problem/555/B 题目大意: 有n个岛屿(岛屿在一列上,可以看做是线性的,用来描述岛屿位置的是起点与终点),m个桥,给出每个岛屿的位置和桥的长度,问是否可以把n个岛屿连起来? 解题思路: 排序+贪心,对于n个岛屿,相邻的两个之间起点和端点可以转化为n-1个连接桥的长度区间,把区间升序排列. 对于m个桥升序排列,对于每一个桥枚举每个可以合法覆盖的区间,选取最优的,选取的时候满足L<bridge_length<…
Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water. The only dry land there is an archipelago of n narrow islands located in a row. For more comfort l…
D. Secret Passwords One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piece of paper with a list of n passwo…
题目链接:http://codeforces.com/contest/556/problem/C 题目意思:有 n 个数(1,2,...,n)组成 k 条链.第 i 条链由 mi 个数组成.每一秒只可以做其中一件事:(1)将链i连到只有一个数的链 j 中(链 i 的最大值比只由单个数组成的链 j 还要小):(2)将链上最大的数从链中分离. 然后我们最终是要得到一条1,2,3,...n.问最少需要连接的秒数. 不难推出,我们需要找到编号为 1 的链包含多少个数,然后对于此链的其他数,我们需要先分离…
题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每按一次 button,每个齿轮都会有且仅有一个活动的tooth,对于偶数编号的齿轮,它下一个活动tooth是紧挨着当前tooth的逆时针方向的那个:而奇数编号的齿轮,下一个活动tooth是顺时针的那个.给出每个齿轮的活动tooth,问通过按下有限次的button,问能不能得到一个0,1,...,n-…
/////////////////////////////////////////////////////////////////////////////////////////////////////// 作者:stxy-ferryman声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/链接被删请百度:stxy-ferryman…
/////////////////////////////////////////////////////////////////////////////////////////////////////// 作者:stxy-ferryman声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/链接被删请百度:stxy-ferryman…
556D - Case of Fugitive 思路:将桥长度放进二叉搜索树中(multiset),相邻两岛距离按上限排序,然后二分查找桥长度匹配并删除. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; struct node { ll x; ll y; int id; bool operator <(const node &a)const { return y<a.y; } }…
题意:有n-1个缝隙,在上面搭桥,每个缝隙有个ll,rr值,ll<=长度<=rr的才能搭上去.求一种搭桥组合. 经典问题,应列入acm必背300题中.属于那种不可能自己想得出来的题.将二元组[ll,rr]排序(ll相同时再rr),长度x排序(升序).一个全局优先队列pq(rr小的顶部).for循环,对每个x,将ll比它小的放入优先队列pq,如果pq仍为空,说明这块桥用不上,不为空,看top的rr是否大于x,如果大于,这块桥就能用上,并且给当前的top一定是可行的. 乱码: #pragma co…
B. Secret Combination time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each…
B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of…
D. Felicity's Big Secret Revealed   The gym leaders were fascinated by the evolutions which took place at Felicity camp. So, they were curious to know about the secret behind evolving Pokemon. The organizers of the camp gave the gym leaders a PokeBlo…
[题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所切成的各个部分的二进制,转成十进制之后;假设里面最大的数为m; 问1..m这些数字都出现的切法有多少种; [题解] 可以算一下对于1个75位的数字来说; 最多只可能连续出现 从 1..20 你可以算一下1..20这20个数字的二进制形式恰好占74个; 不能再多一个数字了,因为21的二进制形式的长度肯…
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls…
链接: https://codeforces.com/contest/1263/problem/D 题意: One unknown hacker wants to get the admin's password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator's office and stole a piec…
Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once he thought about a string…
/////////////////////////////////////////////////////////////////////////////////////////////////////// 作者:stxy-ferryman声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/链接被删请百度:stxy-ferryman…
原文链接https://www.cnblogs.com/zhouzhendong/p/9272797.html 题目传送门 - CF555C 题意 给定一个 $n\times n(n\leq 10^9)$ 的方格阵列. 接下来,我们将从该方阵的副对角线开始进行一些操作. 操作 $"y\ x\ U"或"y\ x\ L"$ 分别表示一个人从第 $x$ 行第 $y$ 列开始走,$U$ 表示向上,$L$ 表示向左.保证初始位置在副对角线上面. 已经有人走过的不能再走,每次操…
题意:1-n的数字,大的在小的后面,以这种规则已经形成的几个串,现在要转为一个串,可用的操作是在末尾拆或添加,问要操作几次? 模拟了很久还是失败,看题解才知道是数学.看来这种只要结果的题,模拟很不合算. 设结果为res,res先为0,看1在的那个串,在后一位不等于前一位加1的地方断开.res+=剩下数量*2,因为剩下的都要拆掉,然后在某个时刻再装上去.对于其他的串,res+=(串长度-1)*2+1,因为最前面的数字不用拆,只要装. 乱码: #pragma comment(linker,"/STA…
题意:直角边为n的网格巧克力,一格为一块,选择斜边上一点,从左或上吃,直到吃到空气,称为一次操作.给出几个操作,问各能吃几块.如果x是当前要吃的横坐标,在已经吃过的中找x1>=x的第一个x1,即lower_bound().如果x1==x,结果就是0:否则假设x是往上吃,x1也是往上吃,因为x和x1间没有往左吃的,因此x1结束的地方也是x结束的地方.如果x往上吃,x1往左吃,因为x1横坐标最小,纵坐标最大,对x能吃到的位置仅受到它的影响. 乱码: //#pragma comment(linker,…
pro:N个数排成一圈.一次操作为,每个位置的数+=L*左+R*右,保留x为整数. 问S轮操作后每个位置的值. N<=1000,S<=2^30,x<=9 . sol:不难想到矩阵乘法,但是N为1000,显然普通的N^3矩阵乘法的复杂度不能AC. 不难发现这是经典的循环矩阵(第二行为第一行右移一格....依次),所以我们只需要求第一行的矩阵,其他每一行都可以在第一行找到对应的值. (我的代码1500ms,VJ有神仙150ms,暂时不知道怎么搞的. #include<bits/stdc…
1:Union语句: 把两个结果合为一体(但是完全重复的数据会去掉) Eg1: select name, age, ‘学生无工资’ from student        union          select name, age, sal from teacher Eg2: select top 2  CONVERT(varchar(20),itemId) itemid, fee, addDate  from Orders union select '合计',SUM(fee),GETDAT…
SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Introduction We've studied various approaches to file system design. Now we'll look at some real file systems to explore the approaches that were taken i…
第一次就去拉了点思维很神奇的CF题目 2018省赛赛第一次训练 # Origin Title     A CodeForces 607A Chain Reaction     B CodeForces 385C Bear and Prime Numbers     C CodeForces 670D2 Magic Powder - 2     D CodeForces 360B Levko and Array     E CodeForces 68B Energy exchange     F…
Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 960    Accepted Submission(s): 344 Problem Description A crowd of little animals is visiting a mysterious laboratory…