Start: Jul, 03, 2019 08:38:00
2019年度暑期短学期第七天 助教场
End: Jul, 04, 2019 23:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 3ms
Memory: 1756kB
Author: 2018212212125
In contest: 1292

#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<iostream>
#define ll long long 
using namespace std;
const int maxn = 1010;
const int inf = 0x3f3f3f3f;
int  n, m, k, N, t;
char ch[maxn];
int main()
{
	scanf("%d", &t);
	getchar();
	while (t--) {
		gets(ch);
		n = strlen(ch);
		int i;
		m = 0;
		for (i = n - 1; i >= 5; --i)
		{
			if (ch[i] == ' '&&ch[i - 1] == 't'&&ch[i - 2] == 'n'&&ch[i - 3] == 'i'&&ch[i - 4] == 'r'&&ch[i - 5] == 'p')
				ch[i] = '(', m++;
		}
		for (int j = 0; j < n; ++j)
			printf("%c", ch[j]);
		for (i = 1; i <= m; ++i)
			printf(")");
		printf("\n");
	}

}