Topcoder High School SRM 11 250 pt - Level one - City Buses editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm11
Topcoder High School SRM 11 250 pt - Level one - City Buses solution:
#include <iostream> #include <vector> #include <cstdlib> using namespace std; class CityBuses { public: int maximumFare(vector <string> v) { int ma=0; for(int i=0; i<v.size(); i++) { for(int j=0; j<v[i].length(); j++) { if(v[i][j]=='B') { for(int k=0; k<v.size(); k++) { for(int l=0; l<v[i].length(); l++) { if(v[k][l]=='B') { if(abs(i-k)+abs(j-l)>ma) ma=abs(i-k)+abs(j-l); } } } } } } return ma; } };
note: after compiling i tested my code on examples and it returned expected results except last example, example 3. no matter what, i got AC.
for details: http://apps.topcoder.com/forums/?module=Thread&threadID=821317&start=0&mc=1#1887528
No comments:
Post a Comment