# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244162 | MatesV13 | Zagrade (COI17_zagrade) | C++11 | 2367 ms | 1048580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long n, a, b, ans;
char z[300005];
vector<int> c[300005];
multiset<int> zag[2][300005];
void help(int idx){
cout << "Obraduje se " << idx << endl;
cout << "0: (";
for (multiset<int>::iterator it=zag[0][idx].begin(); it!=zag[0][idx].end(); it++)
cout << *it << " ";
cout << ")" << endl;
cout << "1: (";
for (multiset<int>::iterator it=zag[1][idx].begin(); it!=zag[1][idx].end(); it++)
cout << *it << " ";
cout << ")" << endl;
cout << "Trenutni ans je " << ans << endl << endl;
}
void solve(int idx, int par){
for (int i=0; i<c[idx].size(); i++)
if (c[idx][i]!=par)
solve(c[idx][i], idx);
int vrsta;
if (z[idx]=='(') vrsta=1;
else vrsta=-1;
for (int i=0; i<c[idx].size()-1; i++){
for (multiset<int>::iterator it=zag[0][c[idx][i]].begin(); it!=zag[0][c[idx][i]].end(); it++)
for (int j=i+1; j<c[idx].size(); j++){
ans+=(1LL*zag[1][c[idx][j]].count(-(*it+vrsta)));
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |