結果

問題 No.179 塗り分け
ユーザー yoza
提出日時 2015-04-06 01:37:24
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 1,261 bytes
コンパイル時間 3,228 ms
コンパイル使用メモリ 66,528 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 01:40:34
合計ジャッジ時間 4,537 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 35 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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 or co mod 2 == 1:
    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):
        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] == '#':
              tmpCo += 1
              tBoard[h][w] = 'R'
              tBoard[hMove + h][wMove + w] = 'B'
            else:
              flag = true
              break
          # else:
          #   flag = true
          #   break
        if flag:
          break
      if tmpCo == co div 2 and not flag:
        return "YES"
  return "NO"

echo(solve())
0