2017ICPC/广西邀请赛1005(水)HDU6186
CS Course
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 593 Accepted Submission(s): 288
Today he has learned bit-operations in Algorithm Lessons, and he got a problem as homework.
Here is the problem:
You are giving n non-negative integers a1
,a
2
,⋯,a
n
, and some queries.
A query only contains a positive integer p, which means you
are asked to answer the result of bit-operations (and, or, xor) of all the integers except ap
.
Each test case begins with two positive integers n and p
in a line, indicate the number of positive integers and the number of queries.
2≤n,q≤105
Then n non-negative integers a1
,a
2
,⋯,a
n
follows in a line, 0≤ai
≤10
9
for each i in range[1,n].
After that there are q positive integers p1
,p
2
,⋯,p
q
in q lines, 1≤pi
≤n
for each i in range[1,q].
in a line.
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;
const int maxn= 1e5 + ;
const int inf = 0x3f3f3f3f;
typedef long long ll;
int n,m;
int sum1[maxn],sum2[maxn],sum3[maxn];
int rsum1[maxn],rsum2[maxn],rsum3[maxn];
int a[maxn];
int main(int argc, char const *argv[])
{
while(scanf("%d %d",&n,&m)==)
{
scanf("%d",&a[]);
sum1[]=sum2[]=sum3[]=a[];
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
sum1[i]=sum1[i-] & a[i];
sum2[i]=sum2[i-] | a[i];
sum3[i]=sum3[i-] ^ a[i];
}
rsum1[n]=rsum2[n]=rsum3[n]=a[n];
for(int i=n-;i>=;i--)
{
rsum1[i]=rsum1[i+] & a[i];
rsum2[i]=rsum2[i+] | a[i];
rsum3[i]=rsum3[i+] ^ a[i];
//cout<<rsum1[i]<<" "<<rsum2[i]<<" "<<rsum3[i]<<endl;
}
int q;
while(m--)
{
scanf("%d",&q);
if(q==)
printf("%d %d %d\n",rsum1[],rsum2[],rsum3[]);
else if(q == n)
printf("%d %d %d\n",sum1[n-],sum2[n-],sum3[n-]);
else
printf("%d %d %d\n",sum1[q-] & rsum1[q+],sum2[q-]|rsum2[q+],sum3[q-]^rsum3[q+]);
}
}
return ;
}
2017ICPC/广西邀请赛1005(水)HDU6186的更多相关文章
- 2017ICPC/广西邀请赛1001(水)HDU6181
A Math Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 2017 ICPC 广西邀请赛1005 CS Course
CS Course Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 2017ACM/ICPC广西邀请赛 1005 CS Course
CS Course Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 2017 ICPC 广西邀请赛1004 Covering
Covering Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 2017ACM/ICPC广西邀请赛-重现赛1005 CS course
2017-08-31 16:19:30 writer:pprp 这道题快要卡死我了,队友已经告诉我思路了,但是做题速度很缓慢,很费力,想必是因为之前 的训练都是面向题解编程的缘故吧,以后不能这样了,另 ...
- HDU 4847 陕西邀请赛A(水)
HDU 4847 Wow! Such Doge! pid=4847" style="">题目链接 题意:给定文本,求有几个doge,不区分大写和小写 思路:水题.直 ...
- 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi
Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...
- 2017ACM/ICPC广西邀请赛-重现赛 1010.Query on A Tree
Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learne ...
- 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering
Problem Description Bob's school has a big playground, boys and girls always play games here after s ...
随机推荐
- iOS APP跳转设置界面以及设置中的其他界面
1.跳转设置总页面(iOS10+以及之前的都可以用:ios10+ 是跳转到了应用到设置界面) [[UIApplication sharedApplication]openURL:[NSURL URLW ...
- 开源一个上架 App Store 的相机 App
Osho 相机是我独立开发上架的一个相机 App,App Store地址:https://itunes.apple.com/cn/app/osho/id1203312279?mt=8.它支持1:1,4 ...
- 【Uva623】500!(高精)
Description 求N! \(N \leq 1000\) Sample Input 10 30 50 100 Sample Output 10! 3628800 30! 265252859812 ...
- ORACLE环境变量设置
用oracle帐号登录,配置相关环境变量: vi .bash_profile export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=/u01/app ...
- vue 回到顶部的小问题
今天在用vue项目中,实现回到顶部功能的时候,我写了一个backTop组件,接下来需要通过监听window.scroll事件来控制这个组件显示隐藏 因为可能会有其他的组件会用到这样的逻辑,所以将此功能 ...
- Word+PS制作拼音表格
这几天,朋友让帮忙做个拼音表格,使用Word可以直接标注音标,却无法实现小时候那种4线3格,Word的模板只有练习书法的.使用Excel却,无法将拼音标注单独标注到上一单元格(有朋友会VBA的话,帮我 ...
- php curl 请求302跳转页面
今天对接支付接口,需要获取支付页面,发现支付商那边给的链接会发送302 跳转,最后发现该方法,绝对给力: <?php $url = 'http://auto.jrj.com.cn/'; $ch ...
- Xamarin.Forms (Android制作启动画面)
http://blog.csdn.net/zapzqc/article/details/38496117 Xamarin.Forms 在启动的时候相当慢,必须添加一个启动界面,步骤如下: 1. ...
- javascript计算对象的长度
计算对象的长度,即获取对象属性的个数 方法一:通过for in 遍历对象,并通过hasOwnProperty判断是否是对象自身可枚举的属性 var obj = {"c1":1,&q ...
- S2 深入.NET和C#编程 一: 深入C#.NET框架
深入C#.NET框架 1..NET框架 之一 推荐一个代码管理平台,博客发布平台 git 之前的复习: 学习的网站: git github.com 2.类和对象的关系 Dept de ...