SRM 566 Div2 Easy PenguinTiles
解法
右下にある場合0
一番下の行 or 一番右の列にある場合1
それ以外の場合は1回の操作で↑の状態にできるので2
ソースコード
int PenguinTiles::minMoves(vector <string> tiles) { int h = tiles.size(), w = tiles[0].size(); if (tiles[h - 1][w - 1] == '.') return 0; rep(x, w) if (tiles[h - 1][x] == '.') return 1; rep(y, h) if (tiles[y][w - 1] == '.') return 1; return 2; }