Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Last active December 11, 2015 00:58
Show Gist options
  • Select an option

  • Save tsu-nera/4519970 to your computer and use it in GitHub Desktop.

Select an option

Save tsu-nera/4519970 to your computer and use it in GitHub Desktop.
TopCoder SRM 566 (div1) 250
/*
* 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