結果

問題 No.179 塗り分け
ユーザー yoza
提出日時 2015-04-06 01:28:09
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 3,386 ms
コンパイル使用メモリ 65,536 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 01:40:08
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, algorithm, math

proc solve(): string =
  var
    hw = readLine(stdin).split(' ').map(parseInt)
    board = newSeq[string](hw[0])
    tBoard = newSeq[string](hw[0])
    count = 0
    tmpCount: int
    flag = false

  for i in countup(0, hw[0] - 1):
    board[i] = readLine(stdin)
    count += board[i].count('#')

  if count mod 2 == 1:
    return "NO"

  for hMove in countup(0, hw[0] - 1):
    for wMove in countup(-hw[1] + 1, hw[1] - 1):
      tmpCount = 0
      flag = false
      for h in countup(0, hw[0] - 1):
        tBoard[h] = board[h]
      for h in countup(0, hw[0] - 1):
        if hMove + h >= hw[0]:
          break
        for w in countup(0, hw[1] - 1):
          if wMove + w >= hw[1] or wMove + w < 0:
            break
          if tBoard[h][w] == '#':
            if tBoard[hMove + h][wMove + w] == '#':
              tmpCount += 1
              tBoard[h][w] = 'R'
              tBoard[hMove + h][wMove + w] = 'B'
            else:
              flag = true
              break
          # else:
          #   flag = true
          #   break
        if flag:
          break
      if tmpCount == count div 2 and not flag:
        return "YES"
  return "NO"

echo(solve())
0