Description

「大括號下放根本是邪教!」我相信這是許多人的心聲,但 Java 程式碼排版其實並不重要,也有像是 Spotless 等工具可以自動化重新排版

但今天你看這些下放的大括號實在太不爽了,你決定寫一個程式把它們處理掉。程式的邏輯非常簡單,就是:如果看到有一行除了空格外,只有一個 {,就將它合併到上一行,並在中間新增一個空格!

Input Format

很多行字串直到 EOF

條件:

行數 $< 1000$,每行長度 $< 1000$
保證由 ASCII 可列印字元組成
每行不會由空格結尾
不會連續兩行只有 {

Output Format

更改過的字串,詳見題敘

Sample Input 1

public class Main
{
  public static void main(String[] args)
  {
    System.out.printf("Hello, world!\n");
  }
}

Sample Output 1

public class Main {
  public static void main(String[] args) {
    System.out.printf("Hello, world!\n");
  }
}

Sample Input 2

A
{
B
{{

Sample Output 2

A {
B
{{

Hints

Problem Source

裸題 好欸

TopCoder


$\texttt{<script>alert(":3");</script>}$

User's AC Ratio

100.0% (1/1)

Tags

Problem Setter

Created by

Subtasks

No. Testdata Range Score
1 0~9 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 1
2 1000 65536 65536 1
3 1000 65536 65536 1
4 1000 65536 65536 1
5 1000 65536 65536 1
6 1000 65536 65536 1
7 1000 65536 65536 1
8 1000 65536 65536 1
9 1000 65536 65536 1