Result: Accepted
Time: 3ms
Memory: 1856kB
#include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
int i, j, k;
int m, n, p;
char a[100010];
int main() {
scanf("%d", &n);
getchar();
while (n--) {
gets(a);
int flag = 0;
for (i = 0; i < strlen(a); i++) {
if (a[i] == 'p' && a[i + 1] == 'r' &&a[i + 2] == 'i' && a[i + 3] == 'n' &&a[i + 4] == 't'&&a[i + 5] == ' ') {
a[i + 5] = '(';
flag = 1;
break;
}
}
if (flag == 1) {
int s = strlen(a);
a[s] = ')';
a[s + 1] = '\0';
}
puts(a);
}
return 0;
}