QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106538#5257. Money LaunderingmaspyAC ✓857ms19768kbC++2326.9kb2023-05-18 01:28:362023-05-18 01:28:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-18 01:28:40]
  • 评测
  • 测评结果:AC
  • 用时:857ms
  • 内存:19768kb
  • [2023-05-18 01:28:36]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) \
  for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sum = 0;
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  assert(!que.empty());
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  assert(!que.empty());
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}
#endif
#line 1 "library/other/io.hpp"
// based on yosupo's fastio
#include <unistd.h>

namespace fastio {
#define FASTIO
// クラスが read(), print() を持っているかを判定するメタ関数
struct has_write_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.write(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_write : public decltype(has_write_impl::check<T>(std::declval<T>())) {
};

struct has_read_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.read(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_read : public decltype(has_read_impl::check<T>(std::declval<T>())) {};

struct Scanner {
  FILE *fp;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) { ref = 10 * ref + (line[st++] & 0xf); }
    if (neg) ref = -ref;
    return true;
  }
  template <typename T,
            typename enable_if<has_read<T>::value>::type * = nullptr>
  inline bool read_single(T &x) {
    x.read();
    return true;
  }
  bool read_single(double &ref) {
    string s;
    if (!read_single(s)) return false;
    ref = std::stod(s);
    return true;
  }
  bool read_single(char &ref) {
    string s;
    if (!read_single(s) || s.size() != 1) return false;
    ref = s[0];
    return true;
  }
  template <class T>
  bool read_single(vector<T> &ref) {
    for (auto &d: ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T, class U>
  bool read_single(pair<T, U> &p) {
    return (read_single(p.first) && read_single(p.second));
  }
  template <size_t N = 0, typename T>
  void read_single_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
      auto &x = std::get<N>(t);
      read_single(x);
      read_single_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool read_single(tuple<T...> &tpl) {
    read_single_tuple(tpl);
    return true;
  }
  void read() {}
  template <class H, class... T>
  void read(H &h, T &... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE *fp) : fp(fp) {}
};

struct Printer {
  Printer(FILE *_fp) : fp(_fp) {}
  ~Printer() { flush(); }

  static constexpr size_t SIZE = 1 << 15;
  FILE *fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write(const char val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write('0');
      return;
    }
    if (val < 0) {
      write('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) { line[pos + i] = small[len - 1 - i]; }
    pos += len;
  }
  void write(const string s) {
    for (char c: s) write(c);
  }
  void write(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write(s[i]);
  }
  void write(const double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  void write(const long double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  template <typename T,
            typename enable_if<has_write<T>::value>::type * = nullptr>
  inline void write(T x) {
    x.write();
  }
  template <class T>
  void write(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  template <class T, class U>
  void write(const pair<T, U> val) {
    write(val.first);
    write(' ');
    write(val.second);
  }
  template <size_t N = 0, typename T>
  void write_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
      if constexpr (N > 0) { write(' '); }
      const auto x = std::get<N>(t);
      write(x);
      write_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool write(tuple<T...> tpl) {
    write_tuple(tpl);
    return true;
  }
  template <class T, size_t S>
  void write(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  void write(i128 val) {
    string s;
    bool negative = 0;
    if (val < 0) {
      negative = 1;
      val = -val;
    }
    while (val) {
      s += '0' + int(val % 10);
      val /= 10;
    }
    if (negative) s += "-";
    reverse(all(s));
    if (len(s) == 0) s = "0";
    write(s);
  }
};
Scanner scanner = Scanner(stdin);
Printer printer = Printer(stdout);
void flush() { printer.flush(); }
void print() { printer.write('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  printer.write(head);
  if (sizeof...(Tail)) printer.write(' ');
  print(forward<Tail>(tail)...);
}

void read() {}
template <class Head, class... Tail>
void read(Head &head, Tail &... tail) {
  scanner.read(head);
  read(tail...);
}
} // namespace fastio
using fastio::print;
using fastio::flush;
using fastio::read;

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)   \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 2 "library/graph/base.hpp"

template <typename T>
struct Edge {
  int frm, to;
  T cost;
  int id;
};

template <typename T = int, bool directed = false>
struct Graph {
  int N, M;
  using cost_type = T;
  using edge_type = Edge<T>;
  vector<edge_type> edges;
  vector<int> indptr;
  vector<edge_type> csr_edges;
  vc<int> vc_deg, vc_indeg, vc_outdeg;
  bool prepared;

  class OutgoingEdges {
  public:
    OutgoingEdges(const Graph* G, int l, int r) : G(G), l(l), r(r) {}

    const edge_type* begin() const {
      if (l == r) { return 0; }
      return &G->csr_edges[l];
    }

    const edge_type* end() const {
      if (l == r) { return 0; }
      return &G->csr_edges[r];
    }

  private:
    const Graph* G;
    int l, r;
  };

  bool is_prepared() { return prepared; }
  constexpr bool is_directed() { return directed; }

  Graph() : N(0), M(0), prepared(0) {}
  Graph(int N) : N(N), M(0), prepared(0) {}

  void build(int n) {
    N = n, M = 0;
    prepared = 0;
    edges.clear();
    indptr.clear();
    csr_edges.clear();
    vc_deg.clear();
    vc_indeg.clear();
    vc_outdeg.clear();
  }

  void add(int frm, int to, T cost = 1, int i = -1) {
    assert(!prepared);
    assert(0 <= frm && 0 <= to && to < N);
    if (i == -1) i = M;
    auto e = edge_type({frm, to, cost, i});
    edges.eb(e);
    ++M;
  }

  // wt, off
  void read_tree(bool wt = false, int off = 1) { read_graph(N - 1, wt, off); }

  void read_graph(int M, bool wt = false, int off = 1) {
    for (int m = 0; m < M; ++m) {
      INT(a, b);
      a -= off, b -= off;
      if (!wt) {
        add(a, b);
      } else {
        T c;
        read(c);
        add(a, b, c);
      }
    }
    build();
  }

  void build() {
    assert(!prepared);
    prepared = true;
    indptr.assign(N + 1, 0);
    for (auto&& e: edges) {
      indptr[e.frm + 1]++;
      if (!directed) indptr[e.to + 1]++;
    }
    for (int v = 0; v < N; ++v) { indptr[v + 1] += indptr[v]; }
    auto counter = indptr;
    csr_edges.resize(indptr.back() + 1);
    for (auto&& e: edges) {
      csr_edges[counter[e.frm]++] = e;
      if (!directed)
        csr_edges[counter[e.to]++] = edge_type({e.to, e.frm, e.cost, e.id});
    }
  }

  OutgoingEdges operator[](int v) const {
    assert(prepared);
    return {this, indptr[v], indptr[v + 1]};
  }

  vc<int> deg_array() {
    if (vc_deg.empty()) calc_deg();
    return vc_deg;
  }

  pair<vc<int>, vc<int>> deg_array_inout() {
    if (vc_indeg.empty()) calc_deg_inout();
    return {vc_indeg, vc_outdeg};
  }

  int deg(int v) {
    if (vc_deg.empty()) calc_deg();
    return vc_deg[v];
  }

  int in_deg(int v) {
    if (vc_indeg.empty()) calc_deg_inout();
    return vc_indeg[v];
  }

  int out_deg(int v) {
    if (vc_outdeg.empty()) calc_deg_inout();
    return vc_outdeg[v];
  }

  void debug() {
    print("Graph");
    if (!prepared) {
      print("frm to cost id");
      for (auto&& e: edges) print(e.frm, e.to, e.cost, e.id);
    } else {
      print("indptr", indptr);
      print("frm to cost id");
      FOR(v, N) for (auto&& e: (*this)[v]) print(e.frm, e.to, e.cost, e.id);
    }
  }

  // G における頂点 V[i] が、新しいグラフで i になるようにする
  Graph<T, directed> rearrange(vc<int> V) {
    int n = len(V);
    map<int, int> MP;
    FOR(i, n) MP[V[i]] = i;
    Graph<T, directed> G(n);
    for (auto&& e: edges) {
      if (MP.count(e.frm) && MP.count(e.to)) {
        G.add(MP[e.frm], MP[e.to], e.cost);
      }
    }
    G.build();
    return G;
  }

private:
  void calc_deg() {
    assert(vc_deg.empty());
    vc_deg.resize(N);
    for (auto&& e: edges) vc_deg[e.frm]++, vc_deg[e.to]++;
  }

  void calc_deg_inout() {
    assert(vc_indeg.empty());
    vc_indeg.resize(N);
    vc_outdeg.resize(N);
    for (auto&& e: edges) { vc_indeg[e.to]++, vc_outdeg[e.frm]++; }
  }
};
#line 3 "library/graph/strongly_connected_component.hpp"

template <typename Graph>
pair<int, vc<int>> strongly_connected_component(Graph& G) {
  assert(G.is_directed());
  assert(G.is_prepared());
  int N = G.N;
  int C = 0;
  vc<int> comp(N);
  vc<int> low(N);
  vc<int> ord(N, -1);
  vc<int> visited;
  int now = 0;

  auto dfs = [&](auto self, int v) -> void {
    low[v] = now;
    ord[v] = now;
    ++now;
    visited.eb(v);
    for (auto&& [frm, to, cost, id]: G[v]) {
      if (ord[to] == -1) {
        self(self, to);
        chmin(low[v], low[to]);
      } else {
        chmin(low[v], ord[to]);
      }
    }
    if (low[v] == ord[v]) {
      while (1) {
        int u = visited.back();
        visited.pop_back();
        ord[u] = N;
        comp[u] = C;
        if (u == v) break;
      }
      ++C;
    }
  };
  FOR(v, N) {
    if (ord[v] == -1) dfs(dfs, v);
  }
  FOR(v, N) comp[v] = C - 1 - comp[v];
  return {C, comp};
}

template <typename GT>
Graph<int, 1> scc_dag(GT& G, int C, vc<int>& comp) {
  Graph<int, 1> DAG(C);
  vvc<int> edges(C);
  for (auto&& e: G.edges) {
    int x = comp[e.frm], y = comp[e.to];
    if (x == y) continue;
    edges[x].eb(y);
  }
  FOR(c, C) {
    UNIQUE(edges[c]);
    for (auto&& to: edges[c]) DAG.add(c, to);
  }
  DAG.build();
  return DAG;
}
#line 1 "library/string/split.hpp"
vc<string> split(string S, char sep = ',') {
  vc<string> res = {""};
  for (auto&& s: S) {
    if (s == sep)
      res.eb("");
    else
      res.back() += s;
  }
  return res;
}

vc<string> split(string S, string seps = " ,") {
  vc<string> res = {""};
  for (auto&& s: S) {
    if (count(all(seps), s))
      res.eb("");
    else
      res.back() += s;
  }
  return res;
}
#line 2 "library/mod/modint_common.hpp"

struct has_mod_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};


template <typename mint>
mint inv(int n) {
  static const int mod = mint::get_mod();
  static vector<mint> dat = {0, 1};
  assert(0 <= n);
  if (n >= mod) n %= mod;
  while (len(dat) <= n) {
    int k = len(dat);
    int q = (mod + k - 1) / k;
    dat.eb(dat[k * q - mod] * mint(q));
  }
  return dat[n];
}

template <typename mint>
mint fact(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n);
  if (n >= mod) return 0;
  static vector<mint> dat = {1, 1};
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint(len(dat)));
  return dat[n];
}

template <typename mint>
mint fact_inv(int n) {
  static const int mod = mint::get_mod();
  assert(-1 <= n && n < mod);
  static vector<mint> dat = {1, 1};
  if (n == -1) return mint(0);
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
  return dat[n];
}

template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
  return (mint(1) * ... * fact_inv<mint>(xs));
}

template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
  return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}

template <typename mint>
mint C_dense(int n, int k) {
  static vvc<mint> C;
  static int H = 0, W = 0;
  auto calc = [&](int i, int j) -> mint {
    if (i == 0) return (j == 0 ? mint(1) : mint(0));
    return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
  };
  if (W <= k) {
    FOR(i, H) {
      C[i].resize(k + 1);
      FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
    }
    W = k + 1;
  }
  if (H <= n) {
    C.resize(n + 1);
    FOR(i, H, n + 1) {
      C[i].resize(W);
      FOR(j, W) { C[i][j] = calc(i, j); }
    }
    H = n + 1;
  }
  return C[n][k];
}

template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  if (dense) return C_dense<mint>(n, k);
  if (!large) return multinomial<mint>(n, k, n - k);
  k = min(k, n - k);
  mint x(1);
  FOR(i, k) x *= mint(n - i);
  return x * fact_inv<mint>(k);
}

template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
  assert(n >= 0);
  assert(0 <= k && k <= n);
  if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
  return mint(1) / C<mint, 1>(n, k);
}

// [x^d] (1-x) ^ {-n} の計算
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
  assert(n >= 0);
  if (d < 0) return mint(0);
  if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
  return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "library/mod/modint.hpp"

template <int mod>
struct modint {
  static_assert(mod < (1 << 30));
  int val;
  constexpr modint(const ll val = 0) noexcept
      : val(val >= 0 ? val % mod : (mod - (-val) % mod) % mod) {}
  bool operator<(const modint &other) const {
    return val < other.val;
  } // To use std::map
  modint &operator+=(const modint &p) {
    if ((val += p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((val += mod - p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    val = (int)(1LL * val * p.val % mod);
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint(-val); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  modint inverse() const {
    int a = val, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(ll n) const {
    assert(n >= 0);
    modint ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
#ifdef FASTIO
  void write() { fastio::printer.write(val); }
  void read() { fastio::scanner.read(val); }
#endif
  static constexpr int get_mod() { return mod; }
  // (n, r), r は 1 の 2^n 乗根
  static constexpr pair<int, int> ntt_info() {
    if (mod == 167772161) return {25, 17};
    if (mod == 469762049) return {26, 30};
    if (mod == 754974721) return {24, 362};
    if (mod == 880803841) return {23, 211};
    if (mod == 998244353) return {23, 31};
    if (mod == 1045430273) return {20, 363};
    if (mod == 1051721729) return {20, 330};
    if (mod == 1053818881) return {20, 2789};
    return {-1, -1};
  }
  static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};

using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 3 "library/linalg/mat_mul.hpp"

template <class T, typename enable_if<has_mod<T>::value>::type* = nullptr>
vc<vc<T>> mat_mul(const vc<vc<T>>& A, const vc<vc<T>>& B) {
  constexpr int mod = T::get_mod();
  auto N = len(A), M = len(B), K = len(B[0]);
  vv(int, b, K, M);
  FOR(i, M) FOR(j, K) b[j][i] = B[i][j].val;
  vv(T, C, N, K);

  if (M <= 16) {
    FOR(i, N) FOR(j, K) {
      u64 sm = 0;
      FOR(m, M) sm += u64(A[i][m].val) * b[j][m];
      C[i][j] = sm % mod;
    }
  } else {
    FOR(i, N) FOR(j, K) {
      i128 sm = 0;
      FOR(m, M) sm += ll(A[i][m].val) * b[j][m];
      C[i][j] = sm % mod;
    }
  }
  return C;
}

template <class T, typename enable_if<!has_mod<T>::value>::type* = nullptr>
vc<vc<T>> mat_mul(const vc<vc<T>>& A, const vc<vc<T>>& B) {
  assert(!A.empty() && !B.empty());
  auto N = len(A), M = len(B), K = len(B[0]);
  vv(T, b, K, M);
  FOR(i, M) FOR(j, K) b[j][i] = B[i][j];
  vv(T, C, N, K);
  FOR(n, N) FOR(m, M) FOR(k, K) C[n][k] += A[n][m] * b[k][m];
  return C;
}
#line 7 "main.cpp"

using Re = double;

void solve() {
  LL(N1, N2);
  Graph<Re, true> G(N1 + N2);
  FOR(i, N1) {
    LL(n);
    FOR(n) {
      STR(S);
      auto tokens = split(S, ":");
      string A = tokens[0];
      Re x = stod(tokens[1]) / 100.0;
      int k = stoi(A.substr(1));
      --k;
      k = (A[0] == 'C' ? k : N1 + k);
      G.add(i, k, x);
    }
  }
  G.build();

  auto [nc, comp] = strongly_connected_component(G);
  vvc<int> V(nc);
  FOR(v, N1) V[comp[v]].eb(v);

  vv(Re, A, N1 + N2, N2);
  FOR(k, N2) A[N1 + k][k] = 1.0;

  vc<int> new_idx(N1 + N2, -1);

  FOR_R(c, nc) {
    vc<int>& vs = V[c];
    int n = len(vs);
    if (n == 0) continue;
    FOR(i, n) new_idx[vs[i]] = i;

    vv(Re, mat, n + n, n + n);
    FOR(i, n) mat[n + i][n + i] = 1.0;
    FOR(i, n) {
      for (auto&& e: G[vs[i]]) {
        int to = new_idx[e.to];
        if (to == -1) to = n + i;
        mat[i][to] += e.cost;
      }
    }
    FOR(30) mat = mat_mul(mat, mat);
    FOR(i, n) {
      int v = vs[i];
      FOR(j, n) {
        Re x = mat[i][n + j];
        if (x == 0.0) continue;
        Re out = 0.0;
        for (auto&& e: G[vs[j]]) {
          if (new_idx[e.to] == -1) out += e.cost;
        }
        x /= out;
        for (auto&& e: G[vs[j]]) {
          if (new_idx[e.to] == -1) {
            int to = e.to;
            Re cf = x * e.cost;
            FOR(k, N2) A[v][k] += A[to][k] * cf;
          }
        }
      }
    }
    FOR(i, n) new_idx[vs[i]] = -1;
  }
  FOR(v, N1) print(A[v]);
}

signed main() {
  solve();
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3564kb

input:

1 1
1 P1:100.0

output:

1.000000000000000

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #2:

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

input:

5 10
6 P3:25.8 P9:47.4 P2:6.9 C4:6.9 C5:8.7 P6:4.3
5 C4:7.9 P7:2.9 C5:8.2 P4:56.0 P10:25.0
3 P5:52.2 P1:36.6 C5:11.2
5 P3:54.8 P8:16.6 P7:16.3 P4:8.2 P6:4.1
4 P3:80.6 P4:3.6 P1:15.7 P9:0.1

output:

0.013659000000000 0.069000000000000 0.365934000000000 0.008790000000000 0.000000000000000 0.045829000000000 0.011247000000000 0.011454000000000 0.474087000000000 0.000000000000000
0.012874000000000 0.000000000000000 0.109384000000000 0.569430000000000 0.000000000000000 0.003239000000000 0.0418770000...

result:

ok 50 numbers

Test #3:

score: 0
Accepted
time: 7ms
memory: 4020kb

input:

50 100
4 P93:40.9 P56:8.8 P5:12.4 P28:37.9
5 C17:4.8 P28:4.1 C44:1.6 P38:9.9 P49:79.6
8 C13:0.1 P52:0.1 C5:10.7 C48:0.3 P44:0.1 C37:87.8 C1:0.1 C28:0.8
4 P85:16.2 P36:7.6 P79:48.1 P78:28.1
6 C45:11.1 P50:0.1 P37:85.0 C32:3.3 C4:0.3 C33:0.2
5 P90:47.3 C40:47.0 C19:2.9 P3:2.0 P92:0.8
9 P53:2.7 P37:0.8...

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.124000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 5000 numbers

Test #4:

score: 0
Accepted
time: 415ms
memory: 15660kb

input:

500 1000
8 P484:0.1 P857:75.5 P602:0.2 P27:1.2 P828:0.9 C162:1.8 P413:6.4 P877:13.9
11 P411:0.9 P887:12.9 P93:1.7 C359:0.9 P870:11.6 P400:30.9 P646:0.1 P302:24.9 C397:0.1 P328:15.7 C434:0.3
13 P924:6.4 P806:12.7 P478:28.3 P829:4.4 P805:1.4 P147:0.1 P273:0.1 P954:0.1 P825:0.1 P362:1.0 P606:0.2 P916:0...

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.000001422000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 500000 numbers

Test #5:

score: 0
Accepted
time: 383ms
memory: 15628kb

input:

500 1000
6 P597:6.9 P65:1.1 C125:72.7 P630:1.0 P366:0.7 P3:17.6
9 P76:0.1 C61:0.1 C67:17.1 P457:0.4 C229:45.9 C222:24.9 P53:0.1 P557:11.3 P761:0.1
8 C342:0.4 C218:88.0 P263:0.1 P588:0.8 C22:4.7 C463:2.2 P518:3.7 C482:0.1
9 P313:0.1 C490:55.2 P296:0.1 P901:0.1 C474:0.1 C45:0.4 P200:0.1 C438:0.1 P540:...

output:

0.000000000000000 0.000000000000000 0.176000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 500000 numbers

Test #6:

score: 0
Accepted
time: 403ms
memory: 15868kb

input:

500 1000
9 P466:36.7 P56:0.6 C338:3.4 P795:19.9 C311:0.2 P383:0.1 C182:0.8 P991:38.2 C326:0.1
7 C165:48.0 P605:0.1 P237:0.1 P990:50.7 C335:0.1 P291:0.9 C108:0.1
8 P703:0.3 P482:10.6 P756:6.4 P826:0.7 P995:3.8 P632:28.4 P318:46.2 P739:3.6
11 P592:17.6 P889:15.9 P654:3.7 P182:2.9 C362:15.6 C182:33.1 P...

output:

0.000000003985767 0.000000000000000 0.000000000000000 0.000000000000000 0.000000004320000 0.000000024000000 0.000000000000000 0.000000000488914 0.000000000014858 0.000086000000000 0.007578930208000 0.000000000000020 0.000000000000000 0.000000000000000 0.000000124709023 0.000000000000000 0.0000000000...

result:

ok 500000 numbers

Test #7:

score: 0
Accepted
time: 37ms
memory: 4516kb

input:

393 100
9 P51:0.4 P99:0.1 P37:77.7 P68:0.9 P98:17.3 P4:0.1 P76:3.0 P70:0.1 C1:0.4
13 P41:0.1 P87:3.1 C2:0.3 P44:0.1 P32:0.1 P80:0.1 P35:0.1 P25:0.1 P95:85.8 P26:0.3 C28:9.7 P72:0.1 P70:0.1
11 P49:0.1 P10:29.0 P13:0.1 P31:0.1 P51:11.9 P80:19.9 P73:24.7 C81:13.9 P68:0.1 P3:0.1 P89:0.1
9 P30:5.3 P31:0....

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.001004016064257 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 39300 numbers

Test #8:

score: 0
Accepted
time: 601ms
memory: 17500kb

input:

759 1000
12 P433:75.4 C138:3.7 P8:16.9 P476:2.3 P974:0.4 P290:0.1 P686:0.1 P471:0.1 P399:0.1 P902:0.1 P796:0.7 P815:0.1
7 P66:0.1 P628:6.8 P353:0.1 P520:0.4 P889:0.1 P770:80.3 P477:12.2
14 P572:0.1 P176:11.7 P362:0.4 P856:0.1 P589:23.7 P945:15.0 P571:2.8 P930:0.1 P687:0.1 P807:0.1 P478:0.1 P379:14.0...

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.169000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 759000 numbers

Test #9:

score: 0
Accepted
time: 641ms
memory: 17940kb

input:

802 1000
9 P260:20.8 P122:0.1 P103:0.1 P273:24.1 P815:0.1 P914:54.0 C236:0.3 P589:0.4 P570:0.1
7 P862:47.1 P302:48.2 P524:2.7 P686:1.0 P573:0.6 P810:0.1 P620:0.3
14 P472:0.1 P896:0.1 P831:0.1 P475:0.6 P979:62.2 P326:0.1 P105:0.1 P939:0.9 P980:3.3 P649:0.3 P348:0.1 P132:30.6 P890:1.4 P527:0.1
11 P556...

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 802000 numbers

Test #10:

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

input:

5 3
3 P1:30.0 P2:20.0 P3:50.0
1 C3:100.0
1 C5:100.0
1 C1:100.0
1 C4:100.0

output:

0.300000000000000 0.200000000000000 0.500000000000000
0.300000000000000 0.200000000000000 0.500000000000000
0.300000000000000 0.200000000000000 0.500000000000000
0.300000000000000 0.200000000000000 0.500000000000000
0.300000000000000 0.200000000000000 0.500000000000000

result:

ok 15 numbers

Test #11:

score: 0
Accepted
time: 796ms
memory: 19768kb

input:

1000 1000
1 C753:100.0
1 C331:100.0
1 C992:100.0
1 C84:100.0
1 C658:100.0
1 C683:100.0
1 C341:100.0
1 C28:100.0
1 C513:100.0
1 C685:100.0
1 C699:100.0
1 C169:100.0
1 C420:100.0
1 C694:100.0
1 C405:100.0
1 C601:100.0
1 C948:100.0
1 C208:100.0
1 C214:100.0
1 C26:100.0
1 C904:100.0
1 C49:100.0
1 C142:1...

output:

0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.0000000000...

result:

ok 1000000 numbers

Test #12:

score: 0
Accepted
time: 835ms
memory: 19716kb

input:

1000 1000
15 C2:7.6 C418:6.6 C134:6.6 C426:6.6 C75:6.6 C812:6.6 C876:6.6 C460:6.6 C431:6.6 C844:6.6 C721:6.6 C333:6.6 C12:6.6 C373:6.6 C413:6.6
13 C802:8.8 C3:7.6 C293:7.6 C775:7.6 C712:7.6 C201:7.6 C553:7.6 C331:7.6 C947:7.6 C982:7.6 C376:7.6 C251:7.6 C928:7.6
25 C4:4.0 C261:4.0 C518:4.0 C392:4.0 C...

output:

0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.0010000000...

result:

ok 1000000 numbers

Test #13:

score: 0
Accepted
time: 857ms
memory: 19488kb

input:

1000 1000
15 C2:1.3 C418:20.5 C134:4.1 C426:6.0 C75:3.2 C812:7.2 C876:8.4 C460:10.7 C431:5.5 C844:8.6 C721:1.2 C333:2.9 C12:6.3 C373:6.3 C413:7.8
13 C802:28.2 C3:11.4 C293:0.5 C775:13.1 C712:10.4 C201:5.7 C553:6.1 C331:2.5 C947:12.3 C982:1.5 C376:5.1 C251:0.4 C928:2.8
25 C4:0.5 C261:0.3 C518:0.9 C39...

output:

0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.001000000000000 0.0010000000...

result:

ok 1000000 numbers

Test #14:

score: 0
Accepted
time: 838ms
memory: 19464kb

input:

1000 1000
15 C2:6.5 C418:13.2 C134:3.5 C75:3.2 C460:6.9 C844:6.9 C333:0.4 C12:0.8 C267:4.6 P170:0.2 P876:9.0 C373:14.6 P879:4.5 C413:24.6 P728:1.1
15 C802:3.7 C3:14.4 P27:6.3 C293:23.6 C775:0.1 C712:5.8 C201:2.0 C553:2.6 C144:6.8 C947:5.4 C148:12.0 P331:4.7 C982:5.3 C376:4.7 C251:2.6
24 C4:0.9 C261:...

output:

0.000017975157857 0.000008127278259 0.000206248415484 0.000222220641396 0.036520503350575 0.000009989371400 0.000341489102714 0.000128152919733 0.000007965864133 0.000264479261160 0.000002865519358 0.000045757757055 0.000338171115552 0.000016419977960 0.000131990764765 0.000054150445491 0.0001852572...

result:

ok 1000000 numbers

Test #15:

score: 0
Accepted
time: 838ms
memory: 19744kb

input:

1000 1000
16 C2:24.0 C418:1.3 C134:8.1 C359:8.7 C75:10.8 C460:0.7 C844:4.7 C333:3.7 C12:2.8 C267:7.3 P170:5.1 P876:0.8 C373:2.6 P879:0.4 C413:9.7 P728:9.3
16 C802:7.8 C3:13.9 P27:0.5 C293:0.9 C91:1.1 C775:7.7 C712:9.9 C201:6.1 C553:3.8 C144:6.8 C947:6.3 C148:3.4 P331:16.3 C982:7.3 C376:1.6 C251:6.6
...

output:

0.000029234446813 0.000002414779744 0.000812086530410 0.000046997828958 0.000522967931207 0.000003304478059 0.000108848833904 0.000559730239501 0.000010216052591 0.000010380214548 0.000071556305024 0.000094132181588 0.000112876681550 0.001366438972455 0.000275473771360 0.000013371686945 0.0001006911...

result:

ok 1000000 numbers

Test #16:

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

input:

66 20
7 P18:0.1 C66:0.1 C22:0.1 P6:0.1 P12:84.5 P4:15.0 C9:0.1
10 C48:0.1 P12:0.1 P11:47.6 P1:19.8 P18:1.2 P8:0.1 P5:14.2 C38:16.2 P7:0.1 P20:0.6
10 C46:0.1 C9:0.6 P1:13.8 C29:0.1 P18:48.8 P4:23.9 P14:3.1 P6:9.4 C1:0.1 P10:0.1
9 P12:3.0 P11:86.5 P9:4.1 C61:0.1 P8:3.0 C4:1.2 P13:0.1 P16:1.9 P14:0.1
1...

output:

0.000049748185017 0.000462742727885 0.000000000087570 0.150748868299336 0.000015302810796 0.001524689387985 0.000000068444609 0.000024217737806 0.000045964828322 0.000000359553415 0.000338340348531 0.845432546600711 0.000000055374297 0.000012414502474 0.000000000007854 0.000010474191559 0.0000000014...

result:

ok 1320 numbers

Test #17:

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

input:

64 20
11 C40:1.2 P8:0.1 P16:0.1 C48:46.3 C64:0.1 C17:50.7 P11:1.1 C1:0.1 C34:0.1 P5:0.1 P15:0.1
6 C7:15.8 C2:0.1 C14:5.7 P7:0.3 P6:0.1 C63:78.0
9 P3:2.3 P14:0.1 P4:0.2 C32:0.3 P15:8.6 P18:82.0 P11:0.1 C51:3.8 P6:2.6
8 C13:35.9 P5:4.3 P16:0.3 P9:35.1 C46:5.3 C58:0.6 P8:13.6 P1:4.9
7 C49:0.9 P17:82.0 ...

output:

0.018043047266132 0.002383725998445 0.045912739588061 0.016400455036885 0.042449024377422 0.024096516620048 0.003162873116993 0.205647783087181 0.010960978153139 0.000019019019019 0.026616341112014 0.000963435707274 0.002098009062078 0.001387379719130 0.052471166858921 0.467879269837383 0.0191608890...

result:

ok 1280 numbers

Test #18:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

61 20
11 P17:0.1 C20:40.2 C1:0.1 P9:12.2 P11:0.1 P12:0.3 P15:0.5 C51:39.6 P14:0.5 P5:0.1 P18:6.3
11 P8:1.4 C2:73.2 C18:0.1 P3:0.1 P9:4.9 C59:0.1 P19:1.0 P11:11.9 P6:7.1 C31:0.1 P20:0.1
9 P1:0.1 P13:0.1 C3:0.2 P18:0.2 P16:98.7 C19:0.1 P3:0.4 P8:0.1 P2:0.1
8 C23:0.7 P19:0.2 P9:0.3 P14:88.6 P4:0.7 P7:9...

output:

0.022782114640338 0.002859642183850 0.000495173633095 0.090789089006656 0.028976436237842 0.130292067918028 0.039325689844394 0.011072798417339 0.129228189811640 0.000009457287150 0.002728618028379 0.113800837129763 0.031265708583314 0.005806051894764 0.005545393782256 0.307775819871327 0.0065613334...

result:

ok 1220 numbers

Test #19:

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

input:

63 20
10 C63:15.0 P15:0.1 C1:54.6 P7:2.3 P2:0.1 P17:0.3 C48:0.1 C9:27.3 P12:0.1 P18:0.1
11 C60:49.6 P16:0.3 P18:0.1 C53:0.2 C15:5.9 P7:2.8 P2:1.7 P15:1.1 P13:0.1 C2:1.2 P14:37.0
11 C48:9.0 P12:0.1 P3:0.2 P8:0.1 P9:29.6 P10:0.3 P2:0.7 P20:3.2 C9:0.1 P13:56.1 P17:0.6
11 C37:0.9 C47:0.2 C4:0.1 P4:24.4 ...

output:

0.099362465144736 0.470684401258568 0.000037527316021 0.000032770644887 0.015021098186708 0.000001023427268 0.050824306295787 0.000000000000000 0.206127080279458 0.000000422098219 0.011919361155429 0.016038862601326 0.091545467065907 0.000001637612460 0.026336965019775 0.000002205393071 0.0066379151...

result:

ok 1260 numbers

Test #20:

score: 0
Accepted
time: 5ms
memory: 3668kb

input:

68 20
10 P17:0.1 P13:0.2 C11:35.4 C37:2.9 P11:0.6 C51:58.7 C21:1.0 C65:0.1 C48:0.1 C1:0.9
12 P13:0.1 P18:1.8 P14:14.8 P20:0.9 C50:0.1 C62:0.1 P3:3.8 P4:70.5 C4:0.9 C2:0.1 C49:3.3 C55:3.6
12 P19:0.8 P1:0.4 C64:1.2 P11:4.4 C6:0.1 C3:0.2 P18:40.8 P12:5.7 P6:5.0 C53:0.6 P17:40.7 C36:0.1
12 P9:0.8 C55:3....

output:

0.000051645878006 0.000000000000000 0.000611833859754 0.001661430475567 0.019715403927486 0.026487876410542 0.007525998362106 0.116793634531318 0.523706677033227 0.000000042195999 0.019934583962930 0.049647331640459 0.006157231974350 0.031809440769159 0.012022789607611 0.020505432117153 0.0013308478...

result:

ok 1360 numbers

Test #21:

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

input:

71 20
8 P15:8.4 P16:62.2 C10:0.1 P8:25.2 C3:1.0 P13:0.1 P9:0.1 C64:2.9
9 P12:1.7 P14:0.6 C53:0.1 C2:25.9 P20:13.6 P2:0.1 P8:1.2 C71:0.2 P5:56.6
9 P1:0.1 P14:0.3 P6:43.7 P16:12.3 C1:5.7 P19:3.4 P7:29.1 P8:0.1 P9:5.3
10 P2:6.4 C63:0.2 P19:1.4 P4:5.6 P14:0.4 P11:0.8 P17:77.9 C4:2.6 P6:0.6 C35:4.1
5 C35...

output:

0.000082332035459 0.000030694117072 0.000119014206221 0.000437696833422 0.000001136085278 0.004374673421876 0.004281850979801 0.257201100766684 0.011547779132302 0.000058702989170 0.000104707926805 0.004431372421612 0.002973415815867 0.000563385051810 0.084084178835689 0.624880639413413 0.0000421727...

result:

ok 1420 numbers

Test #22:

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

input:

66 20
12 C59:1.9 C3:0.1 P1:0.9 P10:0.2 P5:20.1 P7:0.1 C1:34.4 P19:0.2 P15:2.8 P14:12.4 C22:0.8 C49:26.1
8 P1:0.6 P5:0.1 P9:79.0 C10:3.1 P3:16.9 P20:0.1 C51:0.1 C5:0.1
5 P13:1.2 P18:65.4 P20:5.6 C59:0.1 P16:27.7
8 C18:0.1 P15:1.8 P19:74.9 C35:0.2 P12:0.1 P5:0.1 P1:22.6 C24:0.2
5 C16:0.1 P15:56.0 P20:...

output:

0.013820222578291 0.000004904658578 0.000399853216674 0.112521433641205 0.315195730693591 0.000005205691776 0.001530395750311 0.000093689016317 0.139947538464982 0.009301271380700 0.000000003483586 0.000482394071460 0.041541356950710 0.192363187616901 0.079813851745571 0.002284434112252 0.0000000141...

result:

ok 1320 numbers

Test #23:

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

input:

62 20
10 P7:0.2 C13:0.1 P11:6.2 P13:8.2 C40:82.5 C2:0.1 P9:0.1 P20:0.1 P3:1.9 P8:0.6
8 C1:0.1 P14:2.7 C13:0.1 P5:90.6 C2:0.3 P3:0.2 C40:5.9 P16:0.1
9 P9:1.4 P13:0.4 P20:0.3 P5:80.3 P11:4.6 P6:7.3 C3:0.8 P16:0.8 P4:4.1
14 C57:8.9 P10:0.1 P3:24.9 P13:1.4 P1:1.0 C32:15.6 C50:0.1 P9:0.6 P2:0.1 C42:14.0 ...

output:

0.000000000000000 0.000000000000000 0.034651936473190 0.000000000000000 0.027121574893969 0.000000000000000 0.034144111622723 0.120734039813574 0.001820635023523 0.024402273260542 0.112879371458415 0.030571659996659 0.149292071928871 0.000808258854456 0.001125672743206 0.424019433415039 0.0366034098...

result:

ok 1240 numbers

Test #24:

score: 0
Accepted
time: 5ms
memory: 3772kb

input:

67 20
11 P1:4.6 P2:10.2 C65:1.2 C35:7.9 P18:0.6 P13:0.2 P14:33.5 P6:20.4 P3:2.8 C28:18.2 P9:0.4
10 P15:32.1 P2:2.2 P19:2.1 C3:6.1 P7:0.9 P5:22.1 P10:22.9 C2:8.6 P18:1.1 C52:1.9
10 C59:72.7 P14:2.3 P13:0.9 C3:9.8 P17:0.9 P4:0.1 C52:12.4 P15:0.7 P19:0.1 P20:0.1
7 P10:2.7 P9:16.8 P3:0.2 P7:0.6 P11:12.3...

output:

0.046242581775006 0.102090779611707 0.071091661068837 0.000075542340084 0.075987677604520 0.204000000000067 0.000014222521566 0.000000665061638 0.004544321692244 0.096222566117444 0.000000083837882 0.000000293318650 0.002000599041153 0.335016380379381 0.000325112052088 0.000469877947985 0.0533198879...

result:

ok 1340 numbers

Extra Test:

score: 0
Extra Test Passed