Codeforces 1220E. Tourism】的更多相关文章

传送门 这是一道英语题,首先要读懂题目: $\text{Alex believes that his trip will be interesting only if he will not use any road twice in a row.}$ 这句话意思是不会连续走一条路,但是同一条路是可以走多次的 所以对于一个边双联通分量,是可以全部走一遍并可以从联通分量里的任意一个点离开的 所以就可以直接缩点,然后就变成树上问题 发现对于树上的点,如果它的大小为 $1$ 并且它的儿子都没法返回 ,…
(做题方式:瞟题解然后码) 1238E. Keyboard Purchase \(\texttt{Difficulty:2200}\) 题意 给你一个长度为 \(n\) 的由前 \(m\) 个小写字母组成的字符串 \(s\) ,定义一个 \(m\) 个字母的排列 \(t\) 的代价为 \(\sum_{i=2}^n |pos_{s_i}-pos_{s_i-1}|\) ,其中 \(pos_c\) 表示 \(c\) 在 \(t\) 中的位置.求最小的代价. \(n\le 10^5, m\le 20\)…
链接: https://codeforces.com/contest/1220/problem/E 题意: Alex decided to go on a touristic trip over the country. For simplicity let's assume that the country has n cities and m bidirectional roads connecting them. Alex lives in city s and initially loc…
题面 可以发现一个边双必然是可以随意走的,所以我们就把原图求割边然后把边双缩成一个点,然后就是一个树上dp了. #include<bits/stdc++.h> #define ll long long using namespace std; const int N=200005; #define pb push_back inline int read(){ int x=0; char ch=getchar(); for(;!isdigit(ch);ch=getchar()); for(;i…
  记录一些没有写在其他随笔中的 Codeforces 杂题, 以 Problemset 题号排序   1326D2 - Prefix-Suffix Palindrome (Hard version) 题意: 给出一个串 s, |s| ≤ 1e6, 要求选出一个前缀和一个后缀(不相交, 可以为空), 使得它们连接后是一个回文串. 求最长的回文串. 思路: 马拉车处理半径数组, 用前缀, 后缀, 半径与相同的前后缀相交的情况更新答案. view code #include <bits/stdc++…
渭城朝雨浥轻尘,客舍青青柳色新. 劝君更尽一杯酒,西出阳关无故人.--王维 A. Ichihime and Triangle 网址:https://codeforces.com/contest/1337/problem/A Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears. These days the temple is holdi…
上一次我们拿学校的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…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…