find_polygons(s)
answer = { }
for each ss in powerset(s)
if is-regular-polygon(ss)
answer += { ss }
return answer
find_polys(s)
s' = s
polys = { }
while s not empty
p1 = pick s
foreach p2 in s
check(p1, p2, polys, s')
check(p2, p1, polys, s')
return polys
check(p1, p2, polys, points)
for i = 3 to points.size()
rp = generate(i, p1, p2)
if rp in points
polys += rp
find_polys(s)
while s.size > 2
p1 = pick s
foreach p2 in s
edges[dist(p1, p2)] += (p1, p2)
polys = { }
foreach e in edges
polys += chains(e->second)
return polys
chains(edges)
g = create_graph(edges)
return dfs_cycle_find(g)
| c | n | - | + | y | |
| Empty | 5 | ||||
| Garbage | 1 | 4 | |||
| Odd | 1 | 4 | |||
| Non-number | 2 | 3 | |||
| Square | 2 | 3 | |||
| Octagon | 5 | ||||
| Duplicate | 2 | 3 | |||
| Orientation | 4 | 1 |
int main () polygon T T.read_input(std::cin) T.find_polys()
or
int main () polygon T T.read_input(std::cin) T.find_polys() T.write_output(std::cout)
Why?
std::copy( std::istream_iterator(std::cin), std::istream_iterator (), std::back_inserter(v)) validation(v)
std::copy(...) if not std::cin.eof() error: Input error while reading points. validation(v)
while true
in >> x
if in.eof()
break
if in.fail()
abort("Data format error for x value")
in >> y
if in.eof()
abort("! x value but no y value")
if in.fail()
abort("Data format error for y value")
point tmp(x,y)
point_list.push_back(tmp)
with generic algorithms.
std::copy( std::istream_iterator<point>(std::cin), std::istream_iterator<point>(), std::back_inserter(point_list))
This page last modified on 28 April 2004.