• POJ


    模型是个线性模2方程组。高斯消元的话可能解不唯一,要找独立变元。

    但是不难看出,枚举左端点按下的状态,之后可以影响端点就只有一个变量了,根据端点递推了,然后检查。(写的时候想的是枚举左右端点

    /*********************************************************
    *            ------------------                          *
    *   author AbyssalFish                                   *
    **********************************************************/
    #include<cstdio>
    #include<iostream>
    #include<string>
    #include<cstring>
    #include<queue>
    #include<vector>
    #include<stack>
    #include<vector>
    #include<map>
    #include<set>
    #include<algorithm>
    #include<cmath>
    #include<numeric>
    using namespace std;
    
    const int N = 20;
    int b[N];
    
    
    //#define LOCAL
    int main()
    {
    #ifdef LOCAL
        freopen("in.txt","r",stdin);
    #endif
        for(int i = 0; i < N; i++) scanf("%d",b+i);
        int best = N;
        for(int S = 4; S--;){
            int x = S&1, y = S>>1;
            b[0] ^= x; b[1] ^= x;
            b[N-2] ^= y; b[N-1] ^= y;
            int v[N+3] = {};
            int rv = 0, ans = x+y;
            for(int i = 0; i < N; i++){
                if(b[i]^(rv^=v[i])){
                    if(i < N-2){
                        v[i+3] ^= 1; rv ^= 1;
                        ans++;
                    }
                    else{
                        ans = best+1; break;
                    }
                }
            }
            best = min(best,ans);
            b[0] ^= x; b[1] ^= x;
            b[N-2] ^= y; b[N-1] ^= y;
        }
        printf("%d
    ", best);
        return 0;
    }
  • 相关阅读:
    常用git指令操作
    eclipse中常用快捷键整理
    Java Dom解析xml文件
    Spring IOC的注入方式
    Spring framework bean的作用域,生命周期
    android中的bundle使用
    python ftplib模块
    python requests用法总结
    限制字符串 剔除费需要字符然后将多余空格删除
    MFC Edit Control 编辑控件 属性和API
  • 原文地址:https://www.cnblogs.com/jerryRey/p/4975671.html
Copyright © 2020-2023  润新知