题目链接:https://codeforces.com/contest/1100/problem/E 题意:给出 n 个点 m 条边的有向图,要翻转一些边,使得有向图中不存在环,问翻转的边中最大权值最小是多少. 题解:首先要二分权值,假设当前最大权值是 w,那么大于 w 的边一定不能翻转,所以大于 w 所组成的有向图不能有环,而剩下小于等于 w 的边一定可以构造出一个没有环的图(因为如果一条边正反插入都形成环的话,那么图里之前已经有环了),构造方法是把大于 w 的边跑拓扑序,然后小于等于 w 的…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
D. Gourmet choice 链接:http://codeforces.com/contest/1131/problem/D 思路: =  的情况我们用并查集把他们扔到一个集合,然后根据 > < 跑拓扑排序,根据拓扑排序的结果从小到大填数字就好了,需要注意的细节写在代码注释里了 代码: #include<bits/stdc++.h> using namespace std; ; int f[M],n,m; set<int>st[M]; vector<int&…
传送门 Description Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv…
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出由-1和1组成的n个数,现在任意选定一个起点,从起点开始向左向右k个k个地拿走.最后问abs(cnt(-1)-cnt(1))最大是多少. 题解: 由于n和k最多只有100,所以枚举起点直接暴力就好了. 代码如下: #include <bits/stdc++.h> using namespace s…
Codeforces Round #532 (Div. 2) A - Roman and Browser #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #inclu…
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停下来,竖直走. // 问走到终点的最短时间 // 思路: // 1.贪心来做 // 2.我觉的二分更直观 // 可以抽象成:一条射线与凸边行相交,判断交点.二分找切点 #include <bits/stdc++.h> using namespace std; #define LL long lon…
A. Roman and Browser 签到. #include <bits/stdc++.h> using namespace std; ]; int get(int b) { ]; memset(vis, , sizeof vis); int c = b; while (c <= n) { vis[c] = ; c += k; } c = b - k; ) { vis[c] = ; c -= k; } , r = ; ; i <= n; ++i) if (!vis[i]) {…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
https://codeforces.com/contest/1100/problem/F 题意 一个有n个数组c[],q次询问,每次询问一个区间的子集最大异或和 题解 单问区间子集最大异或和,线性基能处理,但是这次多次询问,假如每次重新建立基向量会超时 考虑区间的优先级,假如我只插入不删除的话,区间的优先级和左端点没有关系 贪心一下,只保留后面插入的基,这样就可以离线解决询问,然后查询的时候需要判基的位置是不是在左端点后面 代码 #include<bits/stdc++.h> #define…
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区间的异或和最大值. 题解: 考虑离线做法,先把所有的询问区间按照右端点进行排序,然后从1开始逐个将ai插入,插入线性基的同时记录一下位置,最后扫一下,看看哪些的位置是不小于li的即可加入答案. 这种做法在时间复杂度上面是可行的,但是需要注意的是,如果在i这个位置插入最高位为x的线性基,同时在j这个位…
Arkady coordinates rounds on some not really famous competitive programming platform. Each round features nn problems of distinct difficulty, the difficulties are numbered from 11 to nn. To hold a round Arkady needs nn new (not used previously) probl…
链接:https://codeforces.com/contest/1100/problem/C 题意: 一个圆球外面由其他圆球包裹,两两相连. 给出n,r. n为外面圆球数量,r为内部圆球半径. 求外面圆半径R. 思路: 将内圆和外面两个相邻圆圆心连线,成三角形,将内圆圆心与内圆与外圆交点连线. 可得出公式. 代码: #include <bits/stdc++.h> #define PI 3.1415926535 using namespace std; int main() { int n…
链接:https://codeforces.com/contest/1100/problem/B 题意: 给n,m. 给m个数,每个数代表一个等级,没给一个将其添加到题目池中,当题目池中有难度(1-n)的题目都存在时, 即可产生一次竞赛. 每给一个数,如果可以出竞赛,输出1,否则输出0. 思路: 一个变量记录有几种题目,一个数组记录每种题目有几个. 能出题时将每种题目的数量减一,减完后为0,则记录种类变量减一. 代码: #include <bits/stdc++.h> using namesp…
链接:https://codeforces.com/contest/1100/problem/A 题意: 给定n,k. 给定一串由正负1组成的数. 任选b,c = b + i*k(i为任意整数).将c所有c位置的数删除,求-1和1个数差值绝对值的最大值. 思路: 暴力遍历 代码: #include <bits/stdc++.h> using namespace std; int a[110]; int main() { int n,k; scanf("%d%d",&…
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles: It turned out that the circles are equal. NN was very…
This morning, Roman woke up and opened the browser with nn opened tabs numbered from 11 to nn. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many ta…
http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day n friends gathered together to play "Mafia". During each round of the g…
题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似topsort,'.'与上下左右的'.',的相连.从度为1的点作为突破口. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream>…
B. Lipshitz Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/601/problem/B Description A function  is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| hold…
D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/problem/D Description For months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cy…
B. Kefa and Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/problem/B Description Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend wi…
D. Friends and Subsequences 题目连接: http://www.codeforces.com/contest/689/problem/D Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their o…
C. Vasya and String 题目连接: http://www.codeforces.com/contest/676/problem/C Description High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as th…
D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single soluti…
D. Image Preview 题目连接: http://www.codeforces.com/contest/651/problem/D Description Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over…
E. Thoroughly Bureaucratic Organization 题目连接: http://www.codeforces.com/contest/201/problem/E Description Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TB…
任意门:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array ss consisting of nn integers. You have to find any ar…
题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \(k^2\),另一方就乘以 \(k\).问你能不能达到 \((a,b)\) 这个最终状态. 题解: 设 \(X\), \(P\) 表示两个乘积的集合. 那么,显然: \(S^{2}*P=a\) ------ 1 \(S*P^{2}=b\) ------ 2 所以:\(a*b = S^{3}*P^3\)…
题目链接:https://codeforces.com/contest/1370/problem/D 题意 给出一个含有 $n$ 个数的数组 $a$,从中选出 $k$ 个数组成子序列 $s$,使得 $min(max(s_1, s_3,       s_5, \ldots), max(s_2, s_4, s_6, \ldots))$ 最小. 题解 二分最小值,分别讨论二分值在奇数下标序列和偶数下标数列中的情况. 如果可以构造某个序列使其中的数都小于等于二分值则说明该二分值可行,设为上界,否则加一设…