Submission #66305

#TimeUsernameProblemLanguageResultExecution timeMemory
66305ekremZagrade (COI17_zagrade)C++98
0 / 100
24 ms3572 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...