Submission #66305

# Submission time Handle Problem Language Result Execution time Memory
66305 2018-08-10T07:53:43 Z ekrem Zagrade (COI17_zagrade) C++
0 / 100
24 ms 3572 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)>>1)
#define N 1000005
using namespace std;

int n, ans, a[N], pre[N];
char s[N];
map < int , int > h;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %s",&n, s + 1);
	for(int i = 1; i <= n; i++){
		a[i] = (s[i] == '(') ? 1 : -1;
		pre[i] = pre[i - 1] + a[i];
		// cout << pre[i] << " ";
	}

	// up(1, -n, n, 0);
	h[0]++;
	h[pre[1]]++;
	// up(1, -n, n, pre[1]);

	for(int i = 2; i <= n; i++){
		ans += h[pre[i]];
		h[pre[i]]++;
	}
	printf("%d\n",ans);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %s",&n, s + 1);
  ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -