• [1301] Gopher Hole

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Death-Moon loves telling stories.
    Some days ago, he told us a funny story.


    Long long ago, there is a hamster who is so naughty. Now, he comes to a place likes a N * N square. so, he is so excited to drill holes underground.


  • 输入
  • Input until EOF.
    Fisrt input two integers N (3 <= N < 100) and M (0 < M <2000). N is the side of N * N ground, M is the number of operations.

    Then follow M lines.
    Each line is a command:

    Out x y : Hamster will get out at (x, y) from underground. So, place (x, y) will be a hole.
    P : Calculate out the number of the holes and output (Two holes are connected when they share an edge).
    If two holes are connected, it means it is one hole.
  • 输出
  • For each 'P' command, output the number of the holes. Maybe hamster will get out at the same place more than once.
  • 样例输入
  • 3 5
    Out 0 0
    P
    Out 1 0
    Out 2 2
    P
  • 样例输出
  • 1
    2
  • 提示
  • 来源
  • Hungar
  • 操作

显示春菜