Codeforces Round #399 (Div. 1 + Div. 2, combined)C. Jon Snow and his Favourite Number

unity打包流程整理-Windows/Mac/Linux平台 1.Platform(平台)功能: 选择目标构建的目标平台选项PC, Mac & Linux Standalone: 适用于 Windows、Mac 和 Linux 平台2.Target Platform(目标平台)功能: 选择具体的操作系统版本选项Windows: 针对 Windows 操作系统Mac: 针对 macOS 操作系统Linux: 针对 Linux 操作系统3.Architecture(架构)功能: 选择应用程序的目标处理器架构选项x86: 针对 32 位系统。 阅读详情

C. Jon Snow and his Favourite Number
time limit per test
4 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:

  1. Arrange all the rangers in a straight line in the order of increasing strengths.
  2. Take the bitwise XOR (is written as ) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
  1. The strength of first ranger is updated to , i.e. 7.
  2. The strength of second ranger remains the same, i.e. 7.
  3. The strength of third ranger is updated to , i.e. 11.
  4. The strength of fourth ranger remains the same, i.e. 11.
  5. The strength of fifth ranger is updated to , i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]

Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?

Input

First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.

Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).

Output

Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.

Examples
input
5 1 2
9 7 11 15 5
output
13 7
input
2 100000 569
605 986
output
986 605

因为ai的范围很小,所以可以通过记录每个数的个数来记录这个序列,能想到这样做基本就可以了

然后模拟k次,每次从0开始,一直到1024(因为最大是1000,异或之后可能出现的最大值是1024),根据每个数前面已经出现了几个可以判断这个数第一次出现在按从小到大的排序的序列里是否为第奇数个

例如  1 1 2 2 2 3 3 3

有两个1,并且前面没有任何数,所以这两个1里有一个要异或x,一个不变,三个2,,2前面有两个数,所以第一个2是位于奇数的位置,这三个2里有两个要异或x,一个不变,

三个3,而第一个3是位于偶数的位置,所以三个3里只有一个要异或x

#include<stdio.h>
#include<string.h> 
#include<algorithm>
using namespace std;
#define MEM(a) memset(a,0,sizeof(a));
#define res(i,be,n) for(i=be;i<n;i++)
int main()
{
	int n,x,k,a[1030],b[1030],t,i,j,re;
	scanf("%d %d %d",&n,&k,&x);
	MEM(a);
	MEM(b);
	res(i,0,n)
	{
		scanf("%d",&j);
		a[j]++;
	}
	res(i,0,k)
	{
		t=0;
		res(j,0,1025)
		{
			b[j]=a[j];
		}
		MEM(a);
		res(j,0,1025)
		{
			re=(b[j]+!(t&1))/2;
			a[j^x]+=re;
			a[j]+=b[j]-re;
			t+=b[j];
		}
	}
	int maxx=0,minn=1024;
	res(i,0,1025)
	if(a[i])
	{
		maxx=max(maxx,i);
		minn=min(minn,i);
	}
	printf("%d %d\n",maxx,minn);
	return 0;
}




神经网络基础概念总结(小白入门自用) 神经网络人工神经网络多层感知机激活函数反向传播算法损失函数权值初始化正则化方法 人工神经网络 人工神经元:人工神经元是人工神经网络的基本单元。模拟生物神经元,人工神经元有1个或者多个输入(模拟多个树突或者多个神经元向该神经元传递神经冲动);对输入进行加权求和(模拟细胞体将神经信号进行积累和树突强度不同);对输入之和使用激活函数计算活性值(模拟细胞体产生兴奋或者抑制);输出活性值并传递到下一个人工神经元(模拟生物神经元通过轴突将神经冲动输入到下一个神经元)。 人工神经网络:大量的人工神经元以某种链接方式得来的 阅读详情

相关推荐

夏令营纪实——东南大学计科院&PALM实验室面试全解析

本文详细解析了东南大学计科院与PALM实验室夏令营的面试全流程,包括前期准备、技术考察、项目经验深挖等关键环节。特别针对自然语言处理(NLP)和机器学习(ML)领域的高频问题提供应对策略,帮助申请者提升面试表现。文章还分享了实用的准备技巧和面试经验,为有意向参加该夏令营的学生提供宝贵参考。

convnet3designer的博客 459

Codeforces 768C Jon Snow and his Favourite Number

C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fi

你那么爱笑,家里人知道吗? 2239

四阶龙格库塔法求解一次常微分方程组(python实现)

之前在博客发布了关于使用四阶龙格库塔方法求解一次常微分方程组的文章,由于代码缺少具体的验证,部分朋友可能存在疑问,因此这里打算再重新写一篇博客来验证一下程序的正确性,另外,这里是使用python语言来实现的。

HelloWorldTM的博客 8543

(打表找循环节)CodeForces - 768C Jon Snow and his Favourite Number

C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with W

PiKa__Qiu的博客 618

S32K344开发环境搭建全攻略:S32DS 3.5.12与RTD 3.0.0实战指南

在嵌入式开发中,集成开发环境(IDE)与实时驱动(RTD)的协同配置是项目启动的关键。S32DS作为NXP官方IDE,结合RTD包,为S32K3系列提供底层驱动支持。正确安装与路径配置能确保编译、调试与烧录流程顺畅,避免常见错误。该环境适用于汽车电子、工业控制等场景,如车身域控、BMS。本文基于S32K344芯片,详细记录从软件下载到调试的完整过程,帮助开发者快速搭建稳定开发环境。

weixin_42713608的博客 211

TSmaster CANFD配置避坑指南:为什么你的PCAN盒不支持最新版本?

本文针对TSmaster配置PCAN硬件进行CANFD通信时的常见问题,提供了详细的避坑指南。重点解析了CANFD配置中TSEG1等关键参数的理解误区,并深入探讨了TSmaster新版本与PCAN硬件驱动之间的兼容性变化,帮助工程师快速定位并解决连接失败或无法发送CANFD报文等问题。

alpha的博客 542

【Codeforces】835B The number on the board (贪心)

把所有字符串上的数字加起来,看是否超过k,没有超过k的话,把字符串sort,从第一位开始,将字符变成9,直到sum大于等于k为止。 #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; typede...

( :3 ) 252

各种AI的调试日记——辅助工作篇

记录使用各种AI(语言大模型)的心得和总结

m0_73056986的博客 1391

C. Jon Snow and his Favourite Number

C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fi

樱花满地集于我心,楪舞纷飞祈愿相随 1058

以LAN8720A为例的以太网硬件设计方案

输入时钟(XTAL1/CLKIN,XTAL2):推荐外加25MHz(性价比较高)晶振为PHY芯片提供时钟,PHY芯片内部PLL将其倍频为50MHz来使用,亦可使用直接使用50MHz晶振。三位MODE通过高低电平组合分别对应以上8种模式 ,包含10M半双工,10M全双工,100M半双工,100M全双工,是否启用自协商协议,CRS是否有效等。VDDCR:1.2V电源,可由芯片内部稳压电源提供,亦可由外部电源提供,由外部电源提供可降低芯片功耗。REF_CLK:参考时钟,由MAC或外部时钟晶振向PHY芯片提供。

weixin_46154042的博客 5884

【大模型】DeepSeek + Coze 打造个人专属AI智能体使用详解

DeepSeek + Coze 打造个人专属AI智能体使用详解

congge 1万+

H - Vasya and Robot

Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0)(0,0) . Robot can perform the following four kinds of operations: U — move from (x,y)(x,y) to (x,y+1...

qq_42865713的博客 250

基于 YOLOv26 的陶瓷产品缺陷检测系统:智能视觉质检方案

本文提出了一种基于YOLOv26深度学习模型的陶瓷产品智能缺陷检测系统。该系统针对陶瓷生产中的裂纹、气泡、釉面缺陷等8类常见质量问题,采用YOLOv26目标检测算法实现高精度自动化检测。系统架构包含数据采集、预处理、YOLOv26检测和后处理四个模块,具有多类别分类、实时推理和强鲁棒性等技术优势。文章详细介绍了数据预处理与增强方法,并提供了Python代码实现示例。该方案可显著提升陶瓷产品质量检测效率,替代传统人工检测方式,为陶瓷制造业提供智能化质检解决方案。

一键难忘的博客 788

Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favou

树形dp

我们仍未知道那天所看见的花的名字。 124

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes

A. Ostap and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On the way to Rio de Janeiro Ostap

jerans的博客 1287

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Gym - 101128C Canvas Painting 逆向思维

https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337 刚开始读错题意,以为是不变序列,就想着区间dp但数据量肯定会t,,,没想到什么优化方法就放下了,后来队员发现序列是可变的。。。。任意的。。。。。 想着先排序在布拉布拉布拉,一直都没有逆向思维想到哈夫曼。只怪数据结构没认真听啊。。。。 想到哈夫

jerans的博客 945

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

CodeForces - 361D Levko and Array二分加dp

D. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of inte

jerans的博客 840

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞

C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arkady plays Gardenscapes a lot. Arkady wants

jerans的博客 810

codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon

D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output PolandBall has such a convex poly

jerans的博客 726

B. The Meeting Place Cannot Be Changed

B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Byt

jerans的博客 695

Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//

C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service

jerans的博客 684

Beautiful numbers CodeForces - 55D 数位dp

D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is

jerans的博客 676

Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造

C:http://codeforces.com/contest/828/problem/C 题意:有一个字符串,你知道他的一些子串所在的位置,求符合条件的字典序最小的原串 因为已知的数据较大,还存在较多重复的部分,直接暴力不可行 可以记录原串每个位置的下一个没确定出来的字符的位置(记住next【i】),优化后可以过,时间较长 #include #define eps 1e-9 #defin

jerans的博客 672

Codeforces Round #410 (Div. 2) C. Mike and gcd problem 贪心

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

jerans的博客 662

Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率dp

D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bad Luck Island is inhabited by thre

jerans的博客 648

Codeforces Round #424 (Div. 2)C. Jury Marks 暴力 D. Office Keys 二分 E. Cards Sorting 树状数组

C:http://codeforces.com/contest/831/problem/C。 题意:给两个序列a和b 有一个初始值,不断的加ai,要求是在加的过程中b的所有值都出现过,求这样满足条件的初始值有几个。 崩了,这么水的暴力竟然没想出来?? 先把所有的b值标记出来,随便选一个b,暴力放到某一个a后面,这样就可以直接找出原序列,看看b数组里的值是不是都出现过,如果出现过则这个序列满

jerans的博客 632
上一篇: Codeforces Round #398 (Div. 2) D. Cartons of milk
下一篇: Codeforces Round #398 (Div. 2) B. The Queue
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值