• Bzoj1923: [Sdoi2010]外星千足虫


    题面

    传送门

    Sol

    显然高斯消元
    你会发现线性基和高斯消元本质上好像差不多
    直接上线性基判断是否有解
    线性基的插入不就是高斯消元吗

    然后bitset优化即可

    # include <bits/stdc++.h>
    # define RG register
    # define IL inline
    # define Fill(a, b) memset(a, b, sizeof(a))
    using namespace std;
    typedef long long ll;
    typedef long double lod;
    
    template <class Int>
    IL void Input(RG Int &x){
        RG int z = 1; RG char c = getchar(); x = 0;
        for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
        for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
        x *= z;
    }
    
    const int maxn(1005);
    
    int n, m, num;
    bitset <maxn> a[maxn], tmp;
    char s[maxn];
    
    IL void Gauss(){
    	for(RG int i = n; i > 1; --i)
    		for(RG int j = i - 1; j; --j)
    			a[j][n + 1] = a[j][n + 1] ^ (a[j][i] & a[i][n + 1]);
    	for(RG int i = 1; i <= n; ++i)
    		puts(a[i][n + 1] ? "?y7M#" : "Earth");
    	exit(0);
    }
    
    int main(RG int argc, RG char* argv[]){
    	Input(n), Input(m);
    	for(RG int i = 1, k; i <= m; ++i){
    		scanf(" %s", s + 1), Input(k), tmp[n + 1] = k;
    		for(RG int j = 1; j <= n; ++j) tmp[j] = s[j] == '1';
    		for(RG int j = 1; j <= n; ++j)
    			if(tmp[j]){
    				if(!a[j][j]){
    					a[j] = tmp, ++num;
    					break;
    				}
    				tmp = tmp ^ a[j];
    			}
    		if(num == n){
    			printf("%d
    ", i);
    			Gauss();
    		}
    	}
    	puts("Cannot Determine");
        return 0;
    }
    
    
  • 相关阅读:
    jquery获取当前时间比较日期
    php获取时间计算时间差
    计数查询统计
    jQuery选取所有复选框被选中的值并用Ajax异步提交数据
    在java中实现对access数据库的远程访问
    sublime快捷键
    局部变量和成员变量的区别
    常见的几种数组排序方法
    JVM的内存划分
    Java函数
  • 原文地址:https://www.cnblogs.com/cjoieryl/p/8805512.html
Copyright © 2020-2023  润新知