Submission #419523

# Submission time Handle Problem Language Result Execution time Memory
419523 2021-06-07T08:27:25 Z vato_chachanidze Zagrade (COI17_zagrade) C++14
0 / 100
213 ms 4788 KB
#include<bits/stdc++.h>
using namespace std;
long long n,l1,l2,k,ans,gaxs,shekr;
string s;
int main()
{
	cin>>n;
	cin>>s;
	for(k=1;k<=n-1;k++)
	{
		cin>>l1>>l2;
	}
	for(k=1;k<=n;k++)
	{
		if(s[k-1]=='('){
			gaxs++;
		}
		else{
			if(gaxs==0)
			{
				shekr=0;
				continue;
			}
			if(gaxs>1)
			{
				ans+=1;
			}
			if(gaxs==1)
			{
				ans+=1;
				ans+=shekr;
				shekr++;
			}
			gaxs--;
		}
	}

	gaxs=0;
	shekr=0;
	for(k=n;k>=1;k--)
	{
		if(s[k-1]=='('){
			gaxs++;
		}
		else{
			if(gaxs==0)
			{
				shekr=0;
				continue;
			}
			if(gaxs>1)
			{
				ans+=1;
			}
			if(gaxs==1)
			{
				ans+=1;
				ans+=shekr;
				shekr++;
			}
			gaxs--;
		}
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 4788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -