E. Connected Components? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an undirected graph consisting of n vertices and  edges. Instead of giving you the edges that exist i…
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. Water The Garden 题意:给你一个长度为\(n\)的池子,告诉你哪些地方一开始有水, 每秒可以向左和向右增加一格的水, 问什么时候全部充满水.(\(n \le 200\)) 题解:按题意模拟.每次进来一个水龙头,就更新所有点的答案 (取\(min\)).最 后把所有点取个\(max\)就…
Educational Codeforces Round 37 (Rated for Div. 2)C. Swap Adjacent Elements time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have an array a consisting of n integers. Each integer from 1…
E. Connected Components? You are given an undirected graph consisting of n vertices and edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge between x and y, and if some pair…
E. Connected Components? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an undirected graph consisting of n vertices and  edges. Instead of giving you the edges that exist i…
A. water the garden Code #include <bits/stdc++.h> #define maxn 210 using namespace std; typedef long long LL; int n, k; int x[maxn]; void work() { scanf("%d%d", &n,&k); for (int i = 0; i < k; ++i) scanf("%d", &x[i]…
我的代码应该不会被hack,立个flag A. Water The Garden time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output It is winter now, and Max decided it's about time he watered the garden. The garden can be represent…
Water The Garden #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #inclu…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] bfs. 用一个链表来记录哪些点已经确定在某一个联通快里了. 一开始每个点都能用. 然后从第一个点开始进行bfs. 然后对于它的所有连接着的点(输入的图的补图 看看它是不是之前进行过bfs,如果是的话.就跳过.(可以用链表直接跳过.即沿着链表枚举它的出度. 否则.把这个点从链表中删掉.然后把这个点加入队列.继续bfs即可. 这样已经确定联通了的点之间不会再访问. 链表加速了寻找某个点的出度的过程. 且由于当n很大的时候.m只有2…
题 OvO http://codeforces.com/contest/920/problem/E 解 模拟一遍…… 1.首先把所有数放到一个集合 s 中,并创建一个队列 que 2.然后每次随便取一个数,并且从集合中删除这个数,将这个数放入 que 3.取 que 首元素,记为 now,然后枚举集合 s,每次找到 s 中和 now 相连的元素 x,从 s 中删除元素 x,并且把 x 放入 que 中. 4.如果 s 不为空,回到步骤2 可见就是一个模拟,至于复杂度,计算如下. 由于每个数字只会…