codeforces 129B students and shoes】的更多相关文章

https://vjudge.net/problem/CodeForces-129B 题意: 有n个学生,他们之间被鞋带缠住了.现在,老师首先把所有只与一个学生直接相连的学生找出来,让他们聚集到一起,然后把他们踢出去,直到无人可踢为止.问可以踢多少次. 思路: 用拓扑排序的思路,从所有点的度数下手.将所有度数为1的点入队,之后把他们连接的点的度数全部减一,自己也减1,之后再把所有的度数为1的点入队,循环,直到队列为空. 代码: #include <stdio.h> #include <s…
这套题目做完后,一定要反复的看! 代码经常出现的几个问题: 本机测试超时: 1.init函数忘记写. 2.addedge函数写成add函数. 3.边连错了. 代码TLE: 1.前向星边数组开小. 2.用了memset,慎用. 1. CodeForces 498C  Array and Operations 我发现cf上的网络流的建图思路都非常好,准备着重练习一下. 此题枚举每一个质因子,对每个质因子建图,确实是很好的思路. #include <bits/stdc++.h> using name…
题目链接:http://codeforces.com/problemset/problem/357/A 题目意思:将一堆人分成两组:beginners 和 intermediate coders .每一个人都有一个point,给出每一个point里的总人数(Ci 个人有分数 i )和 x,y,需要找出划分为两组后,每一个组的人数(假设为a,b)符合 x <=  a  <= y 并且 x<= b <= y 的条件,输出这a个人是小于哪个point的,这个point还应该满足另一组的b…
题目传送门 /* 图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:) */ #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int cnt[MAXN]; int a[MAXN]; bool g[MAXN][MAX…
PROBLEM A. Shockers 题 http://codeforces.com/contest/906/problem/A 906A 907C 解 水题,按照题意模拟一下就行了 如果是 ‘ ! ’,那么该字符串中所有没出现的字符标记为否,如果是 ' . '那么该字符串中出现的字符全部标记为否 #include <iostream> #include <cstring> #include <cmath> #include <cstdio> using…
Codeforces 332 C 我爱对拍,对拍使我快乐... 题意:有\(n\)个议题,学生们会让议会同意\(p\)个,其中主席会执行\(k\)个, 每一个议题执行后主席会掉\(a_i\)的头发,不执行后议会会增加\(b_i\)的不开心值, 然后主席想让议会的不开心值最小,如果有多重方案就选自己头发掉的最少的: 而学生们想让主席的头发掉的最多,如果有多种方案让议会的不开心值最大. 问让议会同意哪\(p\)个会达到最好的效果. 思路1: 这是我的不对的思路. (虽然没提交 我们首先将所有的数按照…
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two stu…
You are the gym teacher in the school. There are nn students in the row. And there are two rivalling students among them. The first one is in position aa, the second in position bb. Positions are numbered from 11 to nn from left to right. Since they…
Circle of Students time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a circle in some order. The index of the ii-th student is pipi. It is guaranteed that a…