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. google Cayley图谱数据库初试

    一.安装 mkdir cayley cd cayley mkdir src export GOPATH=$(pwd) go get github.com/google/cayley go build ...

  2. 成都夏季招聘会IT行业缺口大!

    上个周末成都的夏季招聘会在新会展中心举行,我们传智播客的专业市场调查员也深入当中.了解IT行业招聘情况,我们发如今IT软件行业专区招聘的公司特别多,可是去应聘的人却非常少.这意味着IT行业正处于供不应 ...

  3. 围绕react衍生出来的思考

    优势一.声明式开发 首先react是声明式的开发方式,这个与之对应的是命令式开发方式,之前在用jquery写代码的时候,都是直接来操作dom,直接操作dom的这种编程方式,我们把他叫做命令式的编程,也 ...

  4. hack-checkbox

    checkbox选择按钮要用我们自己的样式,看到这个的时候,很可能会以为需要checkbox才能实现,用css可能很难.其实狠简单. <style> .checkbox input{ di ...

  5. HDU 5025 Saving Tang Monk 【状态压缩BFS】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Time Limit: 2000/1000 MS (Java/O ...

  6. 效率对比:各种语言构造100W个时间对象

    原本是用perl写了一个通过给定的时间范围来筛选一个比较大的日志文件.但是测试发现筛选130W行日志需要2分多钟,对其中几个低效率函数单独进行了效率测试,发现构造100W个时间对象所花时间也是个大户. ...

  7. json 二进制传输方案

    json 传输二进制数组方案 json 是一种很简洁的协议,但可惜的是,它只能传递基本的数型(int,long,string等),但不能传递byte类型.如果想要传输图片等二进制文件的话,是没办法直接 ...

  8. 【luogu P3884 [JLOI2009]二叉树问题】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3884 对方不想和你说话并向你扔了一个lca模板. #include <cstdio> #incl ...

  9. 【题解】POJ1845 Sumdiv(乘法逆元+约数和)

    POJ1845:http://poj.org/problem?id=1845 思路: AB可以表示成多个质数的幂相乘的形式:AB=(a1n1)*(a2n2)* ...*(amnm) 根据算数基本定理可 ...

  10. [译]GLUT教程 - 安装

    Lighthouse3d.com >> GLUT Tutorial >> Basics >> Setup 你需要什么 要用GLUT库开发程序,你可以下载最新版本3. ...