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++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
 
int n;
const int dx[5] = {-1, 0, 0, 0, 1};
const int dy[5] = {0, -1, 0, 1, 0};
int tile[10][10];
int flip[10][10];

int get(int x, int y)
{
	int c = tile[y][x];
	rep(d, 5)
	{
		int x2 = x + dx[d];
		int y2 = y + dy[d];
		if (0 <= x2 && x2 < 10 && 0 <= y2 && y2 < 10)
		{
			c += flip[y2][x2];
		}
	}
	return c % 2;
}

void print()
{
	rep(i, 10)
	{
		rep(j, 10)
		{
			if (j == 9)
			{
				printf("%d\n", flip[i][j]);
			} else {
				printf("%d ", flip[i][j]);
			}
		}
	}
}

bool calc()
{
	for (int i=1; i<10; i++)
	{
		for (int j=0; j<10; j++)
		{
			if (get(j, i-1) != 0)
			{
				flip[i][j] = 1;
			}
		}
	}

	for (int j=0; j<10; j++)
	{
		if (get(j, 9) != 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	cin >> n;

	REP(n)
	{
		rep(j, 10)
		{
			rep(k, 10)
			{
				cin >> tile[j][k];
			}
		}

		for (int j=0; j<(1<<10); j++)
		{
			memset(flip, 0, sizeof(flip));
			for (int k=0; k<10; k++)
			{
				flip[0][10-k-1] = j >> k & 1;
			}
			
			if (calc())
			{
				print();
				break;
			}
		}

		/*
		//デバッグ
		rep(j, 10)
		{
			rep(k, 10)
			{
				printf("%d ", tile[j][k]);	
			}
			printf("\n");
		}
		*/
	}

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

void frip(int y, int x, int map[10][10]){
	if(y < 0 || x < 0 || y >= 10 || x >= 10){
		return;
	}else{
		map[y][x] = !map[y][x];
	}
}

void frips(int y, int x, int map[10][10]){
	frip(y - 1, x, map);
	frip(y + 1, x, map);
	frip(y, x, map);
	frip(y, x - 1, map);
	frip(y, x + 1, map);
}

int main(){
	
	int n;
	
	int origin[10][10];
	
	int f_point[10][10];
	
	int map[10][10];
	
	bool checker;
	
	cin >> n;
	
	int N = 10;

	for(int loop = 0; loop < n; loop++){
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				cin >> origin[i][j];
			}
		}
		
		for(int i = 0; i < (1 << N); i++){
			
			for(int x = 0; x < N; x++){
				for(int y = 0; y < N; y++){
					map[y][x] = origin[y][x];
					f_point[y][x] = 0;
				}
			}
			
			for (int x = 0; x < N; x++){
				if((i & (1 << (N - x - 1))) != 0){
					frips(0, x, map);
					f_point[0][x] = 1;
				}else{
				}
			}
			
			for(int y = 1; y < N; y++){
				for(int x = 0; x < N; x++){
					if(map[y - 1][x]){
						frips(y, x, map);
						f_point[y][x] = 1;
					}
				}
			}
			
			checker = true;
			
			for(int x = 0; x < N; x++){
				if(map[N - 1][x]){
					checker = false;
					break;
				}
			}
			
			if(checker){
				for(int y = 0; y < N; y++){
					for(int x = 0; x < N; x++){
						if(f_point[y][x]){
							printf("1 ");
						}else{
							printf("0 ");
						}
					}
					printf("\n");
				}
			}
		}
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int I,flg;
int t[10][10],u[10][10];
int ans[10][10];
void check();
void dfs(int);
void compute(int,int);
int main(){
  cin>>I;
  while(I--){
    flg=0;
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	cin>>t[i][j];
	u[i][j]=t[i][j];
	ans[i][j]=0;
      }
    }
    dfs(0);
  }
  return 0;
}


void dfs(int x){
  if(flg)return;
  if(x==10){
    check();
  }else{
    ans[0][x]=0;
    dfs(x+1);
    ans[0][x]=1;
    dfs(x+1);
  }
}


void check(){
  if(flg)return;
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)t[i][j]=u[i][j];
  for(int i=0;i<10;i++)if(ans[0][i]==1)compute(0,i);

  for(int i=1;i<10;i++){
    for(int j=0;j<10;j++){
      if(t[i-1][j]==1){
	ans[i][j]=1;
	compute(i,j);
      }
    }
  }
  /*
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(j)cout<<' ';
      cout<<t[i][j];
    }
    cout<<endl;
  }
  */
  int cnt=0;
  for(int i=0;i<10;i++)cnt+=t[9][i];
  if(cnt==0){
    flg=1;
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	if(j)cout<<' ';
	cout<<ans[i][j];
      }
      cout<<endl;
    }
  }
}

void compute(int y,int x){
  t[y][x]=(t[y][x]*-1)+1;
  if(y>0)t[y-1][x]=(t[y-1][x]*-1)+1;
  if(x>0)t[y][x-1]=(t[y][x-1]*-1)+1;
  if(y<9)t[y+1][x]=(t[y+1][x]*-1)+1;
  if(x<9)t[y][x+1]=(t[y][x+1]*-1)+1;
}