Last active
December 11, 2015 00:58
-
-
Save tsu-nera/4519970 to your computer and use it in GitHub Desktop.
TopCoder SRM 566 (div1) 250
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * TopCoder | |
| * SRM566 Level1 | |
| * | |
| * Author : tsu_nera | |
| * Created : 2013/01/13 | |
| */ | |
| #include <algorithm> | |
| #include <iostream> | |
| #include <map> | |
| #include <numeric> | |
| #include <set> | |
| #include <sstream> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; | |
| class PenguinTiles { | |
| public: int minMoves(vector<string> tiles) { | |
| int col_length = tiles.size(); | |
| int row_length = tiles[0].size(); | |
| if(tiles[col_length-1].substr(row_length-1,1) == ".") { | |
| return 0; | |
| } | |
| for (int i = 0; i < col_length-1; i++) { | |
| if(tiles[i].substr(row_length-1,1) == ".") { | |
| return 1; | |
| } | |
| } | |
| for (int i = 0; i < row_length-1; i++) { | |
| if(tiles[col_length-1].substr(i,1) == ".") { | |
| return 1; | |
| } | |
| } | |
| return 2; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment