CF193B Xor

sol:发现好像非常不可做的样子,发现n,u都很小,大胆dfs,因为异或偶数次毫无卵用,只要判每次是否做2操作就是了,复杂度O(可过)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
ll s=; bool f=; char ch=' ';
while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
while(isdigit(ch)) {s=(s<<)+(s<<)+(ch^); ch=getchar();}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<) {putchar('-'); x=-x;}
if(x<) {putchar(x+''); return;}
write(x/); putchar((x%)+'');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
const ll inf=0x7fffffffffll;
int n,m,r;
ll ans,a[N],b[N],k[N],p[N];
inline ll calc(ll num[])
{
int i;
ll res=;
for(i=;i<=n;i++) res+=1LL*num[i]*k[i];
return res;
}
inline void dfs(ll num[],int step)
{
if(step==)
{
ans=max(ans,calc(num)); return;
}
int i;
ll c[N],d[N];
for(i=;i<=n;i++) c[i]=num[i]^b[i];
if(step&) ans=max(ans,calc(c)); else ans=max(ans,calc(num));
for(i=;i<=n;i++) d[i]=num[p[i]]+r;
dfs(d,step-);
if(step<) return;
for(i=;i<=n;i++) d[i]=c[p[i]]+r;
dfs(d,step-);
}
int main()
{
int i;
R(n); R(m); R(r); ans=-inf;
for(i=;i<=n;i++) R(a[i]);
for(i=;i<=n;i++) R(b[i]);
for(i=;i<=n;i++) R(k[i]);
for(i=;i<=n;i++) R(p[i]);
dfs(a,m);
Wl(ans);
return ;
}
 

codeforces193B的更多相关文章

随机推荐

  1. C#使用任务并行库(TPL)

    TPL(Task Parallel Library) 任务并行库 (TPL) 是 System.Threading和 System.Threading.Tasks 命名空间中的一组公共类型和 API. ...

  2. js基本用法

    1. 在HTML里面加入JavaScript 方法非常简单,就是通过一对<script></script>标签,然后在标签里面书写代码即可 2. 标签位置 按照以前传统的方法, ...

  3. WinForm 无焦点获取键盘输入

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. CentOS 6.x 配置iptables

    CentOS 6.x 配置iptables 来源 https://www.cnblogs.com/chillax1314/p/7976067.html iptables -P INPUT DROP-- ...

  5. Java构建器(多个构造器参数)

    今天看netty权威指南,第一次听说构建器,百度了几个博客,但是并没有通俗易懂一点儿的,综合别人的博客,总结如下: 1. 构建器是什么? 当创建对象需要传入多个参数的时候我们通常会根据参数的数量写不同 ...

  6. 学习笔记之Google

    Google Pro Tip: Use Back-of-the-envelope-calculations to Choose the Best Design - High Scalability - ...

  7. vue中修改第三方组件的样式并不造成污染

    vue引用了第三方组件, 需要在组件中局部修改第三方组件的样式, 而又不想去除scoped属性造成组件之间的样式污染. 此时只能通过>>>,穿透scoped. 但是,在sass中存在 ...

  8. HTML标签认识一

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. BPM FlowPortal 开发环境及发布环境的配置

    开启开发模式 开发时应设置防缓存和调试信息输出. 开发后发布 开发完成后正式使用时,除了对以上各项做相反设置外,还需设置web.config中的JSVersion,使每个用户都能自动下载最新版的js文 ...

  10. vue简单todolist

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...