1847C-Vampiric Powers, anyone?

题目链接:Vampiric Powers, anyone?

从题目意思我们可以推测出这是一道求最大连续子异或和的题目,那么一般情况来讲要枚举l,r两端,时间复杂度为n^2,超时了,所以我们考虑一下优化,那么想到最多a为2^8那么因此我们可以采用桶来存储,首先求出所有数的异或前缀和,那么我们要求的答案就是xi^xj(表示任意两个异或前缀和的异或值),然后将所有的异或前缀和加入到桶当中,遍历数组,然后再遍历桶(记住:不能遍历两次桶,因为多组测试数据会tle),如果桶中的数存在,那么就比较大小。

代码附上:

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+5;
int a[N];
int vis[N];
int pre[N];
int n;

void solve(){
	cin>>n;
	for(int i=0;i<(1<<9);i++)vis[i]=0;
	for(int i=0;i<=n;i++){
		pre[i]=0;
	}
	for(int i=1;i<=n;i++)cin>>a[i];
	vis[0]++;
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]^a[i];
		vis[pre[i]]++;
	}
	int max1=0;
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<(1<<9);j++){
			if(vis[j]){
				max1=max(max1,pre[i]^j);
				//cout<<"i="<<pre[i]<<" j="<<j<<"\n";
			}
		}
	}

	cout<<max1<<"\n";

}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--){
		solve();
	}

	return 0;
}

  • 19
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dungeons & Dragons 5th Edition中,邪术师法术列表如下: 1级法术: - 奥术飞弹 (Magic Missile) - 色彩喷射 (Color Spray) - 魔法护盾 (Mage Armor) - 魔法导师 (Find Familiar) - 魔法探测 (Detect Magic) - 魔法钥匙 (Unseen Servant) 2级法术: - 暗示 (Suggestion) - 模糊术 (Blur) - 魔法伪装 (Invisibility) - 魔法陷阱 (Arcane Lock) - 魔法探测和识别 (Detect Thoughts) - 魔法书 (Book of Shadows) 3级法术: - 魔法圆盘 (Magic Circle) - 魔法弹幕 (Melf's Minute Meteors) - 魔法箭雨 (Conjure Barrage) - 魔法降咒 (Counterspell) - 魔法眼 (Clairvoyance) - 魔法武器 (Magic Weapon) 4级法术: - 死亡之触 (Vampiric Touch) - 魔法墙 (Wall of Fire) - 魔法脚步 (Dimension Door) - 魔法魅惑 (Charm Monster) - 魔法圆盘控制 (Control Water) - 魔法幻象 (Hallucinatory Terrain) 5级法术: - 空间置换 (Teleportation Circle) - 魔法守护 (Wall of Force) - 魔法掌控 (Dominate Person) - 魔法气息 (Modify Memory) - 魔法传送 (Teleport) - 魔法死亡 (Cone of Cold) 6级法术: - 魔法宝箱 (Create Undead) - 魔法暴风雨 (Investiture of Ice) - 魔法脉冲 (Disintegrate) - 魔法掌控怪物 (Mass Suggestion) - 魔法传送门 (Arcane Gate) - 魔法视野 (True Seeing) 7级法术: - 魔法风暴 (Whirlwind) - 魔法永恒之火 (Delayed Blast Fireball) - 魔法控制亡灵 (Finger of Death) - 魔法掌控巨龙 (Power Word Pain) - 魔法掌控元素 (Control Weather) - 魔法虚实之门 (Etherealness) 8级法术: - 魔法复制 (Clone) - 魔法地震 (Earthquake) - 魔法恶魔 (Summon Greater Demon) - 魔法掌控人 (Dominate Monster) - 魔法突袭 (Teleportation Circle) - 魔法防卫 (Antimagic Field) 9级法术: - 魔法复活 (Raise Dead) - 魔法天灾 (Meteor Swarm) - 魔法地狱 (Gate) - 魔法掌控生命 (Power Word Kill) - 魔法机遇 (Foresight) - 魔法时间停止 (Time Stop) 以上是邪术师在D&D 5E中可用的法术列表,可以根据实际需要进行选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值