Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Numerics;
- namespace _11.Snowballs
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int lines = int.Parse(Console.ReadLine());
- bool openedBraket = false;
- bool isThereAProblamaticBraket = false;
- int openedBrakets = default;
- for (int i = 0; i < lines; i++)
- {
- string input = Console.ReadLine();
- for (int j = 0; j < input.Length; j++)
- {
- if (input[j] == '(' && !openedBraket)
- {
- openedBraket = true;
- openedBrakets++;
- }
- else if (input[j] == '(' && openedBraket)
- {
- isThereAProblamaticBraket = true;
- }
- if (input[j] == ')')
- {
- openedBraket = false;
- openedBrakets--;
- }
- }
- }
- if(openedBrakets % 2 == 0 && openedBrakets >= 0 && !isThereAProblamaticBraket)
- Console.WriteLine("BALANCED");
- else
- Console.WriteLine("UNBALANCED");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement