zoukankan      html  css  js  c++  java
  • BZOJ1923: [Sdoi2010]外星千足虫

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1923

    高斯消元。

    (bitset好优越啊。。

    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<queue>
    #include<bitset>
    #define rep(i,l,r) for (int i=l;i<=r;i++)
    #define down(i,l,r) for (int i=l;i>=r;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define maxn 2005
    using namespace std;
    bitset<1005> a[2005]; 
    int n,m,l,r,ans;
    char s[maxn];
    int read(){
        int x=0,f=1; char ch=getchar();
        while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
        while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
        return x*f;
    }
    void gs(){
        rep(i,1,n){
            int now=i;
            while (now<=m&&a[now][i]==0) now++;
            ans=max(ans,now);
            if (now==m+1) {ans=-1; return;}
            swap(a[now],a[i]);
            rep(j,1,m) if (i!=j&&a[j][i]) a[j]^=a[i];
        }
    }
    int main(){
        n=read(); m=read();
        rep(i,1,m){
            scanf("%s",s); a[i][n+1]=read();
            rep(j,1,n) a[i][j]=s[j-1]-'0';
        }
        gs();
        if (ans==-1) puts("Cannot Determine");
        else {
            printf("%d
    ",ans);
            rep(i,1,n) if (a[i][n+1]) puts("?y7M#");
            else puts("Earth");
        }
        return 0;
    }
  • 相关阅读:
    JAVA多线程实现和应用总结
    大话程序猿眼里的高并发
    重写Dijkstra
    再做一遍floyed
    优美的二分模型
    ACwing : 798. 差分矩阵
    ACwing_789. 数的范围
    快速排序超级强的模板
    1829:【02NOIP提高组】自由落体
    【02NOIP提高组】均分纸牌
  • 原文地址:https://www.cnblogs.com/ctlchild/p/5055048.html
Copyright © 2011-2022 走看看