Crazy Binary String
最长01个数相等的子串和子序列
字串用二分做的,有hack数据 :8 00111100
好像数据太水,直接放过去了
下面为二分代码
#include<bits/stdc++.h>
using namespace std;
int t,n;
typedef long long ll;
#define P pair<ll,ll>
#define fi first
#define se second
P A[];
ll mx,my;
bool cmp(P a,P b)
{
return a.se*b.fi>a.fi*b.se;
} int main()
{
scanf("%d",&t);
while(t--)
{
srand(time(NULL));
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%lld%lld",&A[i].fi,&A[i].se);
if(i==)mx=A[i].fi,my=A[i].se;
mx=min(A[i].fi,mx);
my=min(A[i].se,my);
}
mx-=rand()%+;
my-=rand()%+;
for(int i=;i<=n;i++){
A[i].fi-=mx;
A[i].se-=my;
}
sort(A+,A+n+,cmp);
P a=A[n/],b=A[n/+];
cout<<mx<<' '<<my<<' ';
ll x=a.fi+b.fi;
ll y=a.se+b.se;
cout<<x+mx<<' '<<y+my<<'\n';
}
}
Crazy Binary String的更多相关文章
- 2019牛客多校第三场B Crazy Binary String 思维
Crazy Binary String 思维 题意 给出01串,给出定义:一个串里面0和1的个数相同,求 满足定义的最长子序列和子串 分析 子序列好求,就是0 1个数,字串需要思考一下.实在没有思路可 ...
- 2019 牛客多校第三场 B Crazy Binary String
题目链接:https://ac.nowcoder.com/acm/contest/883/B 题目大意 给定一个长度为 N 的 01 字符串,输出最长子串和子序列的长度,满足其中 0 和 1 的个 ...
- 2019牛客多校训练第三场B.Crazy Binary String(思维+前缀和)
题目传送门 大致题意: 输入整数n(1<=n<=100000),再输入由n个0或1组成的字符串,求该字符串中满足1和0个数相等的最长子串.子序列. sample input: 801001 ...
- Crazy Binary String(前缀和)(2019牛客暑期多校训练营(第三场))
示例: 输入: 801001001 输出:4 6 题意:一段长度为n且只有 ‘0’ 和 ‘1’ 的字符串,求子串中 ‘0’ 和 ‘1’ 数目相等和子序列中 ‘0’ 和 ‘1’ 数目相等的最大长度. 思 ...
- 最长相同01数的子串(map搞搞)--牛客第三场 -- Crazy Binary String
题意: 如题. 或者用我的数组分治也可以,就是有点愚蠢. //#include <bits/stdc++.h> #include <map> #include <iost ...
- Crazy Binary String<Map法>
#include<cstdio> #include<iostream> #include<map> using namespace std; map<int, ...
- 2019牛客多校第三场B-Crazy Binary String(前缀和+思维)
Crazy Binary String 题目传送门 解题思路 把1记为1,把0记为-1,然后求前缀和,前缀和相等的就说明中间的01数一样.只要记录前缀和数值出现的位置即可更新出答案. 代码如下 #in ...
- Binary String Matching
问题 B: Binary String Matching 时间限制: 3 Sec 内存限制: 128 MB提交: 4 解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...
- NYOJ之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
随机推荐
- csr_matrix用法
1 csr_matrix默认对未填充的位置置为0, row = [0, 0, 0, 1, 1, 1, 2, 2, 2] # 行指标 col = [0, 1, 2, 0, 1, 2, 0, 1, 2] ...
- Temporal-Difference Learning for Prediction
In Monte Carlo Learning, we've got the estimation of value function: Gt is the episode return from t ...
- win
/*-------------------------------------------------------------- HelloMsg.c -- Displays "Hello, ...
- HackGame2 writeup
网址:http://hackgame.blackbap.org/ 第一关 突破客户端:无论输入什么密码都会提示"密码不能为空",使用浏览器检查网页元素会发现提交时会触发 javas ...
- CentOS7 破解登录密码
1.重启系统,在出现下面这个界面时按e 2.进入之后方向键的下,找到“LANG=en_US.UTF-8",在这个命令后面输入“rd.break",完成之后按ctrl+x进入紧急救援 ...
- [BNDSOJ] 小P的数列代码
感谢gjznb大佬的帮助Orz #include<bits/stdc++.h> using namespace std; ; vector<int> dp[N][N]; ]; ...
- python 导入json模块的用法
json用于字符串,和 python数据类型间进行转换,json模块有四个功能,dumps,dump,loads,load. json 用法 json.dumps 将数据通过特殊的形式转换为所有程序语 ...
- Untiy3D学习笔记记录
一,原点和中心点 pivot(原点):位置移动的点(模型的原点不会发生变化) center(中心点):计算模型的中心,会发现变化(比如有两个cube,他的中心点会计算在两个模型的中间) 二,prefa ...
- Linux awk抓取IP的两种方式
ip addr show ens33 | awk -F "[ /]+" '/inet /{print $3}' 或 ifconfig ens33 | awk -F "[ ...
- Python之路-面向对象&继承和多态&类属性和实例属性&类方法和静态方法
一.面向对象 编程方式 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强…” 什么是面 ...