• [1588] To love or hate

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Hungar has a magic board,it's size is n*n,every lattice can be marked by ‘#’ or ‘*’.The former means hungar hates it,and the latter means he loves it.But he can choose one lattice and change it ,which means if the lattice is ‘#’,it will be ‘*’ and vice versa.What’s more, if you choose one lattice,It’s adjacent lattice will also be changed(if any).
    We will give you an untreated board(Initialization),now hungar wants to know whether
    he can make the board all his love. you are a good Acmer.Can you help him?

  • 输入
  • The first line is an intger t(t<=100),which means the number of test
    the second line is an intger n(n<=30)
    then follow n lines,every line is an string ,the length is n.
  • 输出
  • if he can’t make it ,output “inf”(without the quotes)
    or you should output the minimum number of operations by hunger.
  • 样例输入
  • 2
    4
    ***#
    #***
    #*#*
    ##**
    3
    #*#
    *##
    ***
    
  • 样例输出
  • inf
    5
    
  • 提示
  • 来源
  • 本站或者转载
  • 操作

显示春菜