A. Oleg and shares time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Oleg the bank client checks share prices every day. There are n share prices he is interested in. Today he observed that e…
http://codeforces.com/contest/793/problem/D 题意:给出一些点和他们之间的距离,是有向的,这些点从1~n顺序排列,现在选出k个点组成一条路径,使他们之间的距离最短,要求是在路径中,一个被访问过的点不会经过两次或以上. 比如,你访问了1~6这条边,那么你已经访问了1和6这两个点,接下来你就不可以访问5~7这条边了,因为他们之间有6这个点. 思路:区间dp题. 区间dp的话,递推和记忆化搜索都是可以的. d[i][l][r][dir]表示当前访问第i次时,在…
http://codeforces.com/contest/793/problem/B 题意:一个地图,有起点和终点还有障碍点,求从起点出发到达终点,经过的路径上转弯次数是否能不超过2. 思路: 直接dfs,但是要优化一下,用vis[x][y][dir]来记录在(x,y)并且方向为dir时的最少转弯数,这样在dfs的时候可以剪掉一些不符合的情况. #include<iostream> #include<algorithm> #include<cstring> #incl…
传送门 题意 给出一个矩形的左下角和右上角的坐标,给出n个点的初始坐标和运动速度和方向,询问是否存在一个时间使得所有点都在矩形内,有则输出最短时间,否则输出-1 分析 对于每个点如果运动过程中都不在矩形内,输出-1 每个点的横纵运动分开考虑,判断处理得到点到达矩形边界的时间段,取交集,具体见代码 trick 1.all the mice that are strictly inside the mousetrap,即在矩形边界点不算入矩形 2.卡精度 代码 #include <bits/stdc…
慢慢来. 题目册 题目 A B C D tag math strings greedy dp 状态 √ √ √ √ //∅,√,× 想法 A. CME res tp A 题意:有\(n\)根火柴,额外填上\(k(k≥0)\)根火柴棍,使得\(n+k\)能分成三份\(a,b,c\),每份至少有一根火柴,满足\(a+b = c\),问\(k\)最小是多少 满足方程 \(a+b+c = n+k\) \(a + b = c\) 得\(2*c = n+k\) 若\(n\)是偶数,那么\(k\)为零,反之\…
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 题目连接: 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…
昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int x1,x2,yy1,y2,x,y; int main(){ scanf("%d%d%d%d%d%d&qu…
这次的前三题挺简单的,可是我做的不快也不对. A. Bank Robbery time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open…
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include <bits/stdc++.h> using namespace std; int a[210]; int n; int main() { scanf("%d", &n); for(int i=1; i<=2*n; i++) scanf("%d", &…