标签:syn == code its pre lse sync space freopen
题解:
水题
从高位向低位考虑
能0-->1则0 否则能1-->1则1
洛谷有毒啊。。。它评测机的输出和用洛谷IDE的都不一样。。。
明明是和答案一样的。。。
bzoj过了
代码:
#include <bits/stdc++.h> using namespace std; #define N 200000 char c[10]; int x[N],y[N],n,m; int js(int x1,int x2) { for (int i=1;i<=n;i++) { int tmp1=(y[i]>>(x2-1))&1; if (x[i]==1) x1=x1&tmp1; if (x[i]==2) x1=x1|tmp1; if (x[i]==3) x1=x1^tmp1; } return(x1); } int main() { freopen("noi.in","r",stdin); freopen("noi.out","w",stdout); //std::ios::sync_with_stdio(false); cin>>n>>m; for (int i=1;i<=n;i++) { cin>>c; if (c[0]==‘A‘) x[i]=1; if (c[0]==‘O‘) x[i]=2; if (c[0]==‘X‘) x[i]=3; cin>>y[i]; } int ans=0,now; for (int i=30;i;i--) { int a=js(1,i); int b=js(0,i); if (b==1) { ans+=(1<<(i-1)); } else if (a==1&&now+(1<<(i-1))<=m) { ans+=(1<<(i-1)); now+=(1<<(i-1)); } } cout<<ans; return 0; }
标签:syn == code its pre lse sync space freopen
原文地址:https://www.cnblogs.com/yinwuxiao/p/8810412.html