主页
试题仓库
题目列表
试题分类
经典教材
作业竞赛
作业列表
判题队列
图灵学院
TuringMOOC
图灵书屋
图灵商城
图灵实验室
图灵会员
荣誉成绩
捐赠支持
图灵云编译器
用户/排名
AOJ排名
实名认证
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem 2958 --6.1.3 Cow XOR
2958: 6.1.3 Cow XOR
上一题
正确率: $0.00\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$0$
正确数量
$0$
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
usaco
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
usaco
单击选择分类:
Description
Farmer John is stuck with another problem while feeding his cows. All of his N (1 ≤ N ≤ 100,000) cows (numbered 1..N) are lined up in front of the barn, sorted by their rank in their social hierarchy. Cow #1 has the highest rank; cow #N has the least rank. Every cow had additionally been assigned a non-unique integer number in the range 0..(221 - 1). Help FJ choose which cows will be fed first by selecting a sequence of consecutive cows in the line such that the bitwise "xor" between their assigned numbers has the maximum value. If there are several such sequences, choose the sequence for which its last cow has the highest rank. If there still is a tie, choose the shortest sequence. PROGRAM NAME: cowxor
Input
INPUT FORMAT Line 1: A single integer N Lines 2..N+1: N integers ranging from 0 to 221 - 1, representing the cows' assigned numbers. Line j describes cow of social hierarchy j-1.
Output
There are 5 cows. Cow #1 had been assigned with 1; cow #2 with 0; cow #3 with 5; cow #4 with 4; cow #5 with 2.
Sample Input
5 1 0 5 4 2
Sample Output
6 4 5
提示
4 xor 2 = 6 (001) xor (010) = (011)
推荐代码
查看2958 所有题解
上传题解视频得图灵币
本题记录
用 户(点击查看用户)
运行号(点击购买题解)
时 间
算法最快[$0 $ms]
0
内存最少[$0 $KB]
0
第一AC
0
第一挑战
0
赛题来源
usaco training
usaco Training
登录后提交代码
题面与样例可直接查看,登录后即可在线提交和评测。
前往登录