题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 1:07:18 * File Name :C.cpp *******************************************…
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况讨论一下 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 0:23:37 * File Name :B.cpp *****************…
D. One-Dimensional Battle ShipsTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/D Description Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n s…
D. One-Dimensional Battle ShipsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/D Description Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n …
A题: 题目地址:Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set> #include <queue> #include…
567A Lineland Mail题意:一些城市在一个x轴上,他们之间非常喜欢写信交流.送信的费用就是两个城市之间的距离,问每个城市写一封信给其它城市所花费的最小费用和最大的费用. 没什么好说的.直接做.特判最左边的和最右边的.其它的最小值在相邻的城市取,最大的在两边的城市与本城市取最大值. 代码: #include <set> #include <map> #include <queue> #include <stack> #include <de…
C. Geometric Progression Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/C Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length…
B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of…
A. Lineland MailTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/A Description All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the…
题目链接: http://codeforces.com/contest/567/problem/E 题意: 给你一个带重边的图,求三类边: 在最短路构成的DAG图中,哪些边是必须经过的: 其他的(包括不在DAG上的边)不是必须经过的边把权值改小多少才能通过, 或者根本不可能通过的. 题解: 从起点s跑一遍最短路得到d[maxn],从终点t跑一遍最短路得到d2[maxn],对于边(u,v,w),如果d[u]+d2[v]+w==d[t]那么这条边在最短路上,对于不在最短路上的边,如果d[u]+d2[…
E. President and RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/E Description Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The c…
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any o…
A. Lineland MailTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/A Description All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on th…
上次比完赛就准备写了, 结果懒癌发作了, 拖到了现在. Problem_A: 题意: 在一条x轴上有n座城市, 每个城市之间的距离就是它们对应坐标的距离, 现在求出每个城市到其他城市的最近距离和最远距离. 思路: 最远的必然在最左右端点产生, 因为没有比它们还远的城市了. 最近的必然在相邻左右端点产生,因为有没比它们还近的城市了. 比较下即可, 注意处理最左右端点时的情况. 代码: #include <cmath> #include <cstdio> #include <cs…
A. Lineland Mail time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordi…
题意 : 给你一个序列,和 K ,选3 个数,下标严格递增, 满足 为递增的等比数列, 等比为K 思路 : 先统计所有数的个数,枚举等比数列的中间数 A, 计算 A 之后的 A*K的个数, A之前的 A /K 的个数,相乘 (打比赛脑残,还想到啪啪什么的,爱残了) #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #incl…
题目的意思是: 如今有一个长度为n,宽为1的方格,在上面能够放大小为1*a船,然后输入为n,k,a.分别为平地的大小,船的数量,船的长度. 一个叫alice的人已经在地图上摆好了船的位置. 然后bob总共能够有m次攻击的机会,然后他每次攻击的点为xi.可是alice并不会告诉它有没有打中(也就是说每次都觉得他是miss的).问你,bob能够在第几次攻击的时候猜測出alice在撒谎,假设猜測不出来则输出-1. 这里每两条相邻的船不能相互接壤. 思路: 用set来维护每一段的区间. 首先.我们最多能…
图给得很良心,一个s到t的有向图,权值至少为1,求出最短路,如果是一定经过的边,输出"YES",如果可以通过修改权值,保证一定经过这条边,输出"CAN",并且输出最小修改值,否则输出"NO".保证有s到t的路径,可能有重边. 建正反两个图,分别求出s和t的最短路径,用来判断一条边是不是在最短路径上,然后把最短路径取出来建一个图求割边. 不要用spfa,最坏O(VE),(出卡spfa数据的方法:Hard Test),会TLE 109(数据好啊),自…
C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions o…
题意: 如今有n个数,然后给出一个数k(代表的是等比数列中的那个公比),然后第二行给出n个数,代表的是这个序列. 最后的问题是叫你找出在这个序列中满足公比为k的三个数有几种.并输出方案总数. 思路: 这道题非常巧妙啊,用到了map. 首先我们先记录下每种数出现过了几次.这里由于数太大了.直接用数组存会爆掉,所以改用map. 我们须要两个map,分别记为mp1.mp2. 然后在for的过程中.我们是以当前的那个数为第二项,然后去寻找它的mp1[a[i]*k](也就是第三项).寻找它的mp2[a[i…
B. Berland National Library time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take…
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table). At the beginning of the game Alice puts k ships on the field without telling their positio…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 这回做的好差啊,a想不到被hack的数据,b又没有想到正确的思维 = = [题目链接]A. Vitya in the Countryside [题目类型]模拟 &题意: 一个月30天,月亮的大小分别是上面所说的规律,求输入的下一天是变大还是变小 &题解: 我想的是首先n==1的时候,我想的是一定-1,但这样是错的,因为当那一个数是15或0时,那么答案就不是-1了. 最后,只…
Problem   Codeforces Round #539 (Div. 2) - D. Sasha and One More Name Time Limit: 1000 mSec Problem Description Input The first line contains one string s (1≤|s|≤5000) — the initial name, which consists only of lowercase Latin letters. It is guarante…
Problem   Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem Description Input The first line contains one integer n (2≤n≤3⋅10^5) — the size of the array. The second line contains n integers a1,a2,…,an (0≤ai<2^…
Codeforces Round #485 (Div. 2) https://codeforces.com/contest/987 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<ll>::iterator #define sqr(x) ((x)*(x)) #define pb…