Untitled

mail@pastecode.io avatar
unknown
plain_text
4 years ago
520 B
2
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

char stack[102 * 1024];
signed main() {
	char c;
	int top = 0;
	while ((c = getc(stdin)) != EOF) {
		if (c == '[')
			stack[top++] = ']';
		else if (c == '<')
			stack[top++] = '>';
		else if (c == '{')
			stack[top++] = '}';
		else if (c == '(')
			stack[top++] = ')';
		else if (top && c == stack[top - 1])
			--top;
		else {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
}