そーすこーど
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
int N,M;
cin>>N>>M;
vector<string> matrix(N);
int i,j;
for(i=0;i<N;i++){
cin>>matrix[i];
}
int row_mask=0;
int col_mask=0;
for(i=0;i<N;i++){
for(j=0;j<M;j++){
if(matrix[i][j]=='0'){
row_mask|=(1<<i);
col_mask|=(1<<j);
}
}
}
for(i=0;i<N;i++){
for(j=0;j<M;j++){
if(row_mask&(1<<i)||col_mask&(1<<j)){
cout<<0;
} else{
cout<<matrix[i][j];
}
}
cout<<endl;
}
return 0;
}
入力例1
3 3
111
101
111
出力例1
101
000
101
入力例2
2 33
111111111111111111111111111111110
111111111111111111111111111111111
出力例2
000000000000000000000000000000000
011111111111111111111111111111110