codeforces 1037】的更多相关文章

\(>Codeforces \space 1037\ H. Security<\) 题目大意 : 有一个串 \(S\) ,\(q\) 组询问,每一次给出一个询问串 \(T\) 和一个区间 \([l,r]\) ,要求找出 \(S\) 在 \([l,r]\) 之间的子串中字典序大于 \(T\) 且最小的 \(1 \leq |S|\leq 10^5, 1\leq q \leq 2 \times 10^5\) 解题思路 : 其实这个题一点意思都没有,就是一个 \(sam\) + 线段树合并裸题.. 但…
题解: E-trips 哎哎哎好傻逼啊 没有想到算不能的一直在想怎么算能的 太傻逼了 其实很简单 我们只需要对好友<=k的首先dfs一下给他连接着的朋友-1 然后如果小于了就递归下去 这个正确性是比较好想的 最后剩下的每个都是好友>=k个的并且都是这之间的 我们把他们都选了就可以了 这样不支持连边但是可以删边,所以倒着做就可以了 F - Maximum Reduction 大水题 会发现要求的长度为k,2k-1,3k-2,4k-3的最大值 单调栈维护前驱后继 然后前缀和优化一下求答案就完了 #…
目录 Codeforces 1037 A.Packets B.Reach Median C.Equalize D.Valid BFS E.Trips(正难则反) Codeforces 1037 比赛链接 F之后的先不做了... A.Packets logn+1,没细想,反正对. #include <cstdio> #include <cctype> #include <algorithm> #define gc() getchar() inline int read()…
D. Valid BFS? http://codeforces.com/contest/1037/problem/D 题意: 给一个序列,一棵树,判断能否bfs这棵树,得到这个序列. 分析: 将每个点所达到的点,按照序列中出现的位置排序,然后bfs,判断是否相等. 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<iostream>…
[题目链接] http://codeforces.com/problemset/problem/1037/E [算法] 首先离线 , 将问题倒过来考虑 , 转化为 : 每次删除一条边 , 此时最多有多少人参加旅行 假设所有点都选取 , 那么 ,如果一个点的度数 < k , 显然这个点不能选 , 我们需要删除它和所有与它相邻的边 显然 , 所有的点和边最多只会被删去一次 , 故时间复杂度为O(N + M) [代码] #include<bits/stdc++.h> using namespa…
[题目链接] http://codeforces.com/problemset/problem/1037/D [算法] 首先求出每个点的父节点 , 每棵子树的大小 然后判断BFS序是否合法即可 时间复杂度 : O(N) [代码] #include<bits/stdc++.h> using namespace std; ; struct edge { int to , nxt; } e[MAXN << ]; int n , tot; int a[MAXN],fa[MAXN],head…
题目链接:http://codeforces.com/problemset/problem/1037/D 题目大意: 给出一棵树,询问一个序列是否可能为这棵树从节点1开始遍历的bfs序 题解: 对于每个节点,令其权值等于该元素在给序列中出现的位置 把每个节点的出边按照到达点的权值排序,来一次bfs得到一个bfs序,判断当前bfs序与给定序列是否相等即可 #include<algorithm> #include<cstring> #include<cstdio> #inc…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…