BZOJ 1923: [Sdoi2010]外星千足虫

Posted ZlycerQan

tags:

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

二次联通门 : BZOJ 1923: [Sdoi2010]外星千足虫

 

 

 

 

 

/*
    BZOJ 1923: [Sdoi2010]外星千足虫

    高斯消元解异或方程组

    模板题来一发
*/
#include <cstdio>
#include <iostream>
#include <bits/stdc++.h>
#define Max 2005
std :: bitset <1005> a[Max];
#define rg register
char s[Max];
inline void read (int &n)
{
    rg char c = getchar ();
    for (n = 0; !isdigit (c); c = getchar ());
    for (; isdigit (c); n = n * 10 + c - 0, c = getchar ());
}
int Answer;
inline void cmax (int &a, int b) { if (b > a) a = b; }
void Gauss (int N, int M)
{
    rg int i, j, n = 0, k;
    for (i = 1; i <= N; ++ i)
    {
        for (j = n + 1; !a[j][i] && j <= M; ++ j);
        if (j == M + 1) { Answer = -1; return ; }
        else cmax (Answer, j);
        for (++ n, std :: swap (a[j], a[n]), k = 1; k <= M; ++ k)
            if (k != n && a[k][i]) a[k] ^= a[n];
    }            
}
int main (int argc, char *argv[])
{
    int N, M, x; read (N), read (M); rg int i, j;
    for (i = 1; i <= M; ++ i)
    {
        scanf ("%s", s + 1);
        for (j = 1; j <= N; ++ j) a[i][j] = s[j] - 0;
        read (x); a[i][N + 1] = x;
    }
    Gauss (N, M);
    if (Answer != -1)
    {
        std :: cout << Answer << std :: endl;
        for (i = 1; i <= N; ++ i)
            if (a[i][N + 1]) puts ("?y7M#");
            else puts ("Earth");
    }
    else puts ("Cannot Determine");
    return 0;
}

 

以上是关于BZOJ 1923: [Sdoi2010]外星千足虫的主要内容,如果未能解决你的问题,请参考以下文章

bzoj 1923: [Sdoi2010]外星千足虫

BZOJ1923: [Sdoi2010]外星千足虫

bzoj1923 [Sdoi2010]外星千足虫

bzoj1923 [Sdoi2010]外星千足虫

bzoj 1923: [Sdoi2010]外星千足虫高斯消元

bzoj 1923 [Sdoi2010]外星千足虫 高斯消元