有什么好说的 就比上道题多个字典序最小 直接秒了
```
#include <bits/stdc++.h> using namespace std; const int N =20; const int mod =11451419; #define endl '\n' #define Endl '\n' #define inf 1e18 #define int long long #define fast ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); int m,n; int g[N][N],bg[N][N],ans[N][N],res[N][N]; int dx[5]={0,1,0,-1,0},dy[5]={1,0,-1,0,0}; void turn(int x,int y){ ans[x][y]=1; for(int i=0;i<5;i++){ int a=x+dx[i],b=y+dy[i]; if(a>=0&&a<m&&b>=0&&b<n)g[a][b]^=1; } } bool sb; signed main(){ cin>>m>>n; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>>bg[i][j]; } } for(int op=pow(2,n)-1;op>=0;op--){ memcpy(g,bg,sizeof g); memset(ans,0,sizeof ans); for(int i=0;i<n;i++){ if(op>>i&1)turn(0,i); } for(int i=0;i<m-1;i++){ for(int j=0;j<n;j++){ if(g[i][j])turn(i+1,j); } } bool flag=1; for(int i=0;i<n;i++){ if(g[m-1][i])flag=0; } if(flag){ memcpy(res,ans,sizeof ans); sb=1; } } if(!sb){ cout<<"IMPOSSIBLE"<<Endl; return 0; } for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cout<<res[i][j]<<' '; } cout<<Endl; } return 0^0; }
```