CodeForces 412D Giving Awards】的更多相关文章

根据给出的条件建边,然后进行dfs 对于某个点x,当x的后继都遍历完毕后,再输出x节点. 这样能保证所有约束条件. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; +; int n,m; vector<int>g[maxn]; int flag[maxn]; void…
就是依照一定顺序输出排序. 比方a欠b的钱就不能先输出a然后输出b. 本题的技巧就是.要求的是不能先输出a然后输出b,可是能够先输出b然后输出a. 故此能够依照a欠b的钱的关系.建立图,然后DFS深度优先搜索,然后逆向记录点,输出这些逆向点,也就是a欠b的钱.就先输出b然后输出a,那么这个顺序就满足要求了. 非常狡猾的题意.要细心.不然就搞半天都白搞了. 题目连接:http://codeforces.com/problemset/problem/412/D #include <stdio.h>…
题目的意思是 老板给n个人发工资,x欠y的工资,the joy of person x from his brand new money reward will be much less, 老板想避免x后面是y领工资,故利用bfs,找到无后继的点 在提交代码的时候输出时格式好像没有oj的平台那么严,可以包含多余的空格(注释的代码也可以提交 #include <iostream> #include <vector> #include <algorithm> #includ…
题目链接 A. Poster time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the ne…
原文链接https://www.cnblogs.com/zhouzhendong/p/9255885.html 题目传送门 - CF873E 题意 现在要给 $n(n\leq 3000)$ 个学生颁奖. 记 $a_i$ 为第 $i$ 个学生在本次比赛中做出的题目数量. 记 $b_i$ 为第 $i$ 个学生所获的奖项,其中 $1,2,3$ 分别表示他获得一.二.三等奖, $-1$ 表示不获奖,当然,一等奖最好,没奖最差. 记 $cnt_i$ 为满足 $b_k=i$ 的 $k$ 的个数. 一个合法的…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits:  200000 KB 64-bit interger IO format:  %lld   Java class name:  Main Description A Hill Number is a number whose digits possibly rise and then possibl…
C. Sonya and Queries time limit per test:1 second memory limit per test: 256 megabytes input:standard input output: standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty mul…
题目链接:http://codeforces.com/contest/499 A. Watching a movie You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute of the movie. By pressing this button, you watch the current minute of…
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), giving the distances at which t…