#include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin >> n >> m; vector< ,false); ; i < m ; i ++ ){ int a,b; cin >> a>>b; flag[a]=flag[b]=true; } ; ; i <= n ; i ++ ){ if(!flag[i]){…
题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目.  要求两个城市之间不超过两条道路,那么所有的城市应该是连在一个点上的,至于这个点就很好找了,只要找到一个没有和其他点有道路限制的即可. //cf 192 B #include <stdio.h> #include <string.h> char map[1005][1005]; i…
D. Tree Construction 题目连接: http://www.codeforces.com/contest/675/problem/D Description During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so…
Tree Construction Problem's Link ---------------------------------------------------------------------------- Mean: 给定n个数,按照构造Binary Search Tree的方式来构造BST树,按顺序输出每一个非root结点的父节点的值. analyse: 构造BST树最坏情况下时间复杂度为O(n),肯定会超时. 注意到只需要输出结点的父节点的值,不需要真的构造BST树. 插到第i…
题目链接: http://codeforces.com/contest/675/problem/D 题意: 给你一系列点,叫你构造二叉搜索树,并且按输入顺序输出除根节点以外的所有节点的父亲. 题解: n有10^5,如果直接去建树,最会情况会O(n^2)t掉. 因此我们需要利用一些二叉搜索树的性质: 对于当前输入节点v,找出已经输入的最大的l和最小的r使得l<v<r. 由于输入v之前l和r中间是没有数的,所以l和r必定为祖先和后代的关系,如果不是的话,就会导致l和r中间还有数(l和r的公共祖先)…
题目链接:http://codeforces.com/problemset/problem/675/D 给你一个如题的二叉树,让你求出每个节点的父节点是多少. 用set来存储每个数,遍历到a[i]的时候查找比a[i]大的数的位置,然后插入,而父亲就是刚好比a[i]小的数或刚好大的数. 然后讨论是哪一个数. 比如给你3 1 2 ,如图 1的父亲是3 ,2的父亲是1. 那我其实只要找左边或右边出现最晚的数就行了,用pair的first表示a[i],second表示出现的顺序i. #include <…
C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/C Description I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pa…
B. Biridian Forest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/B Description You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through t…
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/A Description You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square r…
D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go…
D - Road Improvemen 思路:0没有逆元!!!! 不能直接除,要求前缀积和后缀积!!! #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define y1 skldjfskldjg #define y2 skldfjsklejg using namespace…
题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include <string.h> int vis[11][11]; char map[11][11]; int main() { int r, c; while (scanf("%d %d", &r, &c) != EOF) { for (int i = 1; i <=…
吐槽一下,这次的CF好简单啊. 可是我为什么这么粗心这么大意这么弱.把心沉下来,想想你到底想做什么! A 题意:O(-1) 思路:O(-1) #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> using namespace std; int main() { ]; ][]; int n, m; while(c…
#include <iostream> #include <vector> using namespace std; int main(){ int r,c; cin >>r>>c; vector<bool> row(r,false),col(c,false); char ch; ; i < r; i ++ ){ ; j < c; j ++){ cin >> ch; if(ch == 'S') row[i] = col[j…
题意: 在一个正常的点可以净化该行该列的所有细胞,判断是否可以净化所有的细胞,并且输出所选的点. 思路: 如果可以的话,一定会选n个点. 先判断每一行是否有正常细胞,然后判断每一列是否有,如果都没有肯定不能净化,然后输出每一行或者每一列的第一个正常细胞的位置就好. #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n ; char map[110][11…
A. Cakeminator time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For exam…
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停下来,竖直走. // 问走到终点的最短时间 // 思路: // 1.贪心来做 // 2.我觉的二分更直观 // 可以抽象成:一条射线与凸边行相交,判断交点.二分找切点 #include <bits/stdc++.h> using namespace std; #define LL long lon…
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland has n cities connected by m bidirectional roads. No road connects a city…
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…
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular cho…
Codeforces Round #485 (Div. 2) C. Three displays 题目连接: http://codeforces.com/contest/987/problem/C Description It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays…
Codeforces Round #525 (Div. 2) 哎,忍不住想吐槽一下,又要准备训练,又要做些无聊的事,弄得我都想退出了. 好好的训练不好么???? 只能做出两道水题,其实C题,感觉做出来了,差几分钟,不能提交了,明天交一发试试吧. 题目一览表 来源 考察知识点 完成时间 A Ehab and another construction problem cf 签到?? 2018.12.4 B Ehab and subtraction cf 签到?? 2018.12.4 C Ehab a…
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # include <bits/stdc++.h> int main() { int x; scanf("%d", &x); for(int i = 1; i <= x; i++) for(int j = 1; j <= x; j++) if((i % j == 0) &…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…