Codefroces 731C. Socks】的更多相关文章

C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prep…
C. Socks time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have…
http://codeforces.com/problemset/problem/731/C 并查集+贪心 将要求颜色相同的袜子序号放入一个集合中 贪心:然后统计这个集合中出现次数最多但颜色 可以得到这个集合要repain的次数 代码有难度 统计集合数 int tot;//总的集合数 for (int i = 1; i <= n; i++) if(par[i] == i) { rec[tot++] = i;//记录根节点 } //统计每个集合红颜色的个数 map<int, int> cl…
题目:http://codeforces.com/contest/731/problem/C 思路:并查集处理出哪几堆袜子是同一颜色的,对于每堆袜子求出出现最多颜色的次数,用这堆袜子的数目减去该值即为这堆袜子需要修改的颜色数,用同样的方法处理每堆求和即可. #include<bits/stdc++.h> using namespace std; ],c[]; map<int,map<int,int> > mp; int getf(int x){ if(f[x] == x…
题意:有n只袜子,k种颜色,在m天中,问最少修改几只袜子的颜色,可以使每天穿的袜子左右两只都同颜色. 析:很明显,每个连通块都必须是同一种颜色,然后再统计最多颜色的就好了,即可以用并查集也可以用DFS. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include…
Description Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. Ten minutes before her leave she real…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of…
http://codeforces.com/problemset/problem/731/C 题意:有n只袜子,m天,k个颜色,每个袜子有一个颜色,再给出m天,每天有两只袜子,每只袜子可能不同颜色,问要让每天的袜子是相同颜色的,要重新染色的袜子数最少是多少. 思路:并查集合并,将同一天的袜子合并起来,然后就形成了cnt个集合,每个集合都是独立的,因此排序,找出每个集合里面袜子颜色相同的最多的是哪个颜色,然后把其他不属于这个颜色的都染成这个颜色,那么这样重新染色的袜子数是最少的.然后每个集合的答案…
Step 1. Make sure the SOCKS tunnel on your work computer allows LAN connections so your iPhone/iPod Touch can connect to it. ssh -N -g -D 1080 user@domain.com Step 2. Create a text file and insert the following code: function FindProxyForURL(url, hos…
C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prep…