General MotorsOA #1
Prepare Notification
Estimated EasyJudge-ready
Topics (AI-labelled)Strings
If the message is too long, keep the longest prefix of complete words and append a space and an ellipsis; otherwise return it unchanged; if even the first word does not fit, output just the ellipsis.
The standard input/output conventions and constraints added by this site are given under "Input".
Input
3≤K≤500; the message has 1..500 characters, consisting of letters and single spaces. The first line contains K, and the second line contains the message.
Output
Output the notification, whose length is ≤K.
Example 1
Input:
15
And now here is my secret
Output:
And now ...
Example 2
Input:
15
There is an animal with four legs
Output:
There is an ...
Example 3
Input:
4
super dog
Output:
...
Example 4
Input:
20
how are you
Output:
how are you
Editorial
Loading solution…