forked from srikanthmalipatel/Spoj-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathACPC11A-6728067-src.cpp
More file actions
55 lines (53 loc) · 840 Bytes
/
ACPC11A-6728067-src.cpp
File metadata and controls
55 lines (53 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <deque>
using namespace std;
int main ()
{
int T;
cin >> T;
for( int i=0; i<T; ++i )
{
int N;
cin >> N;
vector<string> left, right;
string englishWord = "", t;
bool leftB = true;
for( int j=0; j<N; ++j )
{
cin >> t;
if( t[0] == '#' && leftB )
left.push_back( t );
else if( t[0] != '#' )
{
leftB = false;
englishWord = t;
}
else
{
right.push_back( t );
}
}
int sR = right.size(), sL = left.size();
for( int j=0; j<sR; ++j )
{
if( j != 0 ) cout << " ";
cout << right[j];
}
if( sR > 0 && englishWord.size() > 0 ) cout << " ";
cout << englishWord;
if( sL > 0 && englishWord.size() > 0 ) cout << " ";
for( int j=0; j<sL; ++j )
{
if( j != 0 ) cout << " ";
cout << left[j];
}
cout << endl;
}
}