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>…
题目传送门 题目大意: 给出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…
在load csv 进mysql的时候,报这个错,苦恼了很长时间,网上搜索不到答案. mysql>    load data infile '/home/hdh/8_sr/8_45.csv'  into table  xizang.fp45 fields terminated by ','   escaped by '"' lines terminated by '\r\n'; 解决方案: 1.查看字符集,Linux, 数据库,表 mysql> show variables like…
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase…
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. 分析:找出字符串中第一次出现且不重复的字符,返回其字符的下标,如果不存在就返回-1. 用hashMap进行求…
问题: 插入数据时,报了这样一个错误:“_mysql_exceptions.Warning: Incorrect string value: ‘\xE6\xB5\x81\xE8\xA1\x8C…’ for column ‘name’ at row 1”. 我使用了中文的数据,看起来就是一个字符集不兼容的错误:Django默认使用UTF-8,而mysqld那边配置是默认使用了latin1 – default collation . 解决办法如下: (1)设置my.cnf vim /etc/mysq…