CodeForces Round #403 (Div.2) A-F】的更多相关文章

Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放学我呆到十点然后还要跑回家耽误时间....要不然$D$题就写完了 周末一些成绩好的同学单独在艺术楼上课然后晚上下第一节晚自习和他们在回廊里玩开灯之后再关上一片漆黑真好玩 A.Andryusha and Socks 日常煞笔提.....我竟然$WA$了一次忘了$n<<1$ #include <…
Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值最大是多少. \(n,m \le 2*10^5,-10^5\le x_i, y_i \le 10^5\) key:二分,贪心 二分答案,此时可以以原点画圆,那么每条直线都可以与该圆相切.每个点与该圆的两切点形成一个区间.问题变成对于 n 个环形区间,用至多 m 个点去覆盖使得每个区间都被覆盖,问是否…
目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路) F.Asya And Kittens(链表) G.Most Dangerous Shark Codeforces 1131 比赛链接 hack一个暴力失败了两次最后还是没成功身败名裂= = CF跑的也太快了吧... 不过倒也涨了不少. A.Sea Battle //想麻烦了,但是无所谓... #…
地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and…
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区间的异或和最大值. 题解: 考虑离线做法,先把所有的询问区间按照右端点进行排序,然后从1开始逐个将ai插入,插入线性基的同时记录一下位置,最后扫一下,看看哪些的位置是不小于li的即可加入答案. 这种做法在时间复杂度上面是可行的,但是需要注意的是,如果在i这个位置插入最高位为x的线性基,同时在j这个位…
题:https://codeforces.com/contest/1253/problem/E 题意:给定n个信号源,俩个参数x和s,x代表这个信号源的位置,s代表这个信号源的波及长度,即这个信号源可以遍及[x-s,x+s]范围,然后你可以消耗一个代价来换取某个信号源的s加1, 给定m,问信号覆盖1到m所有数的最小代价是什么 分析:考虑dp[i]:表示[i+1,m]被覆盖所要花费的最小代价,dp[0]就是答案,枚举[0,m-1],从后往前枚举,若i+1在某个初始范围里面则dp[i]=dp[i+1…
因为很久没有个人认真做题了 昨天晚上开了场虚拟cf来锻炼个人手速 选的是第一次做cf的场 那时候7出3还被hack...之后也没补题 这次做的时候顺便回忆了一下以前比赛的时候是怎么想的 发现经验还是很重要的.. E 给出n个城市和m条双向边 把所有的双向边都变成单向的 如果一个城市的入度为0 那它就是孤独的 问有多少个孤独的 想到一个联通分量中 如果没有环(树) 那么肯定有一个点是孤独的 有环就没有了 那就对于每一个未访问的点bfs一下 然后dfs判断有没有环 O(n)的复杂度 F 一个n*m的…
Div1单场我从来就没上过分,这场又剧毒,半天才打出B,C挂了好几次最后还FST了,回紫了. AC:AB Rank:340 Rating:2204-71->2133 Div2.B.The Meeting Place Cannot Be Changed 题目大意:n个人,第i个人位于xi,速度为vi,找到一个点使得所有人到这个点的耗时最小,输出耗时.(n<=60000) 思路:二分答案,知道耗时后可以求出每个人能到达的区间,如果所有区间有交则合法,复杂度O(nlog). #include<…
唉,昨天晚上迷迷糊糊地去打cf,结果fst两题,掉回蓝了... A.Andryusha and Colored Balloons 题意:给定一棵树,任意两个距离小等于二的点不能染相同的颜色,求最小颜色数和染色方案. n<=2*10^5 题解:求一个度数最大的点,度数+1即是颜色数,然后暴力染色. #include<iostream> #include<cstdio> #include<algorithm> #include<queue> #includ…
E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使用最少的 1 号汽油的前提下使用最少的二号汽油, 我们可以这样考虑 当前在第i个加油站的时候         i个加油站 有3种情况 第一种 他是只有 1 号汽油 那么他必须携带 尽量少的 1号汽油到达离他最近的2号汽油点或者3号汽油点 更新这个点到达终点的代价 取最小值,因为他必须通过那个点到达其…
http://codeforces.com/contest/782/problem/E 题目大意: 有n个节点,m条边,k个人,k个人中每个人都可以从任意起点开始走(2*n)/k步,且这个步数是向上取整的.要求:着k个人要走完所有的节点,且每个人至少走1步. 思路:= =dfs找一棵树,一棵树是n-1条边,所以从树根开始走完所有的,也就只有n*2-2步,所以不会达到上限.md这么简单都没有想到,233 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #incl…
http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用了第二种队名,那么如果队 B 的第一种队名和队 A 的相同,那么同样不能选择.当然,队B的第二个队名无所谓 思路: 学习了2-sat发现这题这么简单= =. 如果那天A了这题就前200了 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits…
地址:http://codeforces.com/contest/782/problem/E 题目: E. Underground Lab time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The evil Bumbershoot corporation produces clones for gruesome experimen…
地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in B…
地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Bytecity is a straight line from…
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha is an orderly boy and likes to keep things in their plac…
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the…
B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates…
精神不佳,选择了在场外同步划水 没想到实际做起来手感还好,早知道就报名了…… 该打 未完待续233 A. Andryusha and Socks 模拟,模拟大法好.注意每次是先判断完能不能收进柜子,再算桌子上的袜子数量的. /*by SilverN*/ #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> using na…
A =w= B 题意:一个数轴上有n个整点,每个点都有一个速度,选一个点让他们集合,使得时间最少. 分析: 直接三分 C 题意:给定一棵树,任意两个距离小等于二的点不能染相同的颜色,求最小颜色数和染色方案. n<=2*10^5 分析: 容易知道答案就是最大的度数+1 至于方案直接暴搜出方案就行 D 题意:有n个足球队,每个队有两个选名字的方案,也就是直接给定了两个名字.所有球队不能有相同的名字.特殊的,如果有两个球队第一个名字相同,一个球队选了第二个名字,另一个球队不能选第一个名字.n<=10…
CF-1029F 题意: a,b个小正方形构造一个矩形,大小为(a+b),并且要求其中要么a个小正方形是矩形,要么b个小正方形是矩形. 思路: 之前在想要分a,b是否为奇数讨论,后来发现根本不需要.只用枚举(a+b)大小的矩形的边长,并暴力判断(注意暴力判断的顺序)能否成立,更新答案. #include <algorithm> #include <iterator> #include <iostream> #include <cstring> #includ…
D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in Byteland. The first task he should do is to assign s…
先反复地扫(不超过n次),把所有可以确定唯一取法的给确定下来. 然后对于剩下的不能确定的,跑2-SAT.输出可行解时,对于a和¬a,如果a所在的强连通分量序号在¬a之前,则取a,否则不取a.如果a和¬a在同一个强连通分量,则无解. #include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstring…
从任意点出发,贪心染色即可. #include<cstdio> #include<algorithm> using namespace std; int v[200010<<1],next[200010<<1],first[200010],e; void AddEdge(int U,int V) { v[++e]=V; next[e]=first[U]; first[U]=e; } bool vis[200010]; int n,col[200010]; v…
三分显然,要注意EPS必须设成1e-6,设得再小一点都会TLE……坑炸了 #include<cstdio> #include<algorithm> #include<cmath> using namespace std; #define EPS 0.000001 int n,x[60010],v[60010]; double calc(double p) { double res=0; for(int i=1;i<=n;++i) res=max(res,fabs(…
翻车!翻车! codeforces782A A题: 水. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; int num[100010]; int main() { int n,x; memset(num,0,sizeof(num)); scanf("%d",&n); int sum=0,ans=0; for(int i=1;i<=2*n;i++) { scanf(…
Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Description You are given a set of size $m$ with integer elements between $0$ and $2^{n}-1$ inclusive. Let's build an undirected graph on these integers in…
Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/contest/988/problem/E Description Polycarp lives on a coordinate line at the point x=0. He goes to his friend that lives at the point x=a. Polycarp can…
题目链接 Codeforces Round #501 (Div. 3) F. Bracket Substring 题解 官方题解 http://codeforces.com/blog/entry/60949 ....看不懂 设dp[i][j][l]表示前i位,左括号-右括号=j,匹配到l了 状态转移,枚举下一个要填的括号,用next数组求状态的l,分别转移 代码 #include<bits/stdc++.h> using namespace std; const int maxn = 207;…
Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不能进行运动或比赛 可以进行运动但不能比赛 可以进行比赛但不能运动 可以进行比赛或运动 对于每天,可以根据当天的状态选择运动,比赛或休息.但不能连续两天的选择均为运动或均为比赛.求在这 \(n\) 天中最少需要休息多少天. 数据范围:\(n \leq 100\) 简要题解:令 \(f_{i,0},f_…