TopCoder High School SRM 33 Level one - 250 pt - Castle Guards editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm33
TopCoder High School SRM 33 Level one - 250 pt - Castle Guards solution:
#include <iostream> #include <vector> #include <algorithm> using namespace std; class CastleGuards { public: int missing(vector <string> c) { int a[55]={0}, b[55]={0}, ca=0, cb=0; for(int i=0; i<c.size(); i++) { for(int j=0; j<c[i].length(); j++) { if(c[i][j]=='X') a[i]=1, b[j]=1; } } for(int i=0; i<c.size(); i++) if(a[i]==0) ca++; for(int i=0; i<c[0].length(); i++) if(b[i]==0) cb++; return max(ca, cb); } };
No comments:
Post a Comment