题目链接: 题目 E. Paths and Trees time limit per test 3 seconds memory limit per test 256 megabytes inputstandard input outputstandard output 问题描述 Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important…
E. Paths and Trees time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving…
E. Paths and Trees time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving…
题目传送门 /* 比C还水... */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; ll a[MAXN]; int main(void) //Codeforc…
题目传送门 /* 题意:每棵树给出坐标和高度,可以往左右倒,也可以不倒 问最多能砍到多少棵树 DP:dp[i][0/1/2] 表示到了第i棵树时,它倒左或右或不动能倒多少棵树 分情况讨论,若符合就取最大值更新,线性dp,自己做出来了:) */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> using na…
题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> using namespace std; ; const int INF = 0x3f3f3f3f; int p[MAXN…
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during the collision. 是指i,j两辆车,而不是全部 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream>…
A.Toy Cars 题意:给出n辆玩具车两两碰撞的结果,找出没有翻车过的玩具车. 思路:简单题.遍历即可. #include<iostream> #include<cstdio> using namespace std; ][]; ]; int main() { int n; scanf("%d", &n); ; i <= n; i++) { ; j <= n; j++) scanf("%d", *(mp + i) +…
题意 求一个生成树,使得任意点到源点的最短路等于原图中的最短路.再让这个生成树边权和最小. http://codeforces.com/contest/545/problem/E 思路 先Dijkstra一下,再对每个点连的边判断是不是最短路上的边,如果是那再贪心取最小的边即可. 代码 #include<bits/stdc++.h> using namespace std; #define ll long long const ll inf=1e18; const int N=6e5+5; s…
C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/D Description Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For ea…
C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/C Description Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately s…
B. Equidistant String Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/B Description Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings conta…
 A. Toy Cars Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/A Description Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process…
简单到让人不敢相信是D题,但是还是疏忽了一点. 题意与分析 (Codeforces 545D) 题意:n人排队,当一个人排队的时间超过他需要服务的时间就会厌烦,现在要求一个最优排列使得厌烦的人最少. 思路:让服务时间长的人到后面去是一个显然的思路.那么直接排序即可.然后逐个检查,当一个人按照时间顺序排序仍然厌烦的时候,将他直接放到最后去(也就是不考虑:反正你怎么样都会厌烦,不如不为你服务2333),这样能够最大化满意的人数. 代码 #include <bits/stdc++.h> #defin…
这题惨遭被卡..卡了一个小时,太真实了. 题意与分析 (Codeforces 545C) 题意:给定\(n\)棵树,在\(x\)位置,高为\(h\),然后可以左倒右倒,然后倒下去会占据\([x-h,x]\)或者\([x,x+h]\)区间,如果不砍伐,占据\([x,x]\)区域. 问你最多砍多少棵树,砍树的条件是倒下去后占有的区间不能被其他树占据. 分析:在这条题目的条件下,这是一个傻逼贪心题.(然后我读错两次题目,怎么也想不出来贪心策略....) 很简单的策略:能往左倒往左倒,能往右倒往右倒.因…
题目链接:http://codeforces.com/problemset/problem/545/D 题解: 问经过调整,最多能使多少个人满意. 首先是排序,然后策略是:如果这个人对等待时间满意,则将其加入队伍中,更新当前的等候时间:如果不满意,既然等待时间最小了都不满意,那把他扔到最后,即跳过他,接着考虑下一个. 代码如下: #include<cstdio>//F - F CodeForces - 545D #include<cstring> #include<cstdl…
D. Queue time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For e…
C. Woodcutters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immedi…
B. Equidistant String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her string…
A. Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The pr…
五道水题,但要手快才好...我手慢了,E题目都没看完TAT.... 想了一发,很水,就是一遍Dijk即可,使用优先队列,同时记录由哪条边转移而来 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #define LL long long using namesp…
题目: 题意:给你n个数值,要求排列这个序列使得第k个数值的前K-1个数的和>=第k个数值的个数尽可能多: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <stack> #incl…
B. World Tour 题目连接: http://www.codeforces.com/contest/666/problem/B Description A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he…
题目链接: 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[…
D. Wilbur and Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/D Description Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. The…
题目链接: http://codeforces.com/problemset/problem/301/B B. Yaroslav and Time time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As s…
传送门 E. Breaking Good time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is real…
D. World Tour   A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will en…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有当a[i]和a[i-1]都大于1的时候才会有不同的情况. a[i] >= a[i-1] 且a[i-1]>=2 则第i-1层的a[i-1]个节点,每个节点下面接一个第i层的节点. 然后剩下的a[i]-a[i-1]个都放在第i-1层最左边那个节点下面. 另外一颗树,所有节点都放在第i-1层最左边那颗下面. 如果a[i]<a[i-1]且a[i-1]>2且a[i]>=2 同样的,在第i-1层的前a[i]个节点…
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake…