Created
October 3, 2010 02:36
-
-
Save anisaraf/608208 to your computer and use it in GitHub Desktop.
This file contains 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
int PenLift::numTimes(vector<string> segments, int n) | |
{ | |
transform(segments.begin(), segments.end(), | |
back_inserter(m_inLines), PenLift::getLine); | |
mergeLines(); | |
intersectLines(); | |
createGraph(); | |
vector< Graph<Point> > g = m_graph.getConnectedGraphs(); | |
if(n % 2 == 0) | |
return (g.size() - 1); | |
int rValue =0; | |
for( vector< Graph<Point> >::iterator it = g.begin() ; | |
it != g.end(); ++it) | |
{ | |
int odd = it->numOddVertices()/2; | |
rValue += odd > 0 ? odd:1; | |
} | |
return rValue - 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment