Codeforces Round #500 (Div. 2) BC
| CodeForces | 1013B | And |
| CodeForces | 1013C | Photo of The Sky |
B
可以发现只有一次与操作是有意义的,所以答案只有-1,0,1,2四种情况
#include <bits/stdc++.h>
#define show(a) cout << #a << " = " << a << endl;
const int MOD = 1e9+;
const int MAXN = ;
const int INF = ;
typedef long long ll; using namespace std; int main()
{
std::ios::sync_with_stdio(false);
int n, x, ans = -;
cin >> n >> x;
int a[MAXN], point[MAXN];
for (int i = ; i <= n; i++)
{
cin >> a[i];
}
sort(a+, a++n);
for (int i = ; i <= n; i++)
{
if (a[i] == a[i-])
{
ans = ;
break;
}
}
if (ans == -)
{
int flg = ;
for (int i = ; i <= n; i++)
point[i] = a[i] & x;
for (int i = ; i <= n; i++)
{
int s = lower_bound(a+, a++n, point[i]) - a;
if (point[i] == a[s] && s != i)
{
ans = , flg = ;
break;
}
}
if (!flg)
{
sort(point+, point++n);
for (int i = ; i <= n; i++)
{
if (point[i] == point[i-])
{
ans = ;
break;
}
}
}
}
cout << ans << endl;
return ;
}
C
可以看成是红蓝染色,要求(红最大-红最小)*(蓝最大*蓝最小),排序后考虑两端颜色相同或不同,时间复杂度O(n)
#include <bits/stdc++.h>
#define show(a) cout << #a << " = " << a << endl;
typedef long long ll;
const int MOD = 1e9+;
const int MAXN = ;
const ll INF = 1e18; using namespace std; int main()
{
std::ios::sync_with_stdio(false);
int n;
cin >> n;
ll num[n*+];
for (int i = ; i <= *n; i++)
cin >> num[i];
sort(num+, num++*n);
ll ans = INF;
for (int i = ; i <= n; i++)
ans = min(ans, (num[i+n-] - num[i]) * (num[*n] - num[]));
ans = min(ans, (num[n*] - num[n+]) * (num[n] - num[]));
cout << ans << endl;
return ;
}
Codeforces Round #500 (Div. 2) BC的更多相关文章
- Codeforces Round #500 (Div. 2) [based on EJOI]
Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...
- Codeforces Round 500 (Div 2) Solution
从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemica ...
- Codeforces Round#500 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Codeforces Round #500 (Div. 2) D - Chemical table
首先我们如果满足三缺一,那么必有同行和同列的点 如果两行有同列的数,我们可以设想,他们最后会全部填充成为两者啥都有的情况 显然这个是个并查集 现在我们有了很多集合,每个集合自己可以进行三缺一操作,但是 ...
- Codeforces Round #421 (Div. 1) (BC)
1. 819B Mister B and PR Shifts 大意: 给定排列$p$, 定义排列$p$的特征值为$\sum |p_i-i|$, 可以循环右移任意位, 求最小特征值和对应移动次数. 右移 ...
- Codeforces Round #467 (div.2)
Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...
- Codeforces Round #510 (Div. 2)
Codeforces Round #510 (Div. 2) https://codeforces.com/contest/1042 A 二分 #include<iostream> usi ...
- Codeforces Round #486 (Div. 3) D. Points and Powers of Two
Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...
- Codeforces Round #296 (Div. 1) C. Data Center Drama 欧拉回路
Codeforces Round #296 (Div. 1)C. Data Center Drama Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xx ...
随机推荐
- Linux--Bind服务搭建
Bind域名解析服务 服务功能:提供域名解析 构建主从域名服务器 1)环境部署 ip=192.168.1.50(主) ip=192.168.1.51(从) [root@localhost Packag ...
- 诊断GRID无法启动问题
诊断 Grid Infrastructure 启动问题 (文档 ID 1623340.1)
- 从github下载一个单一文件
以ubuntu + wget为例 1) 浏览器中打开需要需要下载的文件 2) 点击 raw按钮 3) 从浏览器地址栏中拷贝地址 4) wget + 地址
- NO.001-2018.02.06《木兰花·拟古决绝词柬友》清代:纳兰性德
木兰花·拟古决绝词柬友原文.翻译及赏析_纳兰性德_古诗文网 木兰花·拟古决绝词柬友 清代:纳兰性德 人生若只如初见,何事秋风悲画扇.与意中人相处应当总像刚刚相识的时候,是那样地甜蜜,那样地温馨,那 ...
- thrift基本概念和实例
一.thrift可以做什么 thrift是一个跨语言通信的工具,支持的语言多,而且还提供服务器端的众多网络模型,使服务端的开发可以只专于服务本身的逻辑. 二.thrift重要概念 1.processo ...
- 学校管理系统设计java(数据库、源码、演讲内容、ppt等)
该系统使用java语言编写 获取班级项目展第二名 项目展示:https://www.bilibili.com/video/av27910081/?p=10 登录截图 git:https://githu ...
- 【luogu P2661 信息传递】 题解
题目链接:https://www.luogu.org/problemnew/show/P2661#sub 一种利用并查集求最小环的做法: 对于每个同学看作一个点,每次信息传递是一条有向边,当出现最小环 ...
- Android学习笔记_3_四种布局
Android布局是应用界面开发的重要一环,在Android中,共有四种布局方式, 分别是:FrameLayout( 帧布局 ).LinearLayout (线性布局).TableLayout(表格布 ...
- mobileeye
if a human can drive a car based on vision alone – so can a computer. 但是目前哪家能做到?
- SpringBoot非官方教程 | 第一篇:构建第一个SpringBoot工程
转载请标明出处: https://www.fangzhipeng.com/springboot/2017/07/11/springboot1 本文出自方志朋的博客 简介 spring boot 它的设 ...