Submission #26289

# Submission time Handle Problem Language Result Execution time Memory
26289 2017-06-29T05:14:20 Z 까제비(#1110) Zagrade (COI17_zagrade) C++14
30 / 100
6 ms 4948 KB
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 6e5 + 100;

int N, Lv[MAX_N]; char S[MAX_N];
ll Ans = 0;
void subtask() {
	for(int i=0; i<MAX_N; i++) Lv[i] = 0;
	int lv = MAX_N/2;
	for(int i=0; i<N; i++) {
		if(S[i] == '(') {
			Lv[lv]++;
			lv++;
		} else {
			Lv[lv] = 0;
			lv--;
			Ans += Lv[lv];
		}
	}
}
int main() {
	cin >> N; scanf("%s", S);
	subtask();
	reverse(S, S+N);
	subtask();
	printf("%lld\n", Ans);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:35:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  cin >> N; scanf("%s", S);
                          ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 6 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 6 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 6 ms 4948 KB Output is correct
9 Correct 6 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 6 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -