289 - A Very Nasty Text Formatter
Posted: Mon May 10, 2004 8:07 pm
Can someone explain me this problem?
If yes, why the output for last sample test case is not:
The only way how I can reproduce the sample output is by using greedy, but I got WA when I submitted a program with it. Did someone solve this problem with DP, or is greedy the algorithm that is wanted here?
Does it mean, that I should minimize the number of lines that can't be printed with length n, and then minimize the number of hyphenations?You should do as few hyphenations as possible. However, if it is impossible to justify a line of the text, output it left-justified.
If yes, why the output for last sample test case is not:
Code: Select all
This
is a-
n ex-
ample
of a
para-
graph
whic-
h is
pret-
typr-
inte-
d on
a r-
ow w-
ith a
leng-
th of
five.