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的更多相关文章

  1. Codeforces Round #500 (Div. 2) [based on EJOI]

    Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...

  2. Codeforces Round 500 (Div 2) Solution

    从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemica ...

  3. Codeforces Round#500 Div.2 翻车记

    A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...

  4. Codeforces Round #500 (Div. 2) D - Chemical table

    首先我们如果满足三缺一,那么必有同行和同列的点 如果两行有同列的数,我们可以设想,他们最后会全部填充成为两者啥都有的情况 显然这个是个并查集 现在我们有了很多集合,每个集合自己可以进行三缺一操作,但是 ...

  5. Codeforces Round #421 (Div. 1) (BC)

    1. 819B Mister B and PR Shifts 大意: 给定排列$p$, 定义排列$p$的特征值为$\sum |p_i-i|$, 可以循环右移任意位, 求最小特征值和对应移动次数. 右移 ...

  6. Codeforces Round #467 (div.2)

    Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...

  7. Codeforces Round #510 (Div. 2)

    Codeforces Round #510 (Div. 2) https://codeforces.com/contest/1042 A 二分 #include<iostream> usi ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. RAC修改spfile位置

    RAC修改spfile位置    [root@rac1 ~]# su - oracle  [oracle@rac1 ~]$ sqlplus  / as sysdba  SQL*Plus: Releas ...

  2. 一个简单的例子理解Kubernetes的三种IP地址类型

    很多Kubernetes的初学者对Kubernetes里面三种不同的IP地址和工作机制理解得不是很清楚. 本文我们通过一个最简单的例子来学习. 用如下命令行创建一个基于nginx的deployment ...

  3. SpringCloud实战3-Hystrix请求熔断与服务降级

    我们知道大量请求会阻塞在Tomcat服务器上,影响其它整个服务.在复杂的分布式架构的应用程序有很多的依赖,都会不可避免地在某些时候失败.高并发的依赖失败时如果没有隔离措施,当前应用服务就有被拖垮的风险 ...

  4. robotframework_如何用Chrome模拟手机打开H5页面

    由于公司目前的产品大部分都是APP端的H5页面,APP原生页面很少,测试H5页面如果去搭建appium或者macaca这类自动化平台太费时,太重而不能快速落地:与自动化的目标:提高测试效率相悖.但如果 ...

  5. nautilus命令

    nautilus 是图形程式效果是以当前用户打开图形界面所以如果想以root打开图形界面使用时记得先切为root,sudo没有用的

  6. Django:模板系统

    一,常用语法 只需要记两种特殊符号: {{  }}和 {% %} 变量相关的用{{}},逻辑相关的用{%%}. 二,常量 {{ 变量名 }} 变量名由字母数字和下划线组成. 点(.)在模板语言中有特殊 ...

  7. 用jquery写的json省市县三级联动下拉

    <form action="#" name="myform"> <label>省</label><select nam ...

  8. 【洛谷P3389】(模板)高斯消元

    对于高斯消元法求解线性方程组, 我的理解就类似于我们在做数学题时的加减消元法, 只是把它写成一个通用的程序运算过程 对于一个线性方程组,我们从左往右每次将一列对应的行以下的元通过加减消元消去, 每个元 ...

  9. 【题解】洛谷P1731 [NOI1999] 生日蛋糕(搜索+剪枝)

    洛谷P1731:https://www.luogu.org/problemnew/show/P1731 思路 三重剪枝 当前表面积+下一层表面积如果超过最优值就退出 当前体积+下一层体积如果超过总体积 ...

  10. sql server 自增长显式添加值

    如果想在自增列添加数据,会提示我们不能插入显式值 解决: