Untitled

 avatar
unknown
plain_text
4 years ago
586 B
4
Indexable
#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 (iscntrl(c)) continue;
		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;
		}
	}
	if (!top)
		printf("YES");
	else
		printf("NO");
}
Editor is loading...