-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuri 1277.c
61 lines (57 loc) · 927 Bytes
/
uri 1277.c
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
56
57
58
59
60
61
#include <stdio.h>
#include<string.h>
int main () {
int N,T;
char nomes[5000];
char freq[5000];
char saida[5000];
char c;
int i,j,k,p,a;
scanf("%d",&T);
scanf("%c",&c);
while (T > 0) {
scanf("%d",&N);
scanf("%c",&c);
gets(nomes);
gets(freq);
saida[0] = '\0';
i = 0;
j = 0;
k = 0;
p = 0;
a = 0;
do {
if (freq[i] == 'P')
p++;
else if (freq[i] == 'A')
a++;
else if (freq[i] == ' ' || freq[i] == '\0') {
if (p < a*3) {
while (nomes[j] != ' ' && nomes[j] != '\0') {
saida[k] = nomes[j];
k++;
j++;
}
saida[k] = nomes[j];
k++;
j++;
p = 0;
a = 0;
}
else {
while (nomes[j] != ' ') {
j++;
}
j++;
p = 0;
a = 0;
}
}
i++;
} while (freq[i-1] != '\0');
saida[k-1] = '\0';
printf("%s\n",saida);
T--;
}
return 0;
}