Logo
(追記) (追記ここまで)

9557번 - Arabic and English 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB42324222157.702%

문제

Some computer programs have problems in displaying Arabic text, especially when mixed with English words in the same line, because Arabic is written from right to left and English is written from left to right. In this problem we will try to fix a text with some corrupted lines which consist of a mixture of Arabic and English words. For simplicity, all Arabic letters will be replaced with the letter '#'.

Each line will contain at most one English word. For a line containing an English word, the program that will fix the text will swap the words before the English word with the words after the English word. The words before the English word will remain in the same order. The words after the English word will also remain in the same order. For example, if the line is "# #### ### abc ##", it will be fixed to become "## abc # #### ###".

Please note that a line that contains words only of the same language is not corrupt.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Next 2T lines contain the test cases, each on a pair of lines.

The first line of each case contains a single integer N, the number of words in the line to fix (1 ≤ N ≤ 100). The second line contains N words, separated by single spaces, with no leading or trailing spaces, and each word will be at least 1 character and at most 10 characters long.

Each word will be either Arabic or English. Arabic words will consist of one to ten '#' letters, and English words will consist of one to ten English lower case letters. Each line contains at most one English word.

출력

For each test case, output, on a single line, the fixed line of input text.

제한

예제 입력 1

3
5
# #### ### abc ##
4
## ### ## #####
4
## ##### # xyz

예제 출력 1

## abc # #### ###
## ### ## #####
xyz ## ##### #

힌트

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2011 Arab Collegiate Programming Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /