QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245565#7767. 数据结构hos_lyric#10 49ms5084kbC++1418.0kb2023-11-10 02:08:252024-07-04 02:24:10

Judging History

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

  • [2024-07-04 02:24:10]
  • 评测
  • 测评结果:10
  • 用时:49ms
  • 内存:5084kb
  • [2023-11-10 02:08:25]
  • 提交

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")


// T: monoid representing information of an interval.
//   T()  should return the identity.
//   T(S s)  should represent a single element of the array.
//   T::push(T &l, T &r)  should push the lazy update.
//   T::pull(const T &l, const T &r)  should pull two intervals.
template <class T> struct SegmentTreeRange {
  int logN, n;
  vector<T> ts;
  SegmentTreeRange() : logN(0), n(0) {}
  explicit SegmentTreeRange(int n_) {
    for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
    ts.resize(n << 1);
  }
  template <class S> explicit SegmentTreeRange(const vector<S> &ss) {
    const int n_ = ss.size();
    for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
    ts.resize(n << 1);
    for (int i = 0; i < n_; ++i) at(i) = T(ss[i]);
    build();
  }
  T &at(int i) {
    return ts[n + i];
  }
  void build() {
    for (int u = n; --u; ) pull(u);
  }

  inline void push(int u) {
    ts[u].push(ts[u << 1], ts[u << 1 | 1]);
  }
  inline void pull(int u) {
    ts[u].pull(ts[u << 1], ts[u << 1 | 1]);
  }

  // Applies T::f(args...) to [a, b).
  template <class F, class... Args>
  void ch(int a, int b, F f, Args &&... args) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return;
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) (ts[aa++].*f)(args...);
      if (bb & 1) (ts[--bb].*f)(args...);
    }
    for (int h = 1; h <= logN; ++h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) pull(aa);
      } else {
        if ((aa << h) != a) pull(aa);
        if ((bb << h) != b) pull(bb);
      }
    }
  }

  // Calculates the product for [a, b).
  T get(int a, int b) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return T();
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    T prodL, prodR, t;
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) { t.pull(prodL, ts[aa++]); prodL = t; }
      if (bb & 1) { t.pull(ts[--bb], prodR); prodR = t; }
    }
    t.pull(prodL, prodR);
    return t;
  }

  // Calculates T::f(args...) of a monoid type for [a, b).
  //   op(-, -)  should calculate the product.
  //   e()  should return the identity.
  template <class Op, class E, class F, class... Args>
#if __cplusplus >= 201402L
  auto
#else
  decltype((std::declval<T>().*F())())
#endif
  get(int a, int b, Op op, E e, F f, Args &&... args) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return e();
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    auto prodL = e(), prodR = e();
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) prodL = op(prodL, (ts[aa++].*f)(args...));
      if (bb & 1) prodR = op((ts[--bb].*f)(args...), prodR);
    }
    return op(prodL, prodR);
  }

  // Find min b s.t. T::f(args...) returns true,
  // when called for the partition of [a, b) from left to right.
  //   Returns n + 1 if there is no such b.
  template <class F, class... Args>
  int findRight(int a, F f, Args &&... args) {
    assert(0 <= a); assert(a <= n);
    if ((T().*f)(args...)) return a;
    if (a == n) return n + 1;
    a += n;
    for (int h = logN; h; --h) push(a >> h);
    for (; ; a >>= 1) if (a & 1) {
      if ((ts[a].*f)(args...)) {
        for (; a < n; ) {
          push(a);
          if (!(ts[a <<= 1].*f)(args...)) ++a;
        }
        return a - n + 1;
      }
      ++a;
      if (!(a & (a - 1))) return n + 1;
    }
  }

  // Find max a s.t. T::f(args...) returns true,
  // when called for the partition of [a, b) from right to left.
  //   Returns -1 if there is no such a.
  template <class F, class... Args>
  int findLeft(int b, F f, Args &&... args) {
    assert(0 <= b); assert(b <= n);
    if ((T().*f)(args...)) return b;
    if (b == 0) return -1;
    b += n;
    for (int h = logN; h; --h) push((b - 1) >> h);
    for (; ; b >>= 1) if ((b & 1) || b == 2) {
      if ((ts[b - 1].*f)(args...)) {
        for (; b <= n; ) {
          push(b - 1);
          if (!(ts[(b <<= 1) - 1].*f)(args...)) --b;
        }
        return b - n - 1;
      }
      --b;
      if (!(b & (b - 1))) return -1;
    }
  }
};

////////////////////////////////////////////////////////////////////////////////


struct Hld {
  int n, rt;
  // needs to be tree
  // vertex lists
  // modified in build(rt) (parent removed, heavy child first)
  vector<vector<int>> graph;
  vector<int> sz, par, dep;
  int zeit;
  vector<int> dis, fin, sid;
  // head vertex (minimum depth) in heavy path
  vector<int> head;

  Hld() : n(0), rt(-1), zeit(0) {}
  explicit Hld(int n_) : n(n_), rt(-1), graph(n), zeit(0) {}
  void ae(int u, int v) {
    assert(0 <= u); assert(u < n);
    assert(0 <= v); assert(v < n);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  void dfsSz(int u) {
    sz[u] = 1;
    for (const int v : graph[u]) {
      auto it = std::find(graph[v].begin(), graph[v].end(), u);
      if (it != graph[v].end()) graph[v].erase(it);
      par[v] = u;
      dep[v] = dep[u] + 1;
      dfsSz(v);
      sz[u] += sz[v];
    }
  }
  void dfsHld(int u) {
    dis[u] = zeit++;
    const int deg = graph[u].size();
    if (deg > 0) {
      int vm = graph[u][0];
      int jm = 0;
      for (int j = 1; j < deg; ++j) {
        const int v = graph[u][j];
        if (sz[vm] < sz[v]) {
          vm = v;
          jm = j;
        }
      }
      swap(graph[u][0], graph[u][jm]);
      head[vm] = head[u];
      dfsHld(vm);
      for (int j = 1; j < deg; ++j) {
        const int v = graph[u][j];
        head[v] = v;
        dfsHld(v);
      }
    }
    fin[u] = zeit;
  }
  void build(int rt_) {
    assert(0 <= rt_); assert(rt_ < n);
    rt = rt_;
    sz.assign(n, 0);
    par.assign(n, -1);
    dep.assign(n, -1);
    dep[rt] = 0;
    dfsSz(rt);
    zeit = 0;
    dis.assign(n, -1);
    fin.assign(n, -1);
    head.assign(n, -1);
    head[rt] = rt;
    dfsHld(rt);
    assert(zeit == n);
    sid.assign(n, -1);
    for (int u = 0; u < n; ++u) sid[dis[u]] = u;
  }

  friend ostream &operator<<(ostream &os, const Hld &hld) {
    const int maxDep = *max_element(hld.dep.begin(), hld.dep.end());
    vector<string> ss(2 * maxDep + 1);
    int pos = 0, maxPos = 0;
    for (int j = 0; j < hld.n; ++j) {
      const int u = hld.sid[j];
      const int d = hld.dep[u];
      if (hld.head[u] == u) {
        if (j != 0) {
          pos = maxPos + 1;
          ss[2 * d - 1].resize(pos, '-');
          ss[2 * d - 1] += '+';
        }
      } else {
        ss[2 * d - 1].resize(pos, ' ');
        ss[2 * d - 1] += '|';
      }
      ss[2 * d].resize(pos, ' ');
      ss[2 * d] += std::to_string(u);
      if (maxPos < static_cast<int>(ss[2 * d].size())) {
        maxPos = ss[2 * d].size();
      }
    }
    for (int d = 0; d <= 2 * maxDep; ++d) os << ss[d] << '\n';
    return os;
  }

  bool contains(int u, int v) const {
    return (dis[u] <= dis[v] && dis[v] < fin[u]);
  }
  int lca(int u, int v) const {
    assert(0 <= u); assert(u < n);
    assert(0 <= v); assert(v < n);
    for (; head[u] != head[v]; ) (dis[u] > dis[v]) ? (u = par[head[u]]) : (v = par[head[v]]);
    return (dis[u] > dis[v]) ? v : u;
  }
  int jumpUp(int u, int d) const {
    assert(0 <= u); assert(u < n);
    assert(d >= 0);
    if (dep[u] < d) return -1;
    const int tar = dep[u] - d;
    for (u = head[u]; ; u = head[par[u]]) {
      if (dep[u] <= tar) return sid[dis[u] + (tar - dep[u])];
    }
  }
  int jump(int u, int v, int d) const {
    assert(0 <= u); assert(u < n);
    assert(0 <= v); assert(v < n);
    assert(d >= 0);
    const int l = lca(u, v);
    const int du = dep[u] - dep[l], dv = dep[v] - dep[l];
    if (d <= du) {
      return jumpUp(u, d);
    } else if (d <= du + dv) {
      return jumpUp(v, du + dv - d);
    } else {
      return -1;
    }
  }
  // [u, v) or [u, v]
  template <class F> void doPathUp(int u, int v, bool inclusive, F f) const {
    assert(contains(v, u));
    for (; head[u] != head[v]; u = par[head[u]]) f(dis[head[u]], dis[u] + 1);
    if (inclusive) {
      f(dis[v], dis[u] + 1);
    } else {
      if (v != u) f(dis[v] + 1, dis[u] + 1);
    }
  }
  // not path order, include lca(u, v) or not
  template <class F> void doPath(int u, int v, bool inclusive, F f) const {
    const int l = lca(u, v);
    doPathUp(u, l, false, f);
    doPathUp(v, l, inclusive, f);
  }

  // (vs, ps): compressed tree
  // vs: DFS order (sorted by dis)
  // vs[ps[x]]: the parent of vs[x]
  // ids[vs[x]] = x, not set for non-tree vertex
  vector<int> ids;
  pair<vector<int>, vector<int>> compress(vector<int> us) {
    // O(n) first time
    ids.resize(n, -1);
    std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
      return (dis[u] < dis[v]);
    });
    us.erase(std::unique(us.begin(), us.end()), us.end());
    int usLen = us.size();
    assert(usLen >= 1);
    for (int x = 1; x < usLen; ++x) us.push_back(lca(us[x - 1], us[x]));
    std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
      return (dis[u] < dis[v]);
    });
    us.erase(std::unique(us.begin(), us.end()), us.end());
    usLen = us.size();
    for (int x = 0; x < usLen; ++x) ids[us[x]] = x;
    vector<int> ps(usLen, -1);
    for (int x = 1; x < usLen; ++x) ps[x] = ids[lca(us[x - 1], us[x])];
    return make_pair(us, ps);
  }
};

////////////////////////////////////////////////////////////////////////////////


template <class T> struct NodeSum {
  int sz;
  T sum;
  T lz;
  NodeSum() : sz(0), sum(0), lz(0) {}
  NodeSum(const T &val) : sz(1), sum(val), lz(0) {}
  void push(NodeSum &l, NodeSum &r) {
    l.add(lz);
    r.add(lz);
    lz = 0;
  }
  void pull(const NodeSum &l, const NodeSum &r) {
    sz = l.sz + r.sz;
    sum = l.sum + r.sum;
  }
  void add(const T &val) {
    sum += val * sz;
    lz += val;
  }
  T getSum() const {
    return sum;
  }
  bool accSum(T &acc, const T &tar) const {
    if (acc + sum >= tar) return true;
    acc += sum;
    return false;
  }
};
template <class T> T getSum(SegmentTreeRange<NodeSum<T>> &seg, int a, int b) {
  return seg.get(a, b,
                 [&](const T &l, const T &r) -> T { return l + r; },
                 [&]() -> T { return 0; },
                 &NodeSum<T>::getSum);
}


using U = unsigned long long;

int N, Q;
vector<int> A, B;
vector<int> O, X, Y, K;
vector<U> V;

Hld hld;


namespace brute {
vector<int> on;
vector<U> as;
U sum;
vector<int> vis;
void dfs(int u, int k, U val) {
  if (!vis[u]) {
    vis[u] = 1;
    sum += as[u] += val;
    if (k) {
      const int p = hld.par[u];
      if (~p && !on[p]) {
        dfs(p, k - 1, val);
      }
      for (const int v : hld.graph[u]) if (!on[v]) {
        dfs(v, k - 1, val);
      }
    }
  }
}

vector<U> run() {
cerr<<"[brute::run]"<<endl;
  on.assign(N, 0);
  as.assign(N, 0);
  vector<U> anss;
  for (int q = 0; q < Q; ++q) {
    vector<int> us;
    if (O[q] == 1 || O[q] == 3) {
      hld.doPath(X[q], Y[q], true, [&](int l, int r) -> void {
        for (int j = l; j < r; ++j) us.push_back(hld.sid[j]);
      });
    }
    for (const int u : us) on[u] = 1;
    sum = 0;
    vis.assign(N, 0);
    for (const int u : us) dfs(u, K[q], V[q]);
// cerr<<"on = "<<on<<", us = "<<us<<", as = "<<as<<", sum = "<<sum<<endl;
    if (O[q] == 1) {
      //
    } else if (O[q] == 2) {
      for (int j = hld.dis[X[q]]; j < hld.fin[X[q]]; ++j) as[hld.sid[j]] += V[q];
    } else if (O[q] == 3) {
      anss.push_back(sum);
    } else if (O[q] == 4) {
      U ans = 0;
      for (int j = hld.dis[X[q]]; j < hld.fin[X[q]]; ++j) ans += as[hld.sid[j]];
      anss.push_back(ans);
    } else {
      assert(false);
    }
    for (const int u : us) on[u] = 0;
  }
  return anss;
}
}  // brute


namespace sub2 {
vector<U> run() {
cerr<<"[sub2::run]"<<endl;
  SegmentTreeRange<NodeSum<U>> seg(vector<U>(N, 0));
  vector<U> anss;
  for (int q = 0; q < Q; ++q) {
    if (O[q] == 1) {
      int x = X[q], y = Y[q];
      if (x > y) swap(x, y);
      x = max(x - K[q], 0);
      y = min(y + K[q], N - 1);
      hld.doPath(x, y, true, [&](int l, int r) -> void {
        seg.ch(l, r, &NodeSum<U>::add, V[q]);
      });
    } else if (O[q] == 2) {
      seg.ch(hld.dis[X[q]], hld.fin[X[q]], &NodeSum<U>::add, V[q]);
    } else if (O[q] == 3) {
      int x = X[q], y = Y[q];
      if (x > y) swap(x, y);
      x = max(x - K[q], 0);
      y = min(y + K[q], N - 1);
      U ans = 0;
      hld.doPath(x, y, true, [&](int l, int r) -> void {
        ans += getSum(seg, l, r);
      });
      anss.push_back(ans);
    } else if (O[q] == 4) {
      const U ans = getSum(seg, hld.dis[X[q]], hld.fin[X[q]]);
      anss.push_back(ans);
    } else {
      assert(false);
    }
  }
  return anss;
}
}  // sub2


namespace sub5 {
int lss[200'010][4], rss[200'010][4];
vector<U> run() {
cerr<<"[sub5::run]"<<endl;
  vector<int> ids(N, -1);
  vector<int> que;
  que.push_back(0);
  for (int j = 0; j < N; ++j) {
    const int u = que[j];
    ids[u] = j;
    for (const int v : hld.graph[u]) {
      que.push_back(v);
    }
  }
  for (int u = 0; u < N; ++u) {
    fill(lss[u], lss[u] + 4, N);
    fill(rss[u], rss[u] + 4, 0);
  }
  for (int u = 0; u < N; ++u) {
    int v = u;
    for (int k = 0; k < 4; ++k) {
      chmin(lss[v][k], ids[u]);
      chmax(rss[v][k], ids[u] + 1);
      v = hld.par[v];
      if (!~v) break;
    }
  }
// cerr<<"que = "<<que<<endl;
// for(int u=0;u<N;++u){pv(lss[u],lss[u]+4);pv(rss[u],rss[u]+4);}
  SegmentTreeRange<NodeSum<U>> seg(vector<U>(N, 0));
  vector<U> anss;
  for (int q = 0; q < Q; ++q) {
    vector<pair<int, int>> ps;
    auto add = [&](int l, int r) -> void {
      if (l <= r) {
        ps.emplace_back(l, r);
      }
    };
    {
      int u = X[q];
      for (int k = 0; ; ++k) {
        add(lss[u][K[q] - k], rss[u][K[q] - k]);
        if (k == K[q]) break;
        add(lss[u][K[q] - k - 1], rss[u][K[q] - k - 1]);
        u = hld.par[u];
        if (!~u) break;
      }
    }
// cerr<<X[q]<<" "<<K[q]<<": ps = "<<ps<<endl;
    if (O[q] == 1) {
      for (const auto &p : ps) {
        seg.ch(p.first, p.second, &NodeSum<U>::add, V[q]);
      }
    } else {
      U ans = 0;
      for (const auto &p : ps) {
        ans += getSum(seg, p.first, p.second);
      }
      anss.push_back(ans);
    }
  }
  return anss;
}
}  // sub5


int main() {
  for (; ~scanf("%d%d", &N, &Q); ) {
    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];
    }
    O.assign(Q, -1);
    X.assign(Q, -1);
    Y.assign(Q, -1);
    K.assign(Q, -1);
    V.assign(Q, 0);
    for (int q = 0; q < Q; ++q) {
      scanf("%d", &O[q]);
      if (O[q] == 1) {
        scanf("%d%d%d%llu", &X[q], &Y[q], &K[q], &V[q]);
        --X[q];
        --Y[q];
      } else if (O[q] == 2) {
        scanf("%d%llu", &X[q], &V[q]);
        --X[q];
      } else if (O[q] == 3) {
        scanf("%d%d%d", &X[q], &Y[q], &K[q]);
        --X[q];
        --Y[q];
      } else if (O[q] == 4) {
        scanf("%d", &X[q]);
        --X[q];
      } else {
        assert(false);
      }
    }
    
    hld = Hld(N);
    for (int i = 0; i < N - 1; ++i) {
      hld.ae(A[i], B[i]);
    }
    hld.build(0);
// cerr<<hld<<endl;
    
    bool spe2 = true;
    for (int q = 0; q < Q; ++q) if (O[q] == 1 || O[q] == 3) spe2 = spe2 && (K[q] == 0);
    bool spe3 = true;
    for (int u = 1; u < N; ++u) spe3 = spe3 && (hld.par[u] == u - 1);
    bool spe5 = true;
    for (int q = 0; q < Q; ++q) spe5 = spe5 && ((O[q] == 1 || O[q] == 3) && X[q] == Y[q]);
    
    vector<U> anss;
    if (N <= 5000 && Q <= 5000) {
      anss = brute::run();
    } else if (spe2 || spe3) {
      anss = sub2::run();
    } else if (spe5) {
      anss = sub5::run();
    } else {
      assert(false);
    }
    for (const U ans : anss) {
      printf("%llu\n", ans);
    }
  }
  return 0;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 49ms
memory: 5084kb

input:

5000 5000
1 2
2 3
3 4
4 5
5 6
5 7
6 8
7 9
9 10
8 11
11 12
12 13
12 14
14 15
15 16
16 17
16 18
18 19
18 20
20 21
20 22
22 23
23 24
23 25
23 26
26 27
27 28
28 29
27 30
30 31
29 32
32 33
33 34
32 35
35 36
36 37
35 38
36 39
38 40
38 41
41 42
42 43
43 44
42 45
44 46
45 47
47 48
48 49
48 50
49 51
51 52
52...

output:

37227703492
2136305359188
2794367845468
1309925069860
1698169768858
2678958746332
6690595071246
2087826052960
5786332239171
2186592622
4014965079076
1674542130
6524658548
7094033144666
10065416610040
11589693473717
492570862
3356228199498
2834694279
4198036633070
4395772262
4221137767
9630829210
992...

result:

ok 2559 numbers

Test #2:

score: 0
Accepted
time: 22ms
memory: 4548kb

input:

5000 5000
54 2
1945 3
4131 4
1207 5
3558 6
3582 7
1648 8
3498 9
1761 10
360 11
3617 12
4359 13
158 14
2314 15
529 16
4619 17
1070 18
1504 19
2675 20
2981 21
2142 22
1349 23
1640 24
1374 25
4059 26
2511 27
2708 28
2939 29
3017 30
3320 31
4602 32
4779 33
2697 34
3906 35
1121 36
197 37
1551 38
1119 39
...

output:

0
198262395
0
0
1595057854
0
0
39277179818
13451201574
21469030838
0
0
23554220364
19140694248
212211615641
0
0
0
0
0
86500798
60136122614
47351162248
0
0
306346383502
230306838988
0
170207438
471673864986
387605196674
0
0
0
688392707
115968801311
199501119668
168720065378
634329317954
0
0
155717506...

result:

ok 2456 numbers

Subtask #2:

score: 0
Judgement Failed

Test #3:

score: 0
Judgement Failed

input:

200000 200000
1 2
1 3
1 4
3 5
1 6
1 7
7 8
8 9
2 10
1 11
5 12
1 13
7 14
10 15
2 16
7 17
11 18
5 19
5 20
1 21
16 22
1 23
3 24
20 25
14 26
2 27
6 28
15 29
10 30
15 31
5 32
13 33
12 34
31 35
31 36
36 37
36 38
1 39
28 40
5 41
12 42
41 43
20 44
30 45
22 46
11 47
47 48
45 49
14 50
41 51
3 52
30 53
29 54
6 ...

output:


result:


Subtask #3:

score: 0
Judgement Failed

Test #5:

score: 0
Judgement Failed

input:

200000 200000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:


result:


Subtask #4:

score: 0
Judgement Failed

Test #7:

score: 0
Judgement Failed

input:

200000 200000
1 2
2 3
3 4
1 5
3 6
5 7
5 8
7 9
2 10
7 11
11 12
10 13
6 14
3 15
14 16
4 17
11 18
3 19
14 20
4 21
4 22
12 23
18 24
5 25
5 26
14 27
13 28
24 29
11 30
26 31
29 32
28 33
31 34
23 35
33 36
6 37
11 38
22 39
13 40
35 41
37 42
21 43
12 44
4 45
16 46
12 47
21 48
1 49
26 50
45 51
41 52
46 53
7 5...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #2:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%