-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path1069.cpp
More file actions
36 lines (36 loc) · 888 Bytes
/
Copy path1069.cpp
File metadata and controls
36 lines (36 loc) · 888 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
// Ivan Carvalho
// Solution to https://www.beecrowd.com.br/judge/problems/view/1069
#include <cstdio>
#include <cstring>
#define MAX 1010
char pilha[MAX];
int tamanho;
void clear() { tamanho = 0; }
void pop() {
if (tamanho > 0) tamanho--;
}
void push(char x) { pilha[++tamanho] = x; }
char top() { return pilha[tamanho]; }
int main() {
int n, i, j;
char pedras[MAX];
scanf("%d", &n);
for (i = 0; i < n; i++) {
int resposta = 0;
clear();
scanf("%s", pedras);
for (j = 0; j < strlen(pedras); j++) {
char davez = pedras[j];
if (davez == '<') push('<');
if (davez == '>') {
if (top() == '<') {
resposta++;
pop();
} else
push('>');
}
}
printf("%d\n", resposta);
}
return 0;
}