@codeforces - 594E@ Cutting the Line】的更多相关文章

目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个字符串 s 与正整数 k.现在你需要进行恰好一次操作: (1)将 s 切割成最多 k 个子串.即令 s = t1 + t2 + ... + tm (1 <= m <= k). (2)将其中的某些(不是全部) ti 翻转,得到 t1', t2', ... tm'. (3)重新拼合得到 s' = t1' + t2' + ... tm'. 求字典序最小化的…
[codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that ea…
看起来非常神,但仅仅有三种情况 -1 , 1 ,2..... A. Cutting Figure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark…
Description Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't e…
题目链接:Cutting Out 题意:给定一个n长度的数字序列s,要求得到一个k长度的数字序列t,每次从s序列中删掉完整的序列t,求出能删次数最多的那个数字序列t. 题解:数字序列s先转换成不重复的数字序列,并记录各个数字重复的次数,然后按照重复次数从大到小排序.二分最大删除次数,最后再输出对应的序列t. #include <map> #include <cstdio> #include <iostream> #include <algorithm> us…
https://codeforces.com/problemset/problem/998/B 简单贪心题 代码如下: #include <stdio.h> #include <string.h> #include <iostream> #include <string> #include <math.h> #include <algorithm> #include <vector> #include <stack&…
题意:给出五个人的编号,分别为 1 2 3 4 5,他们在排队, 最开始的时候,1和2可以交谈,3和4可以交谈 然后1走了之后,2和3交谈,4和5可以交谈 2走了之后,3和4可以交谈, 3走了之后,4和5可以交谈 给出一个5*5的矩阵,问最大的交谈的值, 比如2和3交谈,交谈的值为g[2][3]+g[3][2] 直接枚举排列,因为5!=120,算出每一种排列的交谈值,找出最大值 #include<iostream> #include<cstdio> #include<cstr…
其实这个几何写起来还是比较方便,只用到了叉积.首先我们贪心的考虑一种情况,对于任意给定的LR串,我们起点的选择肯定是在这些点围成的凸包端点上,对于这样的起点来说,他对于L或者R都是有选择的机会,而且一定可以从剩下n-1个点选出两个点满足要求(可以画图观察),接下来我们对于这个起点出发开始去寻找满足LR的点,对于第二个点来说,我们需要去找到剩下n-1个点中最外侧的点,并且满足剩下n-2个点都在向量point[1]-point[0]的左侧或者右侧,这个可以直接由叉积得到,那么我们便得到了第二个点,显…
题目:戳这里 题意:给n个数的数组,要求找k个数满足,这k个数在数组中出现的次数最多. 解题思路:k个数每个数出现次数都要最大化,可以想到二分下限,主要是正确的二分不好写. 附ac代码: 1 #include <bits/stdc++.h> 2 typedef long long ll; 3 const int maxn = 1e6+10; 4 const ll inf = 1e18; 5 using namespace std; 6 int cnt[maxn]; 7 int s[maxn];…
A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/problem/A Description A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Un…
  A. Cutting Banner   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Mi…
A. Cutting Banner time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami…
A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
D. Super M Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/D Description Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that…
Time limit 2000 ms Memory limit 262144 kB Source Codeforces Round #328 (Div. 2) Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected…
Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects exactly two distinct cities,…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces' superhero. Byteforces is a country that consi…
yy or Y to copy the line or dd to delete (cutting) the line then p to paste the copied or deleted text after the current line or P to paste the copied or deleted text before the current line…
浅谈从 Lyndon Words 到 Three Squares Lemma By zghtyarecrenj 本文包括:Lyndon Words & Significant Suffixes & Lyndon Array & Runs & Lyndon Tree & Three Squares Lemma. 禁止转载全文,转载部分需要注明出处. 前言 本文正在重写 如果你发现笔者有写错的地方,请联系笔者.(尽量不要用博客园评论,我不会经常看,建议用洛谷私信我或者加…
B - 楼下水题 Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 7C Description A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coo…
A.Warrior and Archer(思维) 战士一定会ban掉当前边缘的位置.而战士和射手就会选择剩下的最远的两点.我们让剩下的最远的两点最近就达到了均衡.于是我们枚举战士ban掉的边缘,ban的次数是一定的. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # include <que…
连发三篇爆炸实录我的心态竟然还这么好…… 昨天题目的D2.稍难. 这也不是我连续拿倒数第一的理由. T1不会.赛时硬写了一个30分的三次方暴力.还有一个地方写挂了.如果不是数据足够水我就爆零了. 也就是说我的11分subtask1还是捡来的. 最难过的是T2.T2写了乱搞(正解之一??).然而并没有调出来. 二维莫队.我写的很顺.没什么细节错误.然而, 我是在最后20分钟才开始打的.也就是说我最一开始并没有打二维莫队. 一方面是觉得这东西复杂度应该不对.另一方面,我不会离散化. 对.我不会离散化…
知识点简单总结--Lyndon分解 Lyndon串 定义:一个字符串的最小后缀就是整个串本身. 等效理解:这个串为其所有循环表示中最小的. Lyndon分解 定义:将字符串分割为 $ s_{1} s_{2} ... s_{k} $ 任意段使得每一段都是Lyndon串且 $ \forall i < j , s_{i} \ge s_{j} $ . 引理一:若 $ u < v $ 且 $ u , v $ 均为Lyndon串,则 $ uv $ 为Lyndon串. 关于证明,它咕了. 引理二:Lyndo…
任意门:http://codeforces.com/contest/1118/problem/F1 F1. Tree Cutting (Easy Version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an undirected tree of nn vertices. Some vert…
任意门: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/contest/1077/problem/D You are given an array ss consisting of nn integers. You have to find any array tt of length kk such that you can cut out maximum number of copies of array tt from array ss. Cutting out the copy of tt mean…
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal. 输入 The first line contains integer n (1 ≤ n ≤ 3·105)…
题目传送门 /* 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 接下来mx次循环,若是0,输出0:若是1,输出1,s[j]--: 注意:之前的0的要忽略 */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include &…
题目传送门 /* 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 判断是否余下的是 "CODEFORCES" :) */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include <set>…