We need to read multiple datasets, each with H and W (height and width). For each dataset, we need to draw a rectangular frame made of '#' and '.' with given dimensions. The frame: outer border is '#', interior is '.'? Actually the description says: "Draw a frame which has a height of H cm and a width of W cm." Then example: H=6, W=10, they show a picture:
........#
........#
........#
........#
Wait, the picture in problem statement seems incomplete? Actually typical "frame" problem from AIZU or similar: print a frame of '#' and '.' where the frame's border is '#' and the inside is '.'? But they show an example: H=6, W=10, the output in problem statement is:
........#
........#
........#
........#
That seems odd. Possibly they only show part of the frame? Actually let's read the problem statement carefully: "Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.
........#
........#
........#
........#"
There are four lines? Should be 6 lines. Maybe the description omitted some lines? Actually maybe the frame is drawn using '#' and '.' where the top and bottom edges are '#' and the left and right edges are '#'? But the sample shows dots and # at rightmost column? Hmm.
Let's check typical "frame" problem from AOJ (Aizu Online Judge) "ITP1_5_B: Print a Frame" Actually there is a problem: print a frame of # with given H and W: The frame: top and bottom rows are all '#', and the inner rows have '#' at the start and end, and '.' in between. That matches the sample output given in the example for this problem: Input: 3 4 -> Output:
#..#
Yes. So that is the classic frame: border of '#', interior of '.'.
But in the description they had a weird example with 6x10 showing dots and # only on right side? Possibly that was just illustration of something else? Actually maybe the problem originally said: "For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm." Then they show a picture with dots and # at right? That might be a mistake. Anyway, we need to output as per the given sample.
So for each dataset (except termination), output a rectangle of H rows and W columns. The outer border (first row, last row, first column, last column) consists of '#', and all other inner cells consist of '.'.
Edge cases: H and W are at least 3, so there will always be at least one inner row and column? Actually if H=3 and W=3, there is a middle cell that is '.' because it's not border? The border includes all cells on the perimeter; the middle cell (2,2) is interior, so it's '.'. Sample for 3 3 output:
#.#
Yes.
So algorithm: For each dataset:
- For i from 0 to H-1:
- For j from 0 to W-1:
- If i == 0 or i == H-1 or j == 0 or j == W-1: print '#', else print '.'
- Print newline.
- After each dataset, print a blank line (i.e., an extra newline). Note: Output says "Print a blank line after each dataset." So after the rectangle, print an additional empty line (or just a newline). In the sample output, they have blank line between datasets but not after the last? Actually sample:
Input:
3 4
5 6
3 3
0 0
Output:
#..#
#....#
#....#
#....#
#.#
Wait formatting: They show:
#..#
#....#
#....#
#....#
#.#
There is a blank line between datasets. So after each dataset, including the last, there should be a blank line? Actually in the sample, after the last dataset they don't show an extra blank line? But "Print a blank line after each dataset." typically means after each dataset's frame, output an additional newline, which would result in a blank line between datasets (since next frame starts after that blank line). For the last dataset, there should also be a blank line after it, but sometimes the judge ignores trailing blank lines. However it's safe to output a blank line after each dataset, including the last. But careful: If we output an extra newline after the last frame, it may cause Presentation Error? In many problems like this, they require exactly one blank line between outputs, and no extra at the end? However many judges accept trailing newlines. To be safe, we can print a newline after each dataset's rectangle (including last). That means after printing the rectangle rows, we print an extra newline. This will produce a blank line between datasets (because the next dataset's rectangle will start after two newlines? Let's simulate: For dataset 1: print rows, each row ends with newline; after all rows, print another newline (blank line). Then for dataset 2: print rows, etc. That yields an empty line between. At the end, after final dataset, we have an extra newline. That's typically acceptable.
Check sample: They show first dataset output then a blank line, second dataset output then a blank line, then third dataset output. Actually after third they didn't show blank line? But it might be that they omitted it. I'll produce exactly as required: after each dataset, print a blank line, i.e., an additional newline.
Implementation: reading until "0 0". Use input().strip().
We must handle multiple datasets, each with two integers.
Now constraints up to 300, so printing is fine.
Now, double-check the weird example in problem statement: It might be a different orientation? But given sample input/output, we know what to do.
Thus, answer: For each dataset, produce H lines of W characters each, with border '#' and interior '.'; then an extra newline.
Now, we must output in the correct format.
Now, craft the response. We need to include the solution, likely in Python, but the user asked "Draw a frame..." It's a programming problem. The user didn't specify language, but typical to provide solution code. Since it's a conversation, maybe they want explanation? The instruction: "We need to read multiple datasets... Output for each dataset..." Actually they might be asking to write a program. But as ChatGPT, we can provide a solution in Python, with explanation.
I'll produce a full solution.
Edge cases: H and W can be up to 300; nothing else.
Implementation details:
while True:
line = input()
if not line: continue? but typically there will be lines.
H, W = map(int, line.split())
if H == 0 and W == 0: break
for i in range(H):
if i == 0 or i == H-1:
print('#' * W)
else:
print('#' + '.' * (W-2) + '#')
print() # blank line
That's it.
Now, ensure we handle the case W=3: then (W-2)=1, prints '#' + '.' + '#'; correct.
Now, produce final answer.
But note: The user might be expecting a response with code and explanation. I'll include both.
Given it's a problem from some online judge, we can output the code.
I'll write the solution in Python, using sys.stdin for speed but not necessary.
Now, produce final. Below is a Python solution that reads multiple datasets, each consisting of two integers H and W, and for each dataset prints a frame of '#' and '.' as described. The program terminates when both H and W are zero.
import sys
def solve() -> None:
out_lines = []
for line in sys.stdin:
line = line.strip()
if not line:
continue
H, W = map(int, line.split())
if H == 0 and W == 0:
break
# Build the frame
for i in range(H):
if i == 0 or i == H - 1:
out_lines.append('#' * W)
else:
out_lines.append('#' + '.' * (W - 2) + '#')
out_lines.append('') # blank line after each dataset
sys.stdout.write('\n'.join(out_lines))
if __name__ == "__main__":
solve()
Explanation
- The program reads lines from standard input until it encounters
0 0.
- For each valid dataset (with
3 ≤ H, W ≤ 300), it constructs H rows:
- The first and last rows consist entirely of
#.
- All other rows have
# at the first and last columns, and . in between (using '.' * (W - 2)).
- After printing all rows of a dataset, an extra newline is added to satisfy the requirement of a blank line after each dataset.
- Output is written to standard output.
This matches the sample output exactly.