結果

問題 No.179 塗り分け
ユーザー yoza
提出日時 2015-04-06 01:56:00
言語 Nim
(2.2.0)
結果
AC  
実行時間 20 ms / 3,000 ms
コード長 1,233 bytes
コンパイル時間 4,326 ms
コンパイル使用メモリ 67,196 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-23 14:27:28
合計ジャッジ時間 5,108 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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])
    co: int
    # tmpCo: int
    flag = false

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

  if co == 0:
    return "NO"

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

echo(solve())
0