Codeforces 101572 D - Distinctive Character】的更多相关文章

D - Distinctive Character 思路:bfs 使最大的匹配数最小,转换一下,就是使最小的不匹配数最大,用bfs找最大的距离 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0)…
Distinctive Character Sol bfs寻找最优解. 考虑一开始把他给的状态加进队列里,这些状态的答案都是0. 每次枚举不同的一位拓展,同时要保证这个新状态没有出现过. 效率O(2^k) 话说我随机化85呢 #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath>…
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant chara…
题目传送门 题目大意: 给出n个01串,让你构造一个字符串,使这个字符串和这些字符串中相似程度最高 尽可能低.如果两个字符串对应位置相同,则相似程度加一. 思路: 每一个01串更改自己的一部分后,都可以得到任何的01串.我希望所有的字符串最后能变成相同的01串.我们将题意转化一下,使相似程度最高的  尽可能低,也就是使不相似程度最低的 尽可能高,而每一个01串改变一次之后,就相当于不相似程度加一,当bfs第一次经过一个状态后,就得到了这个状态对于所有字符串的最低相似程度(因为其他01串到这个01…
A. Airport Coffee 设$f_i$表示考虑前$i$个咖啡厅,且在$i$处买咖啡的最小时间,通过单调队列优化转移. 时间复杂度$O(n)$. #include<cstdio> const int N=500010; typedef long long ll; const double inf=1e20; ll L,A,B,T,R,lim0,lim1,a[N]; double f[N],val[N]; double dp0=inf; int id0; int pre[N]; int…
A - Airport Coffee 留坑. B - Best Relay Team 枚举首棒 #include <bits/stdc++.h> using namespace std; #define N 510 #define INF 0x3f3f3f3f struct node { string name; double v1, v2; inline void scan() { cin >> name >> v1 >> v2; } inline boo…
比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best Relay Team 00:49 (+2) Solved by xk 排序后简单模拟一下题意即可. xk说他要背个锅. 代码: #include <iostream> #include <cmath> #include <map> #include <algorit…
1) Link to the problem: http://codeforces.com/contest/888/problem/C 2) Description: You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant if each substring of s with length at least k contains this character…
题目链接 http://codeforces.com/gym/101572 题意  一共n个文件  存在依赖关系 根据给出的依赖关系   判断是否存在循环依赖 ,不存在的话输出SHIP IT,存在的话,打印最小的环,若有多个,输出其中任何一个. 解析  这道题其实很简单,最小的环无非就是自己到自己的最短路,直接把存在依赖的两个文件建立有向边(题意可看出),权值设为1,跑一遍Floyd,找出自己到自己最短路最小的那个点,输出它的路径.但是输入有点恶心,感觉在搞事情,处理一下就好了. AC代码 #i…
B2. Character Swap (Hard Version) This problem is different from the easy version. In this version Ujan makes at most 2…
B1. Character Swap (Easy Version) This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems. After struggling and failing many times, Ujan decided to tr…
题目:Problem - C - Codeforces 如代码,一共有七种情况,注意不要漏掉  "accabba"  , "abbacca"  两种情况: 使用find()函数可简化代码,使用方法如下 代码: #include <iostream> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.ti…
题目链接:https://vjudge.net/problem/CodeForces-888C 划一条线,使得不论怎么划线,都会出现一个特定的字符,那么这条线最短要多长. 用字符间隔考虑. 先判断哪些字符出现了,然后统计每个不同字符的出现次数,出现一次的和出现多次的分开判断. 出现一次的找到它的位置,取max(当前位置 - 字符串开始位置 + 1,字符串末位位置 - 当前位置 + 1), 然后遍历所有出现一次的字符,得出max的最小值,并记录,dis1 出现多次的找到相邻两个相同字符的间隔,取最…
传送门 •前置知识-multimap的用法 $multimap$ 与 $map$ 的区别在于一个 $key$ 可以对应几个值: 对于 $map$ 而言,一个 $key$ 只能对应一个值,并且按照 $key$ 升序排列: 而 $multimap$ 的一个 $key$ 可以对应多个值,并且按照 $key$ 升序排列: 但是,相同的 $key$ 对应的多个值按照插入的顺序排列,不会自动排序: 定义:$multimap<char ,int >f$ 插值 $f.insert(make\_pair('a'…
This problem is different from the easy version. In this version Ujan makes at most 2n2n swaps. In addition, k≤1000,n≤50k≤1000,n≤50 and it is necessary to print swaps themselves. You can hack this problem if you solve it. But you can hack the previou…
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems. After struggling and failing many times, Ujan decided to try to clean up his house again. He…
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…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output 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…
D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: standard input output :standard output The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is loca…
[codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by on…
题目 Source http://codeforces.com/problemset/problem/528/D Description Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings cons…
C. Sonya and Queries time limit per test:1 second memory limit per test: 256 megabytes input:standard input output: standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty mul…
B - Hongcow Solves A Puzzle 题目连接: http://codeforces.com/contest/745/problem/B Description Hongcow likes solving puzzles. One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be…
A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how t…
A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is…
C. Balance 题目链接 http://codeforces.com/contest/17/problem/C 题面 Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began…
D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to…
A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner - Anton or Danik. None of th…
B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a grid with some cells that are empty and some cells that are occupied. You s…
地址:http://codeforces.com/problemset/problem/712/B 题目: B. Memory and Trident time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is performing a walk on the two-dimensional plane, starti…