QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251922#7776. 超现实树hos_lyric#5 793ms7196kbC++144.9kb2023-11-15 12:59:032024-07-04 02:25:31

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:25:31]
  • 评测
  • 测评结果:5
  • 用时:793ms
  • 内存:7196kb
  • [2023-11-15 12:59:03]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N, M;
char C[100'010];
vector<int> A, B;

vector<vector<int>> graph;


namespace brute {
vector<int> stack;
vector<Int> ans;
void dfs(int u, int p, int k) {
  if (C[u] == '{') {
    stack.push_back(0);
  } else if (C[u] == '|') {
    if (stack.empty()) return;
    ++stack.back();
  } else if (C[u] == '}') {
    if (stack.empty()) return;
    if (!~k) k = stack.back();
    if (k != stack.back()) return;
    stack.pop_back();
  } else {
    assert(false);
  }
  
  if (stack.empty()) {
    assert(~k);
    ++ans[k];
  }
  for (const int v : graph[u]) if (p != v) {
    dfs(v, u, k);
  }
  
  if (C[u] == '{') {
    stack.pop_back();
  } else if (C[u] == '|') {
    if (stack.empty()) assert(false);
    --stack.back();
  } else if (C[u] == '}') {
    assert(~k);
    stack.push_back(k);
  } else {
    assert(false);
  }
}

vector<Int> run() {
cerr<<"[brute::run]"<<endl;
  ans.assign(N, 0);
  for (int r = 0; r < N; ++r) {
    stack.clear();
    dfs(r, -1, -1);
  }
  return ans;
}
}  // brute


namespace sub2 {
vector<Int> run() {
cerr<<"[sub2::run]"<<endl;
  vector<int> hei(N + 1, 0);
  vector<int> mate(N, -1);
  {
    vector<int> stack;
    for (int u = 0; u < N; ++u) {
      if (C[u] == '{') {
        hei[u + 1] = hei[u] + 1;
        stack.push_back(u);
      } else if (C[u] == '|') {
        hei[u + 1] = hei[u];
      } else if (C[u] == '}') {
        hei[u + 1] = hei[u] - 1;
        if (stack.size()) {
          const int v = stack.back();
          stack.pop_back();
          mate[v] = u;
          mate[u] = v;
        }
      }
    }
  }
  vector<pair<int, int>> ps;
  for (int u = 0; u < N; ++u) if (u < mate[u]) {
    ps.emplace_back(u, mate[u]);
  }
  sort(ps.begin(), ps.end(), [&](const pair<int, int> &p0, const pair<int, int> &p1) -> bool {
    return ((hei[p0.first] != hei[p1.first]) ? (hei[p0.first] > hei[p1.first]) : (p0 < p1));
  });
  const int psLen = ps.size();
cerr<<"ps = "<<ps<<endl;
  vector<int> ids(N, -1);
  for (int j = 0; j < psLen; ++j) {
    ids[ps[j].first] = ids[ps[j].second] = j;
  }
  
  vector<int> ks(psLen, -1);
  set<int> ss;
  ss.insert(N);
  for (int j = 0; j < psLen; ++j) {
    auto check = [&](int k) -> void {
      if (!~ks[j]) ks[j] = k;
      if (ks[j] != k) ks[j] = -2;
    };
    const int u = ps[j].first;
    const int v = ps[j].second;
    int sz = v - u - 1;
    for (auto it = ss.lower_bound(u); *it < v; it = ss.erase(it)) {
      const int x = *it;
      const int y = mate[x];
      sz -= (y - x + 1);
      check(ks[ids[x]]);
    }
    assert(sz >= 0);
    check(sz);
    ss.insert(u);
  }
cerr<<"ks = "<<ks<<endl;
  
  vector<Int> ans(N, 0);
  for (int j0 = 0, j1 = 0; j0 < psLen; j0 = j1) {
    for (j1 = j0 + 1; j1 < psLen && ps[j1 - 1].second + 1 == ps[j1].first && ks[j1 - 1] == ks[j1]; ++j1) {}
    if (~ks[j0]) {
      ans[ks[j0]] += (Int)(j1 - j0) * (j1 - j0 + 1) / 2;
    }
  }
  return ans;
}
}  // sub2


int main() {
  for (; ~scanf("%d%d", &N, &M); ) {
    scanf("%s", C);
    A.resize(N - 1);
    B.resize(N - 1);
    for (int i = 0; i < N - 1; ++i) {
      scanf("%d%d", &A[i], &B[i]);
      --A[i];
      --B[i];
    }
    
    graph.assign(N, {});
    for (int i = 0; i < N - 1; ++i) {
      graph[A[i]].push_back(B[i]);
      graph[B[i]].push_back(A[i]);
    }
    
    bool spe2 = true;
    for (int i = 0; i < N - 1; ++i) {
      spe2 = spe2 && (abs(A[i] - B[i]) == 1);
    }
    
    vector<Int> ans;
    if (spe2) {
      ans = sub2::run();
    } else {
      ans = brute::run();
    }
    for (int k = 0; k <= M; ++k) {
      if (k) printf(" ");
      printf("%lld", ans[k]);
    }
    puts("");
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 3ms
memory: 4452kb

input:

4578 4576
|}}|}|{}{}|}|||{}}|}|||{|}||}}{}{{}|{{}|}}{}|{}{{}{{|{}}}|{||}||}}}}}|}}{||}|}{|{{}{}|{}{{}}}|{{}|}{}{}}}}}||}|}||||||{|}{}|}{|}{|}||}}}|}{{|}{{{}{}||{}}||}{}|}}{||{}}{}}|{|}{{|}}|{}||}}{}||}}|{|{{|}|{{}|{{{}}|||{}|||{{}}{||}{{|{{{{|{|}{|}{||}}}{{|}{}|{}}}{|}}{{|{|}{||{||||{|}}{{|}}{|||}}|...

output:

1736 642 213 88 42 16 8 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4577 tokens

Test #2:

score: 0
Accepted
time: 3ms
memory: 4276kb

input:

4598 4596
||||||||}|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||{|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||{|||||||||||||||||||||||||||||||||||||||||||||||...

output:

1 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 4597 tokens

Test #3:

score: 0
Accepted
time: 244ms
memory: 4540kb

input:

4562 4560
}{}{{}{{{}}}}{{{{{}{{}{{{}}{{}{{{}}}{}{}}{}{{{{}}}{{}{{}}{{{{{{{{{{}}}{}}}}}{{{{{}}}}}{{}}{{}}{}{{}}{}{{}}}}}{{}}}}{{{}{}{}}{}{{{}}{{{{{{{}}}{}}}}}{}}{}{{}{}}}}{}{{{{}}}}{}{{}{}}}}{}}}{}}{{{}}}{{{{}}}}}}{}}{}}{}}{}{{{{}}}}{}{{{{{{{}}}{{{}}}}}{}{}}{}{}}}}{{{}}{}}}{{}}{}}{}}}}}{}}{{}}{}}}{{{...

output:

5094047 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4561 tokens

Test #4:

score: 0
Accepted
time: 6ms
memory: 4252kb

input:

4558 4556
||{{}{}|{}||}}}{||}{{|{|{|||{|}|}|}}}{{}|}}}|}}|{{|||{{|{}}{||}|{}}||||{||{||}|}{|}{||{{{{}||{}}{{}}|||}{}||{|}|{{{}|{|{{}}|}|}}}}|{{|{|}|}|{|}{{}}{}||{}{}||}}|}}|}{|}|{}|}|{|{{{}}}|{|{{{{}}|}{{||{|{{||||}}{|}|{|||{}}}}{{{|{{{|||{{|{{}|{||||}}}||||}}}|{|}}|}{{|}{{{{}{|||}{{|}}{|}{}{{}}}}{}...

output:

2009 734 273 142 84 39 10 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4557 tokens

Test #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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4593 tokens

Test #7:

score: 0
Accepted
time: 3ms
memory: 4164kb

input:

4561 4559
{}{{}{{}|{}{||}|}|{|{}|}}||{}||}}{||}}{{{{||}}}}|{|}}|||||{{|{|}}||{||{||{}}|{|{|{|}}||}{}{{}{|{}{{||}||||{|||}{}}}{}{{{{}}|}|}}}}|{}{|{|||{|||}{{{}}|}{}{{}{}|}}|{}|{|{}}{}{}}}|}|}{{}||{|}|}{}|}}}}|{}|}{{{}}{}|}}|}{{|{|}{{||{|}{|}}}}}{{||{}|{{{}{{|}}|{}}{}}}}}||}|{{{{{}}}||}||}|{{{{}}|}}{{...

output:

1828 565 244 83 27 11 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4560 tokens

Test #8:

score: 0
Accepted
time: 41ms
memory: 4268kb

input:

4579 4577
{}}}}}{{}}{{{}}{}{{{}}}}{{{{}{{{{{{{{{{{{{{{}{}{}{}{}{{}}}}{{{}}{}{}{}}}}{{}}{}{}}{{{{}{{{{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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4556 tokens

Test #10:

score: 0
Accepted
time: 4ms
memory: 4176kb

input:

4586 4584
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||...

output:

0 1 3 4 3 1 2 1 1 0 1 3 2 2 2 2 1 2 1 0 0 1 1 2 2 2 2 1 0 1 0 1 2 2 2 0 3 1 2 1 1 1 2 1 0 0 2 1 0 3 1 0 0 0 0 1 3 3 5 3 1 3 1 2 2 3 3 2 1 2 2 1 1 2 2 0 0 1 2 1 1 3 1 0 1 0 1 1 1 2 1 1 0 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 1 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4585 tokens

Test #11:

score: 0
Accepted
time: 2ms
memory: 4308kb

input:

4596 4594
|}}}}|}}}|}}|}}}}|}}}}}|}|}|}}}}}|}}}||||}}|||}|}}|}}|||}|}|}|}|}|||||}}|}|}}|}|}}}}}}}}}}}}}}|}}}}}}||||}|||}}}}|}}}}|}|}|}|}}}|}|}}}}}||}}}}}|}||}}|}|}}}}||}}|}|}}|}||||||}}}}}||}||||}|}}}}||}}}}|||}|}|||}}}|||}}}}}|}}|||}|||}}}|}}||}|}}}}}||}}}||||}}|}|}|||}}}|}|}}|||||}}}|}}||}||}}||}}...

output:

0 0 2 0 1 3 0 0 2 0 0 1 2 0 0 1 1 1 0 1 1 0 2 0 2 3 1 1 2 3 0 2 1 2 1 0 0 0 3 1 4 4 1 5 2 2 1 1 0 3 0 1 0 0 1 0 0 0 0 1 2 0 2 4 1 1 5 1 2 3 1 4 1 1 3 0 0 2 0 3 1 0 3 1 0 2 0 2 1 0 1 3 0 3 1 2 3 1 0 0 2 0 0 5 3 0 1 0 4 0 0 2 1 2 1 1 1 2 1 1 0 1 1 0 2 0 2 2 2 1 1 0 1 2 0 2 1 3 2 0 0 0 1 1 0 0 2 0 0 3 ...

result:

ok 4595 tokens

Test #12:

score: 0
Accepted
time: 2ms
memory: 4236kb

input:

4562 4560
}|}}}|}}}}}|}}}}}}|}}}}}}}}}}}}}|}}}}}}}}}}}}}|}}}}|}}}}}}}}}}}}|}}}}}}}}}|}}}}|}}|}}}}}|}|||}}}}}|}}}}|}|}}|}}}}}}}}}|}}}}}}}}}}}}}}}}}}}}}}|}}|}}}}}}|}}}}|}}}}}|}}}|}}}}}}}}}}|}}|}}}}|}}}}|}}}}}}}}}}}}}}}}|}}|}}}}}}}}}}}}}|}}}|}}}}}}}}}}}}}}}}}}}}}}}}|}}}}}}}}}}}}}}}}}}}||}}}}}}}}}}}}}}}...

output:

9 4 7 10 9 7 6 9 12 16 1 8 12 7 10 12 2 3 10 6 8 12 12 17 10 10 5 6 7 10 12 9 12 2 7 12 1 6 9 11 6 9 9 12 10 10 7 10 7 7 5 8 5 2 5 9 13 7 4 7 10 6 6 3 5 13 7 13 10 7 7 8 5 9 10 8 9 10 10 7 3 13 6 9 8 9 6 6 6 7 10 7 7 7 7 12 9 8 6 9 7 6 5 9 4 10 11 7 8 10 11 8 8 7 8 9 13 8 8 6 7 6 9 7 9 2 6 5 5 11 14...

result:

ok 4561 tokens

Test #13:

score: 0
Accepted
time: 2ms
memory: 4832kb

input:

4578 4576
|}|||||||||||||||||||}|||||||}||||}}|||||||||||||||||||}||||||||||||||||}||}||}|||||||||||||||||||}||||||||||||||||||||||}}|||||||}}||||||||||||||||||||||||||||||||||||||||}||||||}||}||}|}||||}|||||}||||||||||||}||||||||||||}|||||||||||||||}|}|||||||}||||||||||||||||}||||||||||||||||}|||||...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 ...

result:

ok 4577 tokens

Test #14:

score: 0
Accepted
time: 67ms
memory: 4196kb

input:

4560 4558
}}}{}{{{{}{}{{}}{{{}{}}}}{{{{}}}{{{{}{{}{}{{{{{{}}}}}{}}{}|{{}{{}}{}{}}{{}{|{{{{}{{{{}{{}|{}|}}}{{{}}}}{}}}}}}}{{}}{{{{}}}{{}}{{}}|{}}{{}{{}}{}{}}}}}}{{}}|}{}}{}}}{{{}|{}{{}}}}}}}{}}}{{{}{{{{{{}{{{}}}|{}}}{{}}}}{{{}}}}}}}{}|}}{}{}{}|{{{{}{{{{}|{{}{}{}{}{}}{}}}{}}}}{{{|}}}}}}}}}{}}}{{{}{{{{...

output:

200 3999489 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4559 tokens

Test #15:

score: 0
Accepted
time: 3ms
memory: 4432kb

input:

4582 4580
{|}}{|{}}{|{}}|{}|{|}{||{{{|{|}}}{}}|{}}{{|{|}}{{||{{|}|{}|||{}||}{}{{{|{|||{}}{||{||}}{|{|{|{{|||}}}||{{{{{|}{}|}{{}{}{{|{}}{}||}}{}{{{}{|}|}}{{{}|}}}}{}}{|{}}}}}{||{{{{|{|}{{}||{||}{{}|{|}}}}|{|||}}||{|{{}|{|}}{}{{{|}|}|}||}|{|}{{|}|{}}{{{{|{|{{|{}}{{|}|{}||{|{||}{}{}}}|||{|{}{{{|||}{{{}...

output:

1782 724 245 89 41 15 6 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 4581 tokens

Subtask #2:

score: 0
Runtime Error

Test #16:

score: 0
Runtime Error

input:

99981 99979
}|}{|}|}||{{{{|}}}{|}|}|}||||}}}|||||}|{{|||{|{}||}}{}}}}||{}{{}{{|{}{|}}}{|}||{|{}}|{{{|}{}{}}|}{}}{}||||}{|{{}{|{}}{}}|}}{|}{{}{{}|{|||{|{{}}{}{|}{||}}||}|}|}|{}{{}|}||}{{|{}{}}}||}}|}}||{||||||}}{}}}|}}|}}}}|}}}}||||{}}{{|{{}|}|{{}{|}||}{|}|}||{}}|}|{{{{{||{}}{}|{|}{{{|}|{|{|}}|{|}{}}...

output:

14496 4161 1282 407 150 42 18 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #26:

score: 0
Time Limit Exceeded

input:

99990 0
}}}}{{{}{{{{}}}}}{{{{{}}{{}{}}}{}}}{}}}{{{}{{{{}{}}}{{}{{{}{}{}{{{}}{{}}{{{}}{{{{{}{}{}{}}{{{}{}{}{}}{}{}{{}}}{{{}{}{}}{}{}{}}}}}{}{{{}{{{}}{}}}}}{{}}{{{}}}{{}{{}{}{}}{}{}{{}}}}{}{{{}{}{{}{{}{{}}}{}}{{}{}}}}}}}}}}}}{{}}{}{}}}{{{{{}{{{}}{}}{}{{{{}}}{}}}{{}{}{{}{}}{}}}}{}{}{}}{{}}}{}{{}}{{{}}{...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #46:

score: 25
Accepted
time: 35ms
memory: 7132kb

input:

49951 49949
}|}|}|{{{|{|}{|||||}|{}{|{{{{}||}}{|{|}|}{{{|{}}|{|{||{}{{{}{}||||}||}{{{{|{||{|||}{{|}|{}{{{}|{}}||}{|}}}||}{}|||{{{{{}}{||}||}}||{}}{|}{}}{|{{|}|{}|{}|}}|}|{|{|}{{{}}{|{}|{}}||}}}{{{}}|{{||||||||}{|}}{}}}{{}}}{}{||{}}}}}}}{|||{|{{}|{{{{}|}||||{}}|{|||{||{|{|{|||}{}}|}{{{}|{{{|}|}{{|{}}...

output:

18354 6771 2539 1034 403 141 58 22 6 4 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 49950 tokens

Test #47:

score: 0
Accepted
time: 793ms
memory: 7196kb

input:

49986 49984
}}|}|}}{}}|{}{{{|{}||{|{||}}||}}||}}|{||||{|{}}{|{}|}{{||{|}}{{{||{|}{}}|}{{}{{||{}}{}|{{|||{||{}}}|{}}||}|{||}}{|{|{}|}}{}}}{|{{|}{|{}|{}{{|}}{{}}}{|{{{}|{|}||{|}}{}{}}}|}{}{}{}|}|||{|}|{{}|}}{||}|}{|}}|||{{}{|{}}|}}}|||}}}|{}|{}}{}{{|||||}}{|{|}||}}{|{{{{}}}||{|{|{{{}{{{|{{}{}{|}{||}{}...

output:

23672 8952 3214 1437 522 279 117 56 27 15 7 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 49985 tokens

Test #48:

score: -25
Time Limit Exceeded

input:

49995 49993
{|||||||||}||||||||||||||}|||||||||||||||||||||||||||}}|||||||||||||||||}|||||||{|||||||||||||||{|||||}|{||||||{|||||||||||||||||||||||}|||||||||||||{|||||||{||||||||||||||||||||||{||||}||||||||||{||||||||||||||||||||||{||||||}||||||{||||}}|||||||||{|||||||||||||{||||||||||||||||||||||||...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%