#![allow(non_snake_case,dead_code,unused_imports)] use proconio::{*,marker::*}; fn main(){ input!{ n:usize, mut s:[Bytes;n], } for i in 0..n{ for j in 0..n{ s[i][j]-=b'0'; } } let mut ans=vec![vec![false;n];n]; let mut deg=vec![vec![0;n];n]; let mut que=std::collections::VecDeque::new(); let isok=|ans:&Vec>,deg:&Vec>,p:P|->bool{ if ans[p]{ s[p]>=deg[p] } else{ s[p]<=deg[p] } }; let mut inq=vec![vec![false;n];n]; for p in iterp(n,n){ if !isok(&ans,°,p){ inq[p]=true; que.push_back(p); } } while let Some(p)=que.pop_front(){ assert!(inq[p]); inq[p]=false; if isok(&ans,°,p){ continue; } let add=if ans[p]{ !0 } else{ 1 }; ans[p]^=true; for dx in chain!(once(P::new(0,0)),DX){ let np=p+dx; if np.in_range(n,n){ deg[np]+=add; if !isok(&ans,°,np) && !inq[np]{ inq[np]=true; que.push_back(np); } } } } // debug!(deg); // debug!(s); for i in 0..n{ for j in 0..n{ assert!(isok(&ans,°,P::new(i,j))); if ans[i][j]{ print!("o"); } else{ print!("."); } } println!(); } } use std::iter::*; use itertools::*; trait ChangeMinMax:Copy+PartialOrd{ fn chmin(&mut self,a:Self)->bool{ *self>a && { *self=a; true } } fn chmax(&mut self,a:Self)->bool{ *self ChangeMinMax for T{} // library: https://github.com/rhoo19937/cp-lib // LURD const DD:[P;4]=[P{i:0,j:!0},P{i:!0,j:0},P{i:0,j:1},P{i:1,j:0}]; const DX:[P;8]=[P{i:0,j:!0},P{i:!0,j:!0},P{i:!0,j:0},P{i:!0,j:1},P{i:0,j:1},P{i:1,j:1},P{i:1,j:0},P{i:1,j:!0}]; #[derive(Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Hash,Default)] struct P{ i:usize, j:usize, } impl P{ fn new(i:usize,j:usize)->P{ P{i,j} } fn in_range(self,h:usize,w:usize)->bool{ self.iusize{ self.i*w+self.j } fn from(id:usize,w:usize)->P{ P::new(id/w,id%w) } fn manh(self,p:P)->usize{ let abs_diff=|a,b|(a as i64-b as i64).abs() as usize; abs_diff(self.i,p.i)+abs_diff(self.j,p.j) } fn dir(self,p:P)->usize{ if self.i==p.i{ if self.j-1==p.j{ 0 } else{ assert!(self.j+1==p.j); 2 } } else{ if self.i-1==p.i{ 1 } else{ assert!(self.i+1==p.i); 3 } } } } impl std::fmt::Debug for P{ fn fmt(&self,f:&mut std::fmt::Formatter)->std::fmt::Result{ write!(f,"({}, {})",self.i,self.j) } } impl std::ops::Add for P{ type Output=P; fn add(self,a:P)->P{ P{ i:self.i+a.i, j:self.j+a.j, } } } impl std::ops::Sub for P{ type Output=P; fn sub(self,a:P)->P{ P{ i:self.i-a.i, j:self.j-a.j, } } } impl std::ops::Mul for P{ type Output=P; fn mul(self,a:usize)->P{ P{ i:self.i*a, j:self.j*a, } } } impl std::ops::Div for P{ type Output=P; fn div(self,a:usize)->P{ P{ i:self.i/a, j:self.j/a, } } } impl std::ops::Neg for P{ type Output=P; fn neg(self)->P{ P{ i:self.i.wrapping_neg(), j:self.j.wrapping_neg(), } } } macro_rules! impl_p_ops{ ($t:ty,$assign_trait:ident,$assign_func:ident,$op:tt)=>{ impl std::ops::$assign_trait<$t> for P{ fn $assign_func(&mut self,a:$t){ *self=*self $ op a; } } } } impl_p_ops!(P,AddAssign,add_assign,+); impl_p_ops!(P,SubAssign,sub_assign,-); impl_p_ops!(usize,MulAssign,mul_assign,*); impl_p_ops!(usize,DivAssign,div_assign,/); macro_rules! impl_p_index{ ($t:ty)=>{ impl> std::ops::Index

for $t{ type Output=T::Output; fn index(&self,idx:P)->&T::Output{ &self[idx.i][idx.j] } } impl> std::ops::IndexMut

for $t{ fn index_mut(&mut self,idx:P)->&mut T::Output{ &mut self[idx.i][idx.j] } } } } impl_p_index!([T]); impl_p_index!(Vec); fn iterp(h:usize,w:usize)->impl Iterator{ (0..h).map(move|i|(0..w).map(move|j|P::new(i,j))).flatten() } #[allow(unused)] mod rnd{ static mut X2:u32=12345; static mut X3:u32=0xcafef00d; static mut C_X1:u64=0xd15ea5e5<<32|23456; pub fn set_seed(seed:u64){ unsafe{ C_X1^=seed as u64; } } pub fn next()->u32{ unsafe{ let x=X3 as u64*3487286589; let ret=(X3^X2)+(C_X1 as u32^(x>>32) as u32); X3=X2; X2=C_X1 as u32; C_X1=x+(C_X1>>32); ret } } pub fn next64()->u64{ (next() as u64)<<32|next() as u64 } pub fn nextf()->f64{ f64::from_bits(0x3ff0000000000000|(next() as u64)<<20)-1. } pub fn get(n:usize)->usize{ assert!(0>32 } pub fn range(a:usize,b:usize)->usize{ assert!(ausize{ assert!(a<=skip && skipi64{ assert!(a(a:&mut [T]){ for i in (1..a.len()).rev(){ a.swap(i,get(i+1)); } } pub fn shuffle_iter(a:&mut [T])->impl Iterator{ (0..a.len()).rev().map(|i|{ a.swap(i,get(i+1)); a[i] }) } } #[allow(unused)] trait RandomChoice{ type Output; fn choice(&self)->&Self::Output; } impl RandomChoice for [T]{ type Output=T; fn choice(&self)->&T{ &self[rnd::get(self.len())] } } #[cfg(feature="local")] include!(concat!(env!("HOME"), "/cp/lib/debug_mod.rs")); #[cfg(not(feature="local"))] #[macro_export]macro_rules! debug{($($t:tt)*)=>{}}