QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106693#6380. LaLa and Divination MagicmaspyAC ✓650ms104816kbC++2317.6kb2023-05-18 20:46:132023-05-18 20:46:16

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 20:46:16]
  • 评测
  • 测评结果:AC
  • 用时:650ms
  • 内存:104816kb
  • [2023-05-18 20:46:13]
  • 提交

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/alg/monoid/add.hpp"

template <typename X>
struct Monoid_Add {
  using value_type = X;
  static constexpr X op(const X &x, const X &y) noexcept { return x + y; }
  static constexpr X inverse(const X &x) noexcept { return -x; }
  static constexpr X power(const X &x, ll n) noexcept { return X(n) * x; }
  static constexpr X unit() { return X(0); }
  static constexpr bool commute = true;
};
#line 2 "library/string/trie.hpp"

template <int sigma>
struct Trie {
  using ARR = array<int, sigma>;
  int n_node;
  vc<ARR> TO;
  vc<int> parent;
  vc<int> suffix_link;
  vc<int> words;
  vc<int> V; // BFS 順

  Trie() {
    n_node = 0;
    new_node();
  }

  template <typename STRING>
  int add(STRING S, int off) {
    int v = 0;
    for (auto&& ss: S) {
      int s = ss - off;
      assert(0 <= s && s < sigma);
      if (TO[v][s] == -1) {
        TO[v][s] = new_node();
        parent.back() = v;
      }
      v = TO[v][s];
    }
    words.eb(v);
    return v;
  }

  int add_char(int v, int c, int off) {
    c -= off;
    if (TO[v][c] != -1) return TO[v][c];
    TO[v][c] = new_node();
    parent.back() = v;
    return TO[v][c];
  }

  void calc_suffix_link(bool upd_TO) {
    suffix_link.assign(n_node, -1);
    V.resize(n_node);
    int p = 0, q = 0;
    V[q++] = 0;
    while (p < q) {
      int v = V[p++];
      FOR(s, sigma) {
        int w = TO[v][s];
        if (w == -1) continue;
        V[q++] = w;
        int f = suffix_link[v];
        while (f != -1 && TO[f][s] == -1) f = suffix_link[f];
        suffix_link[w] = (f == -1 ? 0 : TO[f][s]);
      }
    }
    if (!upd_TO) return;
    for (auto&& v: V) {
      FOR(s, sigma) if (TO[v][s] == -1) {
        int f = suffix_link[v];
        TO[v][s] = (f == -1 ? 0 : TO[f][s]);
      }
    }
  }

  vc<int> calc_count() {
    assert(!suffix_link.empty());
    vc<int> count(n_node);
    for (auto&& x: words) count[x]++;
    for (auto&& v: V)
      if (v) { count[v] += count[suffix_link[v]]; }
    return count;
  }

private:
  int new_node() {
    parent.eb(-1);
    TO.eb(ARR{});
    fill(all(TO.back()), -1);
    return n_node++;
  }
};
#line 4 "main.cpp"

using BS = bitset<2000>;

void solve() {
  LL(N, M);
  Trie<2> trie;
  VEC(string, S, N);
  FOR(i, N) { trie.add(S[i], '0'); }
  N = M;

  vvv(BS, SAT, 2, 2, N);
  FOR(a, 2) FOR(b, 2) FOR(i, N) FOR(j, N) { SAT[a][b][i][j] = 1; }

  for (auto&& s: S) {
    BS x0, x1;
    FOR(i, N) if (s[i] == '0') x0[i] = 1;
    FOR(i, N) if (s[i] == '1') x1[i] = 1;
    FOR(i, N) {
      if (x0[i]) {
        SAT[0][0][i] &= (~x1);
        SAT[0][1][i] &= (~x0);
      }
      if (x1[i]) {
        SAT[1][0][i] &= (~x1);
        SAT[1][1][i] &= (~x0);
      }
    }
  }

  // 極大にとっているので、連鎖する必要はない

  auto out = [&]() -> void {
    using T3 = tuple<int, int, int>;
    vc<T3> ANS;
    FOR(a, 2) FOR(b, 2) FOR(i, N) FOR(j, i, N) {
      if (SAT[a][b][i][j]) {
        int k = -1;
        if (a == 0 && b == 0) k = 2;
        if (a == 0 && b == 1) k = 4;
        if (a == 1 && b == 0) k = 1;
        if (a == 1 && b == 1) k = 3;
        if (i == j && k == 2) continue;
        if (i == j && k == 3) continue;
        ANS.eb(i, j, k);
      }
    }
    print(len(ANS));
    for (auto&& x: ANS) print(x);
  };

  auto ng = [&]() -> void { return print(-1); };

  bool OK = 1;
  auto dfs = [&](auto& dfs, int v, int idx, BS& x0, BS& x1) -> void {
    if (!OK) return;
    if (v == -1) {
      // 解なしになっているはず
      if ((x0 & x1).any()) return;
      OK = 0;
      return;
    }
    if (idx == N) {
      // 解になっているはず
      assert(!(x0 & x1).any());
      return;
    }
    BS y0 = x0, y1 = x1;
    // goto 0
    y0[idx] = 1;
    y0 |= SAT[0][0][idx];
    y1 |= SAT[0][1][idx];
    dfs(dfs, trie.TO[v][0], idx + 1, y0, y1);
    y0 = x0, y1 = x1;
    y1[idx] = 1;
    y0 |= SAT[1][0][idx];
    y1 |= SAT[1][1][idx];
    dfs(dfs, trie.TO[v][1], idx + 1, y0, y1);
  };

  BS x0, x1;
  dfs(dfs, 0, 0, x0, x1);

  if (!OK) return ng();
  return out();
}

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

詳細信息

Test #1:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #2:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

3 3
101
011
111

output:

6
0 1 4
0 2 4
1 2 4
2 2 4
0 2 3
1 2 3

result:

ok Kout = 6, Kans = 6

Test #3:

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

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #4:

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

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #5:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #6:

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

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #7:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #8:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #9:

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

input:

1 1
1

output:

1
0 0 4

result:

ok Kout = 1, Kans = 1

Test #10:

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

input:

1 1
0

output:

1
0 0 1

result:

ok Kout = 1, Kans = 1

Test #11:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #12:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #13:

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

input:

2 4
0111
0010

output:

15
1 3 2
2 3 2
0 2 4
1 2 4
2 2 4
2 3 4
0 0 1
0 1 1
0 2 1
0 3 1
0 1 3
0 2 3
0 3 3
1 2 3
1 3 3

result:

ok Kout = 15, Kans = 15

Test #14:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #15:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

4 2
10
11
01
00

output:

0

result:

ok Kout = 0, Kans = 0

Test #16:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #17:

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

input:

2 4
0010
1000

output:

15
0 1 2
0 3 2
1 3 2
2 3 2
0 2 4
0 1 1
0 2 1
0 3 1
1 1 1
1 2 1
1 3 1
2 3 1
3 3 1
1 2 3
1 3 3

result:

ok Kout = 15, Kans = 15

Test #18:

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

input:

2 5
11101
00000

output:

21
0 1 2
0 2 2
0 3 2
0 4 2
1 2 2
1 3 2
1 4 2
2 3 2
2 4 2
0 3 1
1 3 1
2 3 1
3 3 1
3 4 1
0 1 3
0 2 3
0 4 3
1 2 3
1 4 3
2 4 3
3 4 3

result:

ok Kout = 21, Kans = 21

Test #19:

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

input:

5 4
0010
1001
0011
0101
1011

output:

-1

result:

ok Kout = -1, Kans = -1

Test #20:

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

input:

3 2
01
00
10

output:

1
0 1 1

result:

ok Kout = 1, Kans = 1

Test #21:

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

input:

3 2
10
11
00

output:

1
0 1 2

result:

ok Kout = 1, Kans = 1

Test #22:

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

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #23:

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

input:

3 27
111010110011101010011110110
010001110100000110100101101
000011111000000010011111001

output:

-1

result:

ok Kout = -1, Kans = -1

Test #24:

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

input:

3 7
1000100
0001100
0101111

output:

39
0 2 2
1 2 2
1 5 2
1 6 2
3 5 2
3 6 2
4 5 2
4 6 2
5 6 2
0 3 4
0 4 4
1 4 4
2 4 4
3 4 4
4 4 4
4 5 4
4 6 4
0 1 1
0 2 1
0 3 1
0 5 1
0 6 1
1 2 1
2 2 1
2 3 1
2 4 1
2 5 1
2 6 1
0 4 3
1 3 3
1 4 3
1 5 3
1 6 3
2 3 3
2 4 3
2 5 3
2 6 3
3 4 3
5 6 3

result:

ok Kout = 39, Kans = 39

Test #25:

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

input:

1 19
1010110011001101000

output:

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

result:

ok Kout = 532, Kans = 532

Test #26:

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

input:

5 32
10101101001001001101111100100110
00110110010111010101011000011010
01010101110100000110001000010100
11010011000110101101110001011111
00111001110011110000000010000111

output:

-1

result:

ok Kout = -1, Kans = -1

Test #27:

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

input:

3 12
110010101000
110001011000
110101011001

output:

145
0 1 2
0 2 2
0 3 2
0 4 2
0 5 2
0 6 2
0 7 2
0 8 2
0 9 2
0 10 2
0 11 2
1 2 2
1 3 2
1 4 2
1 5 2
1 6 2
1 7 2
1 8 2
1 9 2
1 10 2
1 11 2
2 9 2
2 10 2
3 9 2
3 10 2
3 11 2
4 6 2
4 9 2
4 10 2
5 7 2
5 9 2
5 10 2
5 11 2
6 9 2
6 10 2
7 9 2
7 10 2
7 11 2
8 9 2
8 10 2
8 11 2
9 10 2
0 0 4
0 1 4
0 2 4
0 3 4
0 4 ...

result:

ok Kout = 145, Kans = 145

Test #28:

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

input:

3 25
1110100100011100101100111
0100000001011101101010101
0111110111111001001110111

output:

-1

result:

ok Kout = -1, Kans = -1

Test #29:

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

input:

1 5
10110

output:

35
0 1 2
0 2 2
0 3 2
0 4 2
1 4 2
2 3 2
2 4 2
3 4 2
0 0 4
0 1 4
0 2 4
0 3 4
0 4 4
1 2 4
1 3 4
2 2 4
2 3 4
2 4 4
3 3 4
3 4 4
0 1 1
0 4 1
1 1 1
1 2 1
1 3 1
1 4 1
2 4 1
3 4 1
4 4 1
0 2 3
0 3 3
1 2 3
1 3 3
1 4 3
2 3 3

result:

ok Kout = 35, Kans = 35

Test #30:

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

input:

5 17
01011100010100110
01001101111011001
00100111001101010
10101000001010110
00101011010010001

output:

-1

result:

ok Kout = -1, Kans = -1

Test #31:

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

input:

3 30
010100010011100011010001010100
011111100101001100010101010010
011000010111111111000101101110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #32:

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

input:

5 30
110010101001001100010110010000
011011111000011001101000100000
110101010111000000100100111000
001111011110101101101001101011
101100001101011110101010110000

output:

-1

result:

ok Kout = -1, Kans = -1

Test #33:

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

input:

10 10
0110101111
1100100000
1000101100
1000010101
1001011101
1011101101
1011111011
0101010000
0111011010
1111010110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #34:

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

input:

9 10
1000001101
0110010110
1011101111
1010001110
1110001000
1001110110
1101010010
0001011111
1000010100

output:

-1

result:

ok Kout = -1, Kans = -1

Test #35:

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

input:

3 5
11111
01000
01100

output:

18
0 3 2
0 4 2
1 2 2
1 3 2
1 4 2
2 3 2
2 4 2
3 4 2
0 1 4
1 1 4
1 2 4
1 3 4
1 4 4
0 1 3
0 2 3
0 3 3
0 4 3
3 4 3

result:

ok Kout = 18, Kans = 18

Test #36:

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

input:

7 9
000010100
101001100
110010111
000000110
100010101
101000100
101101100

output:

-1

result:

ok Kout = -1, Kans = -1

Test #37:

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

input:

1 4
0000

output:

22
0 1 2
0 2 2
0 3 2
1 2 2
1 3 2
2 3 2
0 0 1
0 1 1
0 2 1
0 3 1
1 1 1
1 2 1
1 3 1
2 2 1
2 3 1
3 3 1
0 1 3
0 2 3
0 3 3
1 2 3
1 3 3
2 3 3

result:

ok Kout = 22, Kans = 22

Test #38:

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

input:

9 8
10011110
10111101
11001010
01000101
10110011
00101001
00101100
11010110
01000000

output:

-1

result:

ok Kout = -1, Kans = -1

Test #39:

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

input:

3 10
0000000111
1011011111
0101111010

output:

-1

result:

ok Kout = -1, Kans = -1

Test #40:

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

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #41:

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

input:

1 5
00110

output:

35
0 1 2
0 4 2
1 4 2
2 3 2
2 4 2
3 4 2
0 2 4
0 3 4
1 2 4
1 3 4
2 2 4
2 3 4
2 4 4
3 3 4
3 4 4
0 0 1
0 1 1
0 2 1
0 3 1
0 4 1
1 1 1
1 2 1
1 3 1
1 4 1
2 4 1
3 4 1
4 4 1
0 1 3
0 2 3
0 3 3
0 4 3
1 2 3
1 3 3
1 4 3
2 3 3

result:

ok Kout = 35, Kans = 35

Test #42:

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

input:

6 9
100101111
100001110
100101010
001101000
101100010
010101110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #43:

score: 0
Accepted
time: 8ms
memory: 4660kb

input:

6 836
001111110001001001101010101010011100010100100100111110110100101000100100000000011101110001011100111111111001101111111101101110010011000100100111111101011010101101011101010000100011100011000011111011011110000001010101001101110100001111111001000110111000010110001100110010010000101011001010101100...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #44:

score: 0
Accepted
time: 154ms
memory: 104816kb

input:

1 1680
00110010011001010101000101001110100010100110000110011101101101011011011011011011000000100100001111110111011001000010100101111110011000011110001000000001001010010110001011101000000110011010000001101010010000101111000010110001001010000010001010110000110111011011001011010011100111110000100110110...

output:

4232760
0 1 2
0 4 2
0 5 2
0 7 2
0 8 2
0 11 2
0 12 2
0 14 2
0 16 2
0 18 2
0 20 2
0 21 2
0 22 2
0 24 2
0 26 2
0 27 2
0 31 2
0 33 2
0 34 2
0 35 2
0 37 2
0 39 2
0 40 2
0 43 2
0 44 2
0 45 2
0 46 2
0 49 2
0 50 2
0 54 2
0 57 2
0 60 2
0 62 2
0 65 2
0 68 2
0 71 2
0 74 2
0 77 2
0 80 2
0 81 2
0 82 2
0 83 2
0 8...

result:

ok Kout = 4232760, Kans = 4232760

Test #45:

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

input:

5 525
010011011010110111000101111001010011110110100011110111000110010010000011011011110001110100110101101111111001100010010011011011011101110010011011001111110100010011011001010111011001100011001000101100111000000100010100011011011110101010000011101110001001000000100101000000101011101010110101010110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #46:

score: 0
Accepted
time: 11ms
memory: 5852kb

input:

9 1369
10111110110000010001000001110000001000010000101111010111111000100001001011101000101011000111001000010110010100011001110101100010000010000010100010011100110011000011110001001001010100010100001111111000111110100100010000100100110111110101100011010100000011000011010111111101011001011001010010110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #47:

score: 0
Accepted
time: 10ms
memory: 5928kb

input:

7 1509
10100001100101000101100011100001010001111101001010100101000010000100010000100110001011000011111000111100011100000110100100011010011111011100111010101011110111011011100100101110011000110111100101101011010101100011101011110001011101001011010100000011001001110100111101101001100110101111011010011...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #48:

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

input:

1 354
101000111100100010011000000111001111100100100101111010100100101010111001011110011010111111010010101111101101101010100011010000011011010101000011010000001101110011011000101101111011111001011010111100100001100000110000110011101011010011110011001100101100011101100010101001100101110011001011001011...

output:

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

result:

ok Kout = 187797, Kans = 187797

Test #49:

score: 0
Accepted
time: 9ms
memory: 5208kb

input:

5 1006
00111100011111100001101011101101000101000011011000111111110010111011001101010000100011001000000111001011010000001110010000101000010111100101100101101000110000011011101010111110101110100110000011001000010000011111000001011111101010110011100110010011010000000000100000111101000001000100101110100...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #50:

score: 0
Accepted
time: 25ms
memory: 6844kb

input:

9 1851
11000110100010011010000110010000010111101010100110011010100101110011100000101101001010000010001011111110100001101000001101111011011011011110010110000111001101110011001011111001110001011101100110111111100101100101000110010001011001100101010111100000101111010110010000110111010100011010111101110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #51:

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

input:

7 695
001100011101000101000011101100000101000000010110110101110110100101010100100111101110100100110101110100111000011000000101111101010100010010101011100101111001100001101111000111000111010110101101001111110111110001010011011111110111111010101010100100111010101010100111110011001100101100110010111101...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #52:

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

input:

8 231
010111111111010000001100101001011111011010100101010100111010100110111011111111101110001100001001101110001001000000001110010010010110011001011110100110110110101100101110101100101011000001101111101001110000101110110010000100111101010
00010011100001101010000101100000110001010100100010110011011111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #53:

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

input:

1751 1586
01101110101110010111101111101010000000001010101101111100000001001100010101101011011111100010010111010010010010111101000011101101010110011100010001111110110011001111111111010000101011010111101110010101010011100110001111101111010000001111101111101011110100011101101100000011100110100110000000...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #54:

score: 0
Accepted
time: 154ms
memory: 27240kb

input:

1879 942
000110000110010111010100001100110100110111110010011011100000001111011000110000000001110001001111110000010000110101111011101001001110000101111111101100101100110111111011001011001101101000011000000011110000011111111000010111000000001011101101110100011111101000110101000010011110101011110001111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #55:

score: 0
Accepted
time: 57ms
memory: 14116kb

input:

599 1083
111111011111001001100010010111010010011010111001100010011000101111110011111111000001001000000011110101011100100100000000001010100100011010010111010111011101010101010011001101100101011001110010111100000110111001000000100001111110000011001000100111100000110100100110010001011100101101111000110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #56:

score: 0
Accepted
time: 137ms
memory: 25328kb

input:

727 1927
001101011110100000000001100011110010101101011100011010001000111100001001110000111101111101101111111101011111110111010100110000100011110110001110011000101001001001001100101110111111111000011110111110010111110111111101000010011011000010111011010110100110101010100111010011110101000111101000001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #57:

score: 0
Accepted
time: 11ms
memory: 5800kb

input:

151 772
0011100000111101101010100111100010111101101001001010101000110100000010101010011001011010111110011100101101011110010000101110111011001110111110110011011001111101010011010110111011010011011001111101001100111001110110111001011010110100000000010101110000101011101001001110111011000000100100010000...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #58:

score: 0
Accepted
time: 19ms
memory: 8136kb

input:

279 912
1101101011000001010100111010110010110011000101001111100000100001110011010010001101010100000111011101111010100010100011001010010100110111000000001010010110111000110100010011101010011111010001011011100011011101101100110001111011101010000011000111001010001010110110000111001001100100100111100001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #59:

score: 0
Accepted
time: 59ms
memory: 14320kb

input:

1704 460
011100111111111110111100000010110110000111101010010100101100011011110101100111010000101111110001100100110111010100110011000011001100111101110110001010010010111110110000000000100111110110011000011110010101100101011011001001111010110010110011110011011100110111010111110111100010110010000101110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #60:

score: 0
Accepted
time: 39ms
memory: 9732kb

input:

1128 409
110010110101001111011001011001011000001111001001010001010110111111101101000111111110110110000111100001000010110010110010111001101111010010100000100000011100110010001010010010010000101100011010010111011110111010010010010110101100001001111111100111100000111010010001101010010011100010001110001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #61:

score: 0
Accepted
time: 134ms
memory: 25508kb

input:

1256 1253
00001111110000100001010011101010110110011010100000000010110000001011100101111001010101010001001100100011010101101100110100101011100100101101000111001010001010011101100000101101110100111100111101100100110100110010010000011001111100111111011111101101001111101000111111100010101111101111001001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #62:

score: 0
Accepted
time: 126ms
memory: 25416kb

input:

1537 1004
11100001111000100101010000101010000001010011001001110010100111110000000100110110010100111001010100001110001101111111111010001101001100110100110011100010001001110111111110110110111111000110011100000101100010110111110000000110011010001100100111111111011100110000101110010111111011110101000111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #63:

score: 0
Accepted
time: 632ms
memory: 72068kb

input:

2000 2000
00111010010010101011100101011110001000011110110110001001100001011010001110101110010111011100100111000011111100100110100110110000111111110010111100011110000000000010100010000001000100111000001110111111011101111010100110001111100111001100001001101011011101001011101000111011001011000101111101...

output:

2001000
0 1 2
0 5 2
0 7 2
0 10 2
0 11 2
0 13 2
0 17 2
0 21 2
0 22 2
0 24 2
0 26 2
0 32 2
0 33 2
0 36 2
0 37 2
0 50 2
0 51 2
0 54 2
0 58 2
0 67 2
0 69 2
0 75 2
0 79 2
0 80 2
0 90 2
0 91 2
0 93 2
0 94 2
0 99 2
0 101 2
0 108 2
0 109 2
0 111 2
0 112 2
0 115 2
0 117 2
0 121 2
0 124 2
0 125 2
0 127 2
0 13...

result:

ok Kout = 2001000, Kans = 2001000

Test #64:

score: 0
Accepted
time: 644ms
memory: 72088kb

input:

2000 2000
11101000100100110110110111100101111011101100110011001100010000010100011100000001100000111100000101101011000011010011111100111010101001101001110011110100011111011000011100000111010101111001001011000111011010011110100011001111100000001111110010111001000010000000000111100101011001011100111101...

output:

2001000
0 3 2
0 27 2
0 50 2
0 51 2
0 55 2
0 67 2
0 84 2
0 85 2
0 105 2
0 112 2
0 132 2
0 151 2
0 162 2
0 166 2
0 171 2
0 172 2
0 187 2
0 188 2
0 189 2
0 191 2
0 194 2
0 195 2
0 196 2
0 203 2
0 218 2
0 230 2
0 239 2
0 240 2
0 249 2
0 251 2
0 261 2
0 262 2
0 267 2
0 268 2
0 276 2
0 295 2
0 303 2
0 307...

result:

ok Kout = 2001000, Kans = 2001000

Test #65:

score: 0
Accepted
time: 650ms
memory: 72024kb

input:

2000 2000
11000010000110011011110010001111100101100111010111000100000000001001110111101110111000011010101101100011100101001101100100101100111001100100101010100101000100000101110011110001101101001001101101011110011101100000100111111100110011010011100001010001111001001111000110111011111001001010001101...

output:

2001000
0 4 2
0 5 2
0 8 2
0 9 2
0 10 2
0 13 2
0 14 2
0 17 2
0 22 2
0 23 2
0 25 2
0 26 2
0 28 2
0 34 2
0 36 2
0 39 2
0 41 2
0 45 2
0 46 2
0 50 2
0 51 2
0 53 2
0 54 2
0 55 2
0 57 2
0 58 2
0 60 2
0 61 2
0 62 2
0 65 2
0 66 2
0 70 2
0 79 2
0 83 2
0 84 2
0 89 2
0 91 2
0 95 2
0 96 2
0 99 2
0 100 2
0 101 2
...

result:

ok Kout = 2001000, Kans = 2001000

Test #66:

score: 0
Accepted
time: 625ms
memory: 72116kb

input:

2000 2000
10000000000101110100100101010010001110001100110100111110010000100100000100000000010100000001100010100101111011011101111010111110001100100001100011011101101101101001001010010100101011010001010110000000011011000110000111110011111101011111111110010110011111001010000110010010110110001110110101...

output:

2001000
0 2 2
0 8 2
0 9 2
0 10 2
0 12 2
0 19 2
0 28 2
0 38 2
0 43 2
0 46 2
0 48 2
0 49 2
0 56 2
0 58 2
0 60 2
0 64 2
0 68 2
0 70 2
0 75 2
0 76 2
0 78 2
0 80 2
0 82 2
0 86 2
0 87 2
0 90 2
0 94 2
0 99 2
0 100 2
0 102 2
0 109 2
0 119 2
0 128 2
0 132 2
0 135 2
0 143 2
0 146 2
0 161 2
0 164 2
0 171 2
0 1...

result:

ok Kout = 2001000, Kans = 2001000

Test #67:

score: 0
Accepted
time: 647ms
memory: 72080kb

input:

2000 2000
00100000000100010100101000010011001001111100100011100001100100111010000001000110100011011101010011100101101011011011011110100010011011101101111111000010001001111111111111100111100010101100101000100101011000011010100100111110100011100011110000111101011000010111010011101100101000010010001001...

output:

2001000
0 32 2
0 300 2
0 496 2
0 498 2
0 501 2
0 517 2
0 685 2
0 732 2
0 780 2
0 842 2
0 910 2
0 968 2
0 970 2
0 1110 2
0 1117 2
0 1134 2
0 1159 2
0 1300 2
0 1303 2
0 1341 2
0 1366 2
0 1378 2
0 1412 2
0 1428 2
0 1492 2
0 1516 2
0 1544 2
0 1633 2
0 1674 2
0 1677 2
0 1765 2
0 1820 2
0 1840 2
0 1864 2
...

result:

ok Kout = 2001000, Kans = 2001000

Test #68:

score: 0
Accepted
time: 638ms
memory: 72124kb

input:

2000 2000
00100101010000000000000111001011100001100111111110111110001000110111010001001111000010110111111011001011110101000011101110000110010010101100101000111111001110011100111100011110010100011000000011100000101010011001111001010000110100000101110010100101111010100100101010001100100000110111111111...

output:

2001000
0 6 2
0 8 2
0 10 2
0 11 2
0 12 2
0 13 2
0 14 2
0 16 2
0 17 2
0 18 2
0 19 2
0 20 2
0 21 2
0 22 2
0 27 2
0 35 2
0 36 2
0 49 2
0 55 2
0 59 2
0 60 2
0 61 2
0 64 2
0 70 2
0 71 2
0 72 2
0 80 2
0 81 2
0 83 2
0 88 2
0 95 2
0 98 2
0 108 2
0 110 2
0 112 2
0 113 2
0 117 2
0 121 2
0 123 2
0 124 2
0 128 ...

result:

ok Kout = 2001000, Kans = 2001000

Test #69:

score: 0
Accepted
time: 649ms
memory: 72048kb

input:

2000 2000
01111100110010011110000111001100000111000000101101110101111011011110100011101001110101011100110110110011100000100111010010010010110010111111010111011111111001001001001110111011010011000000011010010110011111000111011110101000011010100101100010100101101000100010111001101101001010011000100100...

output:

2001000
0 22 2
0 30 2
0 34 2
0 38 2
0 43 2
0 52 2
0 90 2
0 91 2
0 173 2
0 183 2
0 184 2
0 186 2
0 200 2
0 222 2
0 224 2
0 232 2
0 243 2
0 272 2
0 277 2
0 291 2
0 301 2
0 323 2
0 327 2
0 334 2
0 362 2
0 363 2
0 371 2
0 417 2
0 422 2
0 434 2
0 437 2
0 439 2
0 445 2
0 460 2
0 463 2
0 469 2
0 477 2
0 47...

result:

ok Kout = 2001000, Kans = 2001000

Test #70:

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

input:

2000 2000
10111110101111011000011101110000100100110001110000100010110010101111110001100010100101000100101101101010111001001111000010000110111100111100111100010000101100111010011111011110111010111110011111111010000001101101010111011001000011111111110111111100110111001011010100101100010000001111000010...

output:

2001000
0 3 2
0 10 2
0 11 2
0 12 2
0 13 2
0 16 2
0 23 2
0 28 2
0 30 2
0 37 2
0 38 2
0 40 2
0 43 2
0 46 2
0 57 2
0 60 2
0 63 2
0 66 2
0 67 2
0 68 2
0 71 2
0 73 2
0 74 2
0 80 2
0 86 2
0 88 2
0 90 2
0 97 2
0 102 2
0 104 2
0 106 2
0 112 2
0 113 2
0 114 2
0 116 2
0 117 2
0 118 2
0 122 2
0 130 2
0 132 2
0...

result:

ok Kout = 2001000, Kans = 2001000

Test #71:

score: 0
Accepted
time: 618ms
memory: 72124kb

input:

2000 2000
11100100001101010101010010010001010011100011010100110111000100101110000010000000111100011110001101000000110000101011001010011000000101000100110010111100100100111011110011000010001000101011111100110000111001000111101110001111011011000011100100101011110100111000010000100101100100111010010100...

output:

2001000
0 1 2
0 2 2
0 3 2
0 5 2
0 8 2
0 9 2
0 10 2
0 12 2
0 15 2
0 16 2
0 17 2
0 19 2
0 21 2
0 24 2
0 28 2
0 31 2
0 33 2
0 35 2
0 38 2
0 43 2
0 45 2
0 51 2
0 53 2
0 54 2
0 55 2
0 59 2
0 62 2
0 64 2
0 65 2
0 66 2
0 72 2
0 80 2
0 81 2
0 82 2
0 93 2
0 94 2
0 98 2
0 100 2
0 101 2
0 104 2
0 110 2
0 113 2...

result:

ok Kout = 2001000, Kans = 2001000

Test #72:

score: 0
Accepted
time: 647ms
memory: 72108kb

input:

2000 2000
01011010010100100110011111110101001010000110000100101000010010111100101001010010101111001011011101111010010111110111111111100000111000001110001101010010001010000110110011110001010110011111000100111100010111000111000110111011010011111100100010011011000000010101001010110010101010001001101001...

output:

2001000
0 2 2
0 7 2
0 8 2
0 12 2
0 15 2
0 16 2
0 20 2
0 28 2
0 32 2
0 33 2
0 37 2
0 38 2
0 39 2
0 44 2
0 45 2
0 48 2
0 49 2
0 54 2
0 56 2
0 61 2
0 69 2
0 72 2
0 74 2
0 77 2
0 81 2
0 86 2
0 87 2
0 89 2
0 92 2
0 96 2
0 101 2
0 103 2
0 106 2
0 124 2
0 126 2
0 127 2
0 134 2
0 139 2
0 140 2
0 141 2
0 144...

result:

ok Kout = 2001000, Kans = 2001000