Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)
var (
	table, ans = [12][12]int{}, [12][12]int{}
)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		for j := 1; j < 11; j++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			tmp := [10]int{}
			for k := range input {
				tmp[k], _ = strconv.Atoi(input[k])
			}
			for l := 1; l < 11; l++ {
				table[j][l] = tmp[l-1]
			}
		}
		check(table, 1, ans)
	}
}

func check(table [12][12]int, i int, ans [12][12]int) {
	if i == 11 {
		solve(table, 2, 1, ans)
		return
	}
	ans[1][i] = 0
	check(table, i+1, ans)
	ans[1][i] = 1
	attack(table, 1, i)
	check(table, i+1, ans)
	attack(table, 1, i)
}

func solve(table [12][12]int, i, j int, ans [12][12]int) {
	if i == 11 {
		flag := true
		for k := 1; k < 11; k++ {
			if table[10][k] == 1 {
				flag = false
				break
			}
		}
		if flag {
			printans(ans)
		}
		return
	}
	if table[i-1][j] == 1 {
		ans[i][j] = 1
		attack(table, i, j)
		if j == 10 {
			solve(table, i+1, 1, ans)
		} else {
			solve(table, i, j+1, ans)
		}
		attack(table, i, j)
		ans[i][j] = 0
	} else {
		ans[i][j] = 0
		if j == 10 {
			solve(table, i+1, 1, ans)
		} else {
			solve(table, i, j+1, ans)
		}
	}
}

func printans(ans [12][12]int) {
	for i := 1; i < 11; i++ {
		for j := 1; j < 11; j++ {
			fmt.Print(ans[i][j])
			if j < 10 {
				fmt.Print(" ")
			}
		}
		fmt.Println()
	}
}

func attack(table [12][12]int, i, j int) {
	table[i][j] = 1 - table[i][j]
	table[i-1][j] = 1 - table[i-1][j]
	table[i+1][j] = 1 - table[i+1][j]
	table[i][j-1] = 1 - table[i][j-1]
	table[i][j+1] = 1 - table[i][j+1]
}

C++: //Name: Doctor's Strange Particles
//Level: 2
//Category: 全探索
//Note: 

/**
 * 一番上の行に対する照射方法を固定すると、それより下の行が全て一意に決まる。
 * したがって、一番上の行だけを全探索してシミュレーションすればよい。
 *
 * オーダーは O(2^W HW)。
 */
#include <iostream>
#include <array>

using namespace std;

array<int,1<<10> eff;

bool solve(bool first) {
    array<int,10> f;
    for(int r = 0; r < 10; ++r) {
        f[r] = 0;
        for(int c = 0; c < 10; ++c) {
            int v;
            cin >> v;
            f[r] |= (v << c);
        }
    }

    array<int,10> ans;
    for(int pat = 0; pat < (1<<10); ++pat) {
        int prev = f[0] ^ eff[pat];
        int pmask = pat;
        ans[0] = pat;
        for(int r = 1; r < 10; ++r) {
            ans[r] = prev;
            const int tmp = f[r] ^ eff[prev] ^ pmask;
            pmask = prev;
            prev = tmp;
        }
        if(prev == 0) break;
    }
    for(int r = 0; r < 10; ++r) {
        for(int c = 0; c < 10; ++c) {
            if(c > 0) cout << ' ';
            cout << !!(ans[r] & (1<<c));
        }
        cout << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    for(int pat = 0; pat < (1<<10); ++pat) {
        eff[pat] = pat;
        for(int c = 0; c < 10; ++c) {
            if(pat & (1<<c)) {
                if(c > 0) eff[pat] ^= (1<<(c-1));
                if(c < 9) eff[pat] ^= (1<<(c+1));
            }
        }
    }

    bool first = true;
    int N;
    cin >> N;
    while(N-- && solve(first)) {
        first = false;
    }
    return 0;
}

C++: #include<vector>
#include<iostream>

using namespace std;

vector<int> GaussJordanMod2(vector<vector<unsigned int> > a){
	int n=a.size();
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(a[j][i/32]>>(i&31)&1){
				a[i].swap(a[j]);
				break;
			}
		}
		unsigned int rev=a[i][i/32]&~((1<<(i&31))-1);		
		for(int j=0;j<n;j++){
			if(i==j||!(a[j][i/32]>>(i&31)&1))continue;
			a[j][i/32] ^= rev;
			for(int k=i/32+1;k<(n+1+32-1)/32;k++){
				a[j][k] ^= a[i][k];
			}
		}
	}
	vector<int> res(n);
	for(int i=0;i<n;i++)res[i]=a[i][n/32]>>n%32&1;
	return res;
}


int main(){
	int dy[]={0,1,0,-1,0};
	int dx[]={0,0,1,0,-1};
	int n;
	cin>>n;
	while(n--){
		vector<vector<unsigned int> > a(100,vector<unsigned int>((101+31)/32,0));
		for(int i=0;i<100;i++){
			int y=i/10,x=i%10;
			for(int j=0;j<5;j++){
				int ny=y+dy[j],nx=x+dx[j];
				if(0<=ny&&ny<10&&0<=nx&&nx<10){
					a[ny*10+nx][i/32] |= 1<<(i&31);
				}
			}
		}
		for(int i=0;i<100;i++){
			int c;
			cin>>c;
			a[i][100/32] |= c<<(100&31);
		}
		vector<int> ans(GaussJordanMod2(a));cout<<endl;
		for(int i=0;i<10;i++){
			cout<<ans[i*10];
			for(int j=1;j<10;j++){
				cout<<' '<<ans[i*10+j];
			}
			cout<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#define SIZE 10
using namespace std;

class State{
public:
  int data[SIZE][SIZE];
  int put[SIZE][SIZE];
  State() {
    fill((int*)put, (int*)put+SIZE*SIZE, 0);
  }
  void puts(int x, int y) {
    static int d[5][2] = {{0,-1},{1,0},{0,1},{-1,0},{0,0}};
    put[y][x] = 1;
    for(int k = 0; k < 5; k++) {
      int nx = x + d[k][0];
      int ny = y + d[k][1];
      if(nx < 0 || nx >= SIZE) continue;
      if(ny < 0 || ny >= SIZE) continue;
      data[ny][nx] = -(data[ny][nx] - 1);
    }
  }
  bool isAll0() {
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	if(data[i][j] != 0) return false;
      }
    }
    return true;
  }
  void show() {
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	if(j != 0) cout << ' ';
	cout << put[i][j];
      }
      cout << endl;
    }
  }
};

bool rec(State s, int x, int y) {
  static int d[5][2] = {{0,-1},{1,0},{0,1},{-1,0},{0,0}};
  if(s.isAll0()) {
    s.show();
    return true;
  }

  for(int i = y; i < SIZE; i++) {
    int j;
    if(i == y) j = x;
    else       j = 0;
    for(; j < SIZE; j++) {
      bool flag = false;
      /*for(int k = 0; k < 5; k++) {
	int nx = j + d[k][0];
	int ny = i + d[k][1];
	if(nx < 0 || nx >= SIZE) continue;
	if(ny < 0 || ny >= SIZE) continue;
	if(s.data[ny][nx] == 1) {
	  flag = true;
	  break;
	}
	}*/
      flag = true;
      if(flag) {
	if(i > 0 && s.data[i-1][j] == 0) continue;
	State tmp = s;
	tmp.puts(j, i);
	int nx, ny;
	nx = j + 1;
	ny = i;
	if(nx >= SIZE) {
	  nx = 0;
	  ny++;
	}
	if(rec(tmp, nx, ny)) {
	  return true;
	}
	if(i > 0 && s.data[i-1][j] == 1) return false;
      }
    }
  }
  return false;
}

main() {
  int n;
  cin >> n;
  for(int t = 0; t < n; t++) {
    State s;
    for(int i = 0; i < SIZE; i++) {
      for(int j = 0; j < SIZE; j++) {
	cin >> s.data[i][j];
      }
    }
    rec(s, 0, 0);
  }
}

C++: #include<bits/stdc++>h>
using namespace std;

int c[10][10];
int f[10][10];
bool s[10][10];
int hanten[2] = { 1,0 };
int dx[5] = { -1,0,0,1,0 }, dy[5] = { 0,-1,1,0,0 };
int main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		memset(s, false, sizeof(s));
		for (int d = 0; d < 10; d++) {
			for (int e = 0; e < 10; e++) {
				scanf("%d",&c[d][e]);
			}
		}
		for (int g = 0; g < 1024; g++) {
			for (int h = 0; h < 10; h++) {
				for (int i = 0; i < 10; i++) {
					f[h][i] = c[h][i];
				}
			}
			for (int h = 0; h < 10; h++) {
				if (g & (1 << h)) {
					s[0][h] = true;
					for (int i = 0; i < 5; i++) {
						int x = dx[i], y = h + dy[i];
						if (x >= 0 && x < 10 && y >= 0 && y < 10) {
							f[x][y] = hanten[f[x][y]];
						}
					}
				}
			}
			for (int h = 1; h < 10; h++) {
				for (int i = 0; i < 10; i++) {
					if (f[h - 1][i]) {
						s[h][i] = true;
						for (int j = 0; j < 5; j++) {
							int x = h+dx[j], y = i + dy[j];
							if (x >= 0 && x < 10 && y >= 0 && y < 10) {
								f[x][y] = hanten[f[x][y]];
							}
						}
					}
				}
			}
			bool K = true;
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (f[i][j])K = false;
				}
			}
			if (K) {
				for (int i = 0; i < 10; i++) {
					for (int j = 0; j < 10; j++) {
						if (j)cout << " ";
						cout << s[i][j];
					}
					cout << endl;
				}
			}
		}
	}
}