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. 实验,暂停oracle后台进程

    有时出于测试需求,需要暂停oracle的某些后台进程,此时以暂停lgwr进程为例 使用sysdba连接到数据库查询到LGWR进程的PID:SQL> select prc.pid from v$b ...

  2. 为什么A经理的团队总是会陷入加班与救火之中

    最近在看一本名为<稀缺>的书,作者从行为经济学的角度解释了穷人为什么会更穷,忙碌的人越来越没有时间,节食的人总是失败.由于缺乏闲余导致的带宽负担会进一步导致稀缺,由于总是优先处理紧急的事情 ...

  3. Ubuntu 12.04 安装Chrome步骤

    一.添加PPA 从Google Linux Repository(http://www.google.com/linuxrepositories/)下载安装Key,或把下面的代码复制进终端,回车,需要 ...

  4. nginx安装和基础代理配置

    mac上执行 npm install nginx 安装好后运行nginx sudo nginx 一般mac下nginx会安装在 /usr/local/etc/nginx 下 里面的nginx.conf ...

  5. 最短路算法 —— Dijkstra算法

    用途: 解决单源最短路径问题(已固定一个起点,求它到其他所有点的最短路问题) 算法核心(广搜): (1)确定的与起点相邻的点的最短距离,再根据已确定最短距离的点更新其他与之相邻的点的最短距离. (2) ...

  6. Entity Framework 一

    本篇主要介绍:EntityFramework简介, 实体框架架构图, EF版本 实体框架: 编写和管理数据访问的ADO.Net代码是一件单调乏味的工作.微软已经提供了一个名为“实体框架”的O / RM ...

  7. html、css和js原生写一个模态弹出框,顺便解决父元素半透明子元素不透明效果

    模态框: html部分: <!-- 按钮 --> <button id="box" onclick="pop_box()">弹出框< ...

  8. mysql 复制A表 到B表;insert into select * from table

    情况一: INSERT INTO tb1 (a,b,c) select a1,b1,c1, from tb2 where .... --  案例 百度云 INSERT INTO l_biz_car_o ...

  9. IOS 浅谈闭包block的使用

    前言:对于ios初学者,block通常用于逆向传值,遍历等,会使用,但是可能心虚,会感觉block很神秘,那么下面就一起来揭开它的面纱吧. ps: 下面重点讲叙了闭包的概念,常用的语法,以及访问变量, ...

  10. Redis工具之Jedis

    //jedis的连接池 public void test1(){ //创建连接池配置对象 JedisPoolConfig poolConfig = new JedisPoolConfig(); poo ...