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…
题 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 可见就是一个模拟,至于复杂度,计算如下. 由于每个数字只会…
我的代码应该不会被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…
G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Let's denote as L(x, p) an infinite sequence of integers y such that gcd(p, y) = 1 and y > x (where gcd is the greatest…
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…
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…
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你一个有向图,给用最少的颜色给每条边染色,要保证不存在一个环中的所有边都是同一个颜色. [Solution] ​ 用拓扑排序判断图中是否存在环,若图中不存在环,则所有边都是同一种颜色.否则,同一个环中,只要用两种颜色就可以满足题目条件,所以总的颜色数就是两种,对于一个环,一定会存在两种边:1.节点号小…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec Problem Description Input Output The only line should contain the minimal number of days required for the ship to reach the point (x2,y2)(x2,y2). If it…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec Problem Description Input The input contains a single line consisting of 2 integers N and M (1≤N≤10^18, 2≤M≤100). Output Print one integer, the total n…
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(x)…