Gives a \ (4 \ times 4 \) of the trellis diagram, on the trellis diagram by a digital 1s and 0s, a location may be selected for each operation, so that the line of the position where all the numbers on a 1 becomes 0, 0 to 1, to give an initial situation, ask a minimum of handling all numbers to 0.
solution
This is a class differences or problems, so to repeat a position that does not make sense, the question now transformed into those positions to operate.
FIG grid problem, according to the processing line, then a change in the note position, causes a change in each row, thus not prune, only 16 grid, \ (2 ^ {16} = 65536 \) , as direct violence enumerate.
So binary enumeration, the trellis split rows into columns, each one corresponding to a position on the grid map whether to operate on a binary (As for how correspondence, according to your own habits), but in order to quickly transform and achieve click on a pre-out position, which would result in changing the grid, under the direct binary bit computing to reflect this position click the situation changes, just count the number of advance at a good number of bits per 1, so that it can be done \ (O (2 ^ {16} \ Times 16) = 1048576 \) .
Reference Code:
#include <iostream>
#include <cstdio>
#define il inline
#define ri register
#define li 65536
#define intmax 0x7fffffff
using namespace std;
int t[16],tot[li];
il void get(char&);
int main(){
for(int i(0),j,k,l;i<4;++i)
for(j=0;j<4;++j)
for(k=0;k<4;++k)
t[i*4+j]|=1<<k+i*4,
t[i*4+j]|=1<<j+k*4;
for(int i(0),j;i<li;++i)
for(j=15;j>=0;--j)
if(i>>j&1)++tot[i];
char c;int ans(intmax),gzy,s(0);
for(int i(0);i<16;++i)
get(c),s|=(c=='-'?0:1)<<i;
for(int i(0),j,k;i<li;++i){
if(tot[i]>=ans)continue;
for(j=15,k=s;j>=0;--j)
if(i>>j&1)k^=t[j];
if(!k)ans=tot[i],gzy=i;
}printf("%d\n",ans);
for(int i(0);i<16;++i)
if(gzy>>i&1)
printf("%d %d\n",i/4+1,i%4+1);
return 0;
}
il void get(char &c){
while(c=getchar(),c==' '||c=='\n'||c=='\r');
}