1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

リアル女子大生とペアプロできないのはどう考えても俺が悪い 第一話

Posted at

とりま超ナイーブバージョン

($mx,$my) = gets.split(" ").map(&:to_i)

$mem = []
$mx.times do
   $mem << gets.chomp.bytes.map(&:chr).map(&:to_i)
end

def count(x,y)
  k = 0
  $mx.times do |i|
    $my.times do |j|
      if $mem[i][j] == 0
        k += 1 if drawable(i,j,x,y) 
      end
    end
  end
  puts k
end

def drawable(mx,my,x,y)
  return false if mx + x > $mx
  return false if my + y > $my
  x.times do |i|
    y.times do |j|
      return false if $mem[mx + i][my + j] == 1
    end
  end
  return true
end

widgets = gets.to_i

widgets.times do
  count(*(gets.split(" ").map(&:to_i)))
end

テスト4でタイムアウト。42点。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?