Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

哪位大神帮忙看看呗 实在不知道哪里错了

Posted by 20152430227 at 2017-08-29 14:13:34 on Problem 3126
```#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
int map[16][16];
int m,n;
int vis[16][16];
void exchange(int i,int j){//0变1,1变0 即与1异或
map[i][j] ^= 1;
if(i-1>=0) map[i-1][j] ^=1;
if(i+1<m) map[i+1][j] ^=1;
if(j-1>=0) map[i][j-1] ^=1;
if(j+1<n) map[i][j+1] ^=1;
}
bool bfs(){
for(int i=0;i<m-1;i++){
for(int j=0;j<n;j++){
if(map[i][j]==1){
exchange(i+1,j);
vis[i+1][j]=1;
}
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(map[i][j]==1) return false;
}
}
return true;
}
int main(){
while(scanf("%d%d",&m,&n)!=EOF){
getchar();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
scanf("%d",&map[i][j]);
}
}
memset(vis,0,sizeof(vis));//刚开始，将vis全部置0
if(bfs()){
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<vis[i][j]<<' ';
}
cout<<endl;
}
}
else cout<<"IMPOSSIBLE";
}
return 0;
}```

Followed by: