zoukankan      html  css  js  c++  java
  • bzoj3668: [Noi2014]起床困难综合症

    水题。

    按位处理,复杂度O(nlogm)。真心好看。。。。。

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    const int maxn = 100000 + 10;
    
    int n,m,k,l,f1,f2,res;
    char s[20];
    int op[maxn],t[maxn];
    
    inline int calc(int f,int i) {
        if(op[i]==1) f&=t[i];
        else if(op[i]==2) f|=t[i];
        else f^=t[i];
        return f;
    }
    
    void solve() {
        k=m; l=0;
        while(k) {k/=2; l++;};
        for(int i=l-1;i>=0;i--) {
            f1=(1<<i);
            f2=0;
            for(int j=1;j<=n;j++) {
                f1=calc(f1,j);
                f2=calc(f2,j);
            }
            f1&=(1<<i);
            f2&=(1<<i);
            if(f1>f2 && (res|(1<<i))<=m) res|=(1<<i);
        }
        for(int i=1;i<=n;i++) res=calc(res,i);
        printf("%d
    ",res);
    }
    
    
    int main() {
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) {
            scanf("%s%d",s,&t[i]);
            if(s[0]=='A') op[i]=1;
            else if(s[0]=='O') op[i]=2;
            else op[i]=3;
        }
        solve();
        return 0;
    }
  • 相关阅读:
    uIP的ARP协议分析
    如何使函数不生成执行代码
    计算机网络基础
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
  • 原文地址:https://www.cnblogs.com/invoid/p/5615845.html
Copyright © 2011-2022 走看看