codeforces193B

Posted gaojunonly1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces193B相关的知识,希望对你有一定的参考价值。

CF193B Xor

技术图片

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

技术图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()

    ll s=0; bool f=0; char ch= ;
    while(!isdigit(ch))    f|=(ch==-); ch=getchar();
    while(isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
    return (f)?(-s):(s);

#define R(x) x=read()
inline void write(ll x)

    if(x<0) putchar(-); x=-x;
    if(x<10) putchar(x+0); return;
    write(x/10); putchar((x%10)+0);

#define W(x) write(x),putchar(‘ ‘)
#define Wl(x) write(x),putchar(‘\\n‘)
const int N=35;
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=0;
    for(i=1;i<=n;i++) res+=1LL*num[i]*k[i];
    return res;

inline void dfs(ll num[],int step)

    if(step==0)
    
        ans=max(ans,calc(num)); return;
    
    int i;
    ll c[N],d[N];
    for(i=1;i<=n;i++) c[i]=num[i]^b[i];
    if(step&1) ans=max(ans,calc(c)); else ans=max(ans,calc(num));
    for(i=1;i<=n;i++) d[i]=num[p[i]]+r;
    dfs(d,step-1);
    if(step<2) return;
    for(i=1;i<=n;i++) d[i]=c[p[i]]+r;
    dfs(d,step-2);

int main()

    int i;
    R(n); R(m); R(r); ans=-inf;
    for(i=1;i<=n;i++) R(a[i]);
    for(i=1;i<=n;i++) R(b[i]);
    for(i=1;i<=n;i++) R(k[i]);
    for(i=1;i<=n;i++) R(p[i]);
    dfs(a,m);
    Wl(ans);
    return 0;
View Code

 

 

 

 

以上是关于codeforces193B的主要内容,如果未能解决你的问题,请参考以下文章

codeforces 193 D Two Segments

CodeForces 193D. Two Segments线段树

Codeforces Round #524 (Div. 2) codeforces 1080A~1080F

浴谷夏令营题单

CS193P 作业 3,提示#5 - 型号是啥?

Netbeans C++ 错误:193