QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106748#5520. Distance ParitiesmaspyAC ✓94ms7348kbC++2318.8kb2023-05-19 02:39:192023-05-19 02:39:24

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 02:39:24]
  • Judged
  • Verdict: AC
  • Time: 94ms
  • Memory: 7348kb
  • [2023-05-19 02:39:19]
  • Submitted

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) {
  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/ds/unionfind/unionfind.hpp"

struct UnionFind {
  int n, n_comp;
  vc<int> dat; // par or (-size)
  UnionFind(int n = 0) { build(n); }

  void build(int m) {
    n = m, n_comp = m;
    dat.assign(n, -1);
  }

  int operator[](int x) {
    while (dat[x] >= 0) {
      int pp = dat[dat[x]];
      if (pp < 0) { return dat[x]; }
      x = dat[x] = pp;
    }
    return x;
  }

  ll size(int x) {
    assert(dat[x] < 0);
    return -dat[x];
  }

  bool merge(int x, int y) {
    x = (*this)[x], y = (*this)[y];
    if (x == y) return false;
    if (-dat[x] < -dat[y]) swap(x, y);
    dat[x] += dat[y], dat[y] = x, n_comp--;
    return true;
  }
};
#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 resize(int n) { N = n; }

  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 read_parent(int off = 1) {
    for (int v = 1; v < N; ++v) {
      INT(p);
      p -= off;
      add(p, v);
    }
    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);
    }
  }

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/shortest_path/warshall_floyd.hpp"

// 負辺があっても負閉路がなければ正しく動作する。
// 負閉路があるかどうかは、dist[v][v] < 0 となる v があるかどうかで判定。
template <typename T, typename GT>
vc<vc<T>> warshall_floyd(GT& G) {
  ll N = G.N;
  vv(T, dist, N, N, infty<T>);
  FOR(v, N) {
    dist[v][v] = 0;
    for (auto&& e: G[v]) chmin(dist[v][e.to], e.cost);
  }
  FOR(k, N) FOR(i, N) {
    if (dist[i][k] == infty<T>) continue;
    FOR(j, N) {
      if (dist[k][j] == infty<T>) continue;
      chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }
  return dist;
}
#line 5 "main.cpp"

void solve() {
  LL(N);
  Graph<int, 0> G(N);
  UnionFind uf(N);
  VEC(string, dat, N);
  FOR(i, N) {
    FOR(j, i + 1, N) {
      if (dat[i][j] == '1') {
        uf.merge(i, j);
        G.add(i, j, 1);
      }
    }
  }
  G.build();
  if (uf.n_comp != 1) return NO();
  auto mat = warshall_floyd<int, decltype(G)>(G);
  FOR(i, N) FOR(j, N) {
    if (mat[i][j] % 2 != (dat[i][j] - '0')) return NO();
  }
  YES();
  print(G.M);
  for (auto&& e: G.edges) { print(e.frm + 1, e.to + 1); }
}

signed main() {
  INT(T);
  FOR(T) solve();
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3368kb

input:

3
3
011
101
110
4
0100
1000
0001
0010
5
01010
10101
01010
10101
01010

output:

YES
3
1 2
1 3
2 3
NO
YES
6
1 2
1 4
2 3
2 5
3 4
4 5

result:

ok Correct (3 test cases)

Test #2:

score: 0
Accepted
time: 92ms
memory: 7308kb

input:

1
500
001001010000101001100000100011101011010001100110010000011000001100000011010001001111001010010101110100000100011000110111100010001000010111111000000101101010011111000010110010111100111110111000010000100100010010001110000100111000001111101011111101111110111110001000111110001011111100110011100100...

output:

YES
62433
1 3
1 6
1 8
1 13
1 15
1 18
1 19
1 25
1 29
1 30
1 31
1 33
1 35
1 36
1 38
1 42
1 43
1 46
1 47
1 50
1 56
1 57
1 63
1 64
1 71
1 72
1 74
1 78
1 81
1 82
1 83
1 84
1 87
1 89
1 92
1 94
1 96
1 97
1 98
1 100
1 106
1 110
1 111
1 115
1 116
1 118
1 119
1 120
1 121
1 125
1 129
1 134
1 136
1 137
1 138
1 ...

result:

ok Correct (1 test case)

Test #3:

score: 0
Accepted
time: 84ms
memory: 7348kb

input:

1
500
001010100000100110111000011101101110001000011110011000010011000000101110000011111110111000110110011111011101110010011100101110001000001010010011000011101000011110110101001010010110110001111101101100001100010110011100010001001011100111011001101110011010010001011101011110010111010011111001100101...

output:

YES
62414
1 3
1 5
1 7
1 13
1 16
1 17
1 19
1 20
1 21
1 26
1 27
1 28
1 30
1 31
1 33
1 34
1 35
1 39
1 44
1 45
1 46
1 47
1 50
1 51
1 56
1 59
1 60
1 67
1 69
1 70
1 71
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 85
1 86
1 87
1 91
1 92
1 94
1 95
1 98
1 99
1 100
1 101
1 102
1 104
1 105
1 106
1 108
1 109
1 110
1 11...

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 92ms
memory: 7268kb

input:

1
500
000110110101000000010111101011000001000011001001010001010100011101011111111111001010101010111001011110000000001100010001011110101100000001001000110000101011010111110101001101100000111111100011001000000111110001011101101000001101100001011100000000011101011011011011011011000010110111101111010101...

output:

YES
62389
1 4
1 5
1 7
1 8
1 10
1 12
1 20
1 22
1 23
1 24
1 25
1 27
1 29
1 30
1 36
1 41
1 42
1 45
1 48
1 50
1 54
1 56
1 58
1 62
1 63
1 64
1 66
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 81
1 83
1 85
1 87
1 89
1 91
1 92
1 93
1 96
1 98
1 99
1 100
1 101
1 111
1 112
1 116
1 120
1 122
1 123
1...

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 93ms
memory: 7348kb

input:

1
500
000111010001001110011010011100010100001101111101011100111011100000001010111010111100111011011110010111011000111100111011010100110101001010111001000101101100010111101010100101000000011001001110010000101010111100001000011111111110111000110110010010100000110000001010111111010111011100100101010110...

output:

YES
62423
1 4
1 5
1 6
1 8
1 12
1 15
1 16
1 17
1 20
1 21
1 23
1 26
1 27
1 28
1 32
1 34
1 39
1 40
1 42
1 43
1 44
1 45
1 46
1 48
1 50
1 51
1 52
1 55
1 56
1 57
1 59
1 60
1 61
1 69
1 71
1 73
1 74
1 75
1 77
1 79
1 80
1 81
1 82
1 85
1 86
1 87
1 89
1 90
1 92
1 93
1 94
1 95
1 98
1 100
1 101
1 102
1 104
1 105...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 87ms
memory: 7244kb

input:

1
500
001101100011010001011010101010010000100100100010011101111100101101110111101010001101100001110001001110000001010010111110001100110111111110000010110110111110000110111000001010111011010111011001101101110001011011011011101110101000011000010101011101000000011001111101011111001010111000101110000011...

output:

YES
62393
1 3
1 4
1 6
1 7
1 11
1 12
1 14
1 18
1 20
1 21
1 23
1 25
1 27
1 29
1 32
1 37
1 40
1 43
1 47
1 50
1 51
1 52
1 54
1 55
1 56
1 57
1 58
1 61
1 63
1 64
1 66
1 67
1 68
1 70
1 71
1 72
1 73
1 75
1 77
1 81
1 82
1 84
1 85
1 90
1 91
1 92
1 96
1 99
1 100
1 101
1 108
1 110
1 113
1 115
1 116
1 117
1 118
...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 53ms
memory: 4868kb

input:

3
288
011100101100101010010110010101010000101101000110011000110011100111100110100010010000110111111100100011110000000101111010110000101011000010000101101001011101111101010010111111100111111111001101010110001111011011111100111000111111011011110101101100101011111000011000110010000110000111110001
10000...

output:

YES
20659
1 2
1 3
1 4
1 7
1 9
1 10
1 13
1 15
1 17
1 20
1 22
1 23
1 26
1 28
1 30
1 32
1 37
1 39
1 40
1 42
1 46
1 47
1 50
1 51
1 55
1 56
1 59
1 60
1 61
1 64
1 65
1 66
1 67
1 70
1 71
1 73
1 77
1 80
1 85
1 86
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1 97
1 101
1 102
1 103
1 104
1 112
1 114
1 115
1 116
1 117
1...

result:

ok Correct (3 test cases)

Test #8:

score: 0
Accepted
time: 53ms
memory: 4792kb

input:

3
288
011000011000101100111000100010010111001110110011011100110100100010111010111100101110100111110011001010101101100111010011111100101011000001111100110011110100111100000101110111010110110001000011101010110000111100011100001101101100010010010011110110011100010110001111010011010010101100110011
10110...

output:

YES
20570
1 2
1 3
1 8
1 9
1 13
1 15
1 16
1 19
1 20
1 21
1 25
1 29
1 32
1 34
1 35
1 36
1 39
1 40
1 41
1 43
1 44
1 47
1 48
1 50
1 51
1 52
1 55
1 56
1 58
1 61
1 65
1 67
1 68
1 69
1 71
1 73
1 74
1 75
1 76
1 79
1 81
1 82
1 83
1 85
1 88
1 89
1 90
1 91
1 92
1 95
1 96
1 99
1 101
1 103
1 105
1 106
1 108
1 10...

result:

ok Correct (3 test cases)

Test #9:

score: 0
Accepted
time: 54ms
memory: 4708kb

input:

3
288
001001111011100000110001011100111011010000101001010101110011111111001011101000011010010101010100000001110100011001111001001101100001111100000111000100110110110101000011010010111000111111010110100110111011101001001001010000001000010010110011010000111001111101011011010111001111001000101001
00110...

output:

YES
20599
1 3
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 19
1 20
1 24
1 26
1 27
1 28
1 31
1 32
1 33
1 35
1 36
1 38
1 43
1 45
1 48
1 50
1 52
1 54
1 55
1 56
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 69
1 71
1 72
1 73
1 75
1 80
1 81
1 83
1 86
1 88
1 90
1 92
1 94
1 102
1 103
1 104
1 106
1 110
1 111
1 114
1 115
1 ...

result:

ok Correct (3 test cases)

Test #10:

score: 0
Accepted
time: 58ms
memory: 4796kb

input:

3
288
000111001111001111111100001011101110011001011100011110011100000000111110011000101011010000111011000000101000110011111100000101000001110110011100100111100101110101111010111000001010110000011001010111010010000110011010100011011011111100010100011011010001101101011100110111011010100111100011
00110...

output:

YES
20582
1 4
1 5
1 6
1 9
1 10
1 11
1 12
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 27
1 29
1 30
1 31
1 33
1 34
1 35
1 38
1 39
1 42
1 44
1 45
1 46
1 50
1 51
1 52
1 53
1 56
1 57
1 58
1 67
1 68
1 69
1 70
1 71
1 74
1 75
1 79
1 81
1 83
1 84
1 86
1 91
1 92
1 93
1 95
1 96
1 103
1 105
1 109
1 110
1 113
1 11...

result:

ok Correct (3 test cases)

Test #11:

score: 0
Accepted
time: 56ms
memory: 4840kb

input:

3
288
000110011111010001111101111001100001010110000010010011011011001100100011000100011111000010011000011001000001001101010111010101001100111101101101010000100010110000101101011101101010110110000110011001011101100010001011011110101100111101000110100101100110000110001001010011001111000111101001
00000...

output:

YES
20705
1 4
1 5
1 8
1 9
1 10
1 11
1 12
1 14
1 18
1 19
1 20
1 21
1 22
1 24
1 25
1 26
1 27
1 30
1 31
1 36
1 38
1 40
1 41
1 47
1 50
1 53
1 54
1 56
1 57
1 59
1 60
1 63
1 64
1 67
1 71
1 72
1 76
1 80
1 81
1 82
1 83
1 84
1 89
1 92
1 93
1 98
1 99
1 102
1 108
1 111
1 112
1 114
1 116
1 118
1 119
1 120
1 122...

result:

ok Correct (3 test cases)

Test #12:

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

input:

10
158
01100010011000000001011011110010100111101010001101000100110011111110111000110111110000101000010001001110110101101100101001001010111011001011101001000011100010
10111010111111011001011001110000110100101000110101101001111011111101011100010100010101011000110011000000111101011111101010011011011111...

output:

YES
6333
1 2
1 3
1 7
1 10
1 11
1 20
1 22
1 23
1 25
1 26
1 27
1 28
1 31
1 33
1 36
1 37
1 38
1 39
1 41
1 43
1 47
1 48
1 50
1 54
1 57
1 58
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 69
1 70
1 71
1 75
1 76
1 78
1 79
1 80
1 81
1 82
1 87
1 89
1 94
1 98
1 101
1 102
1 103
1 105
1 106
1 108
1 110
1 111
1 113
1 114...

result:

ok Correct (10 test cases)

Test #13:

score: 0
Accepted
time: 18ms
memory: 3476kb

input:

100
50
00110110011011111001110000110010010000111111001100
00001011101101000001011001101100111011111100111101
10011000011111111111010110100011101000101110100001
10101001101110010000000100100000111100010011001001
01110101100010111000101000010001111111010011110000
10001011110110000101000000001101011101...

output:

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

result:

ok Correct (100 test cases)

Test #14:

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

input:

1000
15
010011000011111
101111011100010
010000101011101
010010110101011
110100100010101
110000111000001
001111010010110
010101101001111
011001010010110
010100000011000
101010101101100
101100010110000
101010111010010
110100111000101
101111010000010
15
001100011010101
000111111100101
100011001110100
1...

output:

YES
55
1 2
1 5
1 6
1 11
1 12
1 13
1 14
1 15
2 3
2 4
2 5
2 6
2 8
2 9
2 10
2 14
3 7
3 9
3 11
3 12
3 13
3 15
4 5
4 7
4 8
4 10
4 12
4 14
4 15
5 7
5 11
5 13
5 15
6 7
6 8
6 9
6 15
7 8
7 11
7 13
7 14
8 9
8 12
8 13
8 14
8 15
9 11
9 13
9 14
10 11
10 12
11 12
11 13
13 14
14 15
YES
63
1 3
1 4
1 8
1 9
1 11
1 13...

result:

ok Correct (1000 test cases)

Test #15:

score: 0
Accepted
time: 12ms
memory: 3408kb

input:

10000
5
00100
00101
11001
00001
01110
5
00000
00010
00001
01000
00100
5
00111
00010
10010
11101
10010
5
00111
00000
10001
10001
10110
5
00010
00111
01001
11000
01100
5
00011
00000
00000
10001
10010
5
00001
00101
01001
00001
11110
5
00101
00001
10010
00100
11000
5
00100
00000
10001
00000
00100
5
0100...

output:

NO
NO
YES
6
1 3
1 4
1 5
2 4
3 4
4 5
NO
NO
NO
YES
5
1 5
2 3
2 5
3 5
4 5
NO
NO
YES
6
1 2
1 5
2 3
2 4
3 4
4 5
NO
NO
YES
6
1 2
1 3
1 4
1 5
3 5
4 5
YES
8
1 2
1 3
1 4
2 3
2 4
2 5
3 4
4 5
YES
6
1 2
1 3
1 4
2 3
2 4
2 5
NO
YES
6
1 2
1 5
2 4
3 4
3 5
4 5
YES
6
1 2
1 4
1 5
2 5
3 5
4 5
NO
NO
NO
NO
YES
6
1 2
1 3
...

result:

ok Correct (10000 test cases)

Test #16:

score: 0
Accepted
time: 84ms
memory: 7288kb

input:

1
500
000011011011011110011001000101111011000100101110101000101110110101010000111111111101110111110110110101101010100101110100111101111000110111001101101111010001100000000001000110010100111111101001100000100011100110011110100010001101110101100010101101000110000110100101111000100010101010111000001001...

output:

YES
62450
1 5
1 6
1 8
1 9
1 11
1 12
1 14
1 15
1 16
1 17
1 20
1 21
1 24
1 28
1 30
1 31
1 32
1 33
1 35
1 36
1 40
1 43
1 45
1 46
1 47
1 49
1 51
1 55
1 57
1 58
1 59
1 61
1 62
1 64
1 66
1 68
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 84
1 85
1 86
1 88
1 89
1 90
1 91
1 92
1 94
1 95
1 97
1 98
1 10...

result:

ok Correct (1 test case)

Test #17:

score: 0
Accepted
time: 87ms
memory: 7348kb

input:

1
500
011111010100100001101100100100111100100101111000111111001000111100010100000100111100111001001000011000100010001111100001100111110110010111000011010011100110100100010000010101101001011100001110011100001101111111010110111001111101000011111011101110010101101001110110001101001000001110110011000110...

output:

YES
62500
1 2
1 3
1 4
1 5
1 6
1 8
1 10
1 13
1 18
1 19
1 21
1 22
1 25
1 28
1 31
1 32
1 33
1 34
1 37
1 40
1 42
1 43
1 44
1 45
1 49
1 50
1 51
1 52
1 53
1 54
1 57
1 61
1 62
1 63
1 64
1 68
1 70
1 76
1 79
1 80
1 81
1 82
1 85
1 86
1 87
1 90
1 93
1 98
1 99
1 103
1 107
1 111
1 112
1 113
1 114
1 115
1 120
1 1...

result:

ok Correct (1 test case)

Test #18:

score: 0
Accepted
time: 83ms
memory: 7296kb

input:

1
500
011101100110100001010111000001000000110001010100110001011000001110010110110100001011100100110001111000010100010000101010110111101010100100100000101011000110001111011011001000001000010110101111110111100100110111100100001001010100011100111101111111101010110100111100110000011100011000101011110000...

output:

YES
62477
1 2
1 3
1 4
1 6
1 7
1 10
1 11
1 13
1 18
1 20
1 22
1 23
1 24
1 30
1 37
1 38
1 42
1 44
1 46
1 49
1 50
1 54
1 56
1 57
1 63
1 64
1 65
1 68
1 70
1 71
1 73
1 74
1 76
1 81
1 83
1 84
1 85
1 88
1 91
1 92
1 96
1 97
1 98
1 99
1 104
1 106
1 110
1 115
1 117
1 119
1 121
1 122
1 124
1 125
1 126
1 127
1 1...

result:

ok Correct (1 test case)

Test #19:

score: 0
Accepted
time: 93ms
memory: 7296kb

input:

1
500
001101110000000111110111111000111011101010100010100111000110101001001110001000101101010110001011101111100000101000010000110111010101000010110010110101001010010011110011110011001111001001111101010111000110010110000000110010111011101000011001111001001101000010000000100000110100111010110000101111...

output:

YES
62379
1 3
1 4
1 6
1 7
1 8
1 16
1 17
1 18
1 19
1 20
1 22
1 23
1 24
1 25
1 26
1 27
1 31
1 32
1 33
1 35
1 36
1 37
1 39
1 41
1 43
1 47
1 49
1 52
1 53
1 54
1 58
1 59
1 61
1 63
1 66
1 69
1 70
1 71
1 75
1 79
1 81
1 82
1 84
1 86
1 88
1 89
1 93
1 95
1 96
1 97
1 99
1 100
1 101
1 102
1 103
1 109
1 111
1 11...

result:

ok Correct (1 test case)

Test #20:

score: 0
Accepted
time: 87ms
memory: 7292kb

input:

1
500
011101110110001100010111100011110000111100110110111110101001000111111011011011110111011001101001010101000100011101101100001110011000010101110001100111010010110001010001010000100000111110110110100111010101010101111111001111101001101111100100100101000011011101011000011100110000110101011011110011...

output:

YES
62419
1 2
1 3
1 4
1 6
1 7
1 8
1 10
1 11
1 15
1 16
1 20
1 22
1 23
1 24
1 25
1 29
1 30
1 31
1 32
1 37
1 38
1 39
1 40
1 43
1 44
1 46
1 47
1 49
1 50
1 51
1 52
1 53
1 55
1 57
1 60
1 64
1 65
1 66
1 67
1 68
1 69
1 71
1 72
1 74
1 75
1 77
1 78
1 79
1 80
1 82
1 83
1 84
1 86
1 87
1 90
1 91
1 93
1 96
1 98
1...

result:

ok Correct (1 test case)

Test #21:

score: 0
Accepted
time: 21ms
memory: 4632kb

input:

3
288
000000000000000001000000000000000000000000010000000000000000000000000000110000101000000000000000100101000001000000000000000001001000000001000000000000000000000010100000000000000100000000000000010001000100001000000000000000000100000000000000110000100000000010000000000000000000100000001000
00000...

output:

NO
NO
YES
20715
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 14
1 17
1 18
1 20
1 21
1 22
1 23
1 25
1 31
1 32
1 34
1 35
1 36
1 37
1 38
1 39
1 42
1 45
1 46
1 47
1 48
1 53
1 58
1 59
1 63
1 65
1 66
1 67
1 71
1 74
1 77
1 79
1 80
1 82
1 84
1 86
1 88
1 90
1 91
1 92
1 93
1 94
1 95
1 96
1 98
1 104
1 109
1 110
1 1...

result:

ok Correct (3 test cases)

Test #22:

score: 0
Accepted
time: 21ms
memory: 4552kb

input:

3
288
000000010101000000000110101001100010110001000101101101100000010000011111000000100100000010100001111000010000010000000011111100000001000000000100000100100000100000010001000101000010100010010000100011000000000101001011011001011100011010111000110011000001000010000010000100001100100100000010
00000...

output:

NO
YES
20711
1 2
1 3
1 5
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 14
1 16
1 17
1 19
1 20
1 21
1 23
1 24
1 26
1 27
1 30
1 32
1 33
1 35
1 39
1 40
1 44
1 48
1 49
1 50
1 52
1 53
1 55
1 57
1 59
1 62
1 66
1 67
1 69
1 71
1 72
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 92
1 93
1 94
1 95
1 96
1 101
1 102
1 103
1 104
...

result:

ok Correct (3 test cases)

Test #23:

score: 0
Accepted
time: 27ms
memory: 4728kb

input:

3
288
010100011011100111101110111011101101001111101111100001011111110001101100111100000000111011101101110010010010001000100000101001001110001100001011100101010011011111010101001110111000000011010110101000101100111100010100010011110101101111100000010000100110000010100110011111010001110000101010
10101...

output:

YES
20739
1 2
1 4
1 8
1 9
1 11
1 12
1 13
1 16
1 17
1 18
1 19
1 21
1 22
1 23
1 25
1 26
1 27
1 29
1 30
1 31
1 33
1 34
1 36
1 39
1 40
1 41
1 42
1 43
1 45
1 46
1 47
1 48
1 49
1 54
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 66
1 67
1 69
1 70
1 73
1 74
1 75
1 76
1 85
1 86
1 87
1 89
1 90
1 91
1 93
1 94
1 96
1 97...

result:

ok Correct (3 test cases)

Test #24:

score: 0
Accepted
time: 34ms
memory: 4732kb

input:

3
288
001110110001001011000001111011000000000100100101000011001001010101001100011100011010101001011110011101100010101110110000011001010110011001011000001000011001001000101001001111000110101001111010001001100010010011011110110011111011101110010101010011001010111011101001001111001101111111101110
00111...

output:

YES
20737
1 3
1 4
1 5
1 7
1 8
1 12
1 15
1 17
1 18
1 24
1 25
1 26
1 27
1 29
1 30
1 40
1 43
1 46
1 48
1 53
1 54
1 57
1 60
1 62
1 64
1 66
1 69
1 70
1 74
1 75
1 76
1 80
1 81
1 83
1 85
1 87
1 90
1 92
1 93
1 94
1 95
1 98
1 99
1 100
1 102
1 103
1 107
1 109
1 111
1 112
1 113
1 115
1 116
1 122
1 123
1 126
1 ...

result:

ok Correct (3 test cases)

Test #25:

score: 0
Accepted
time: 34ms
memory: 4648kb

input:

3
288
000110111010001100000011101100100000010011101110101110010000010111001110100100000010010001111100111111110011101011110001100001010110101000001111100001111110110000100001111000000010000011010100000011110101001010001111111001011110101110000001110100011000110000101101000001100100101011001011
00011...

output:

YES
20653
1 4
1 5
1 7
1 8
1 9
1 11
1 15
1 16
1 23
1 24
1 25
1 27
1 28
1 31
1 38
1 41
1 42
1 43
1 45
1 46
1 47
1 49
1 51
1 52
1 53
1 56
1 62
1 64
1 65
1 66
1 69
1 70
1 71
1 73
1 76
1 83
1 86
1 90
1 91
1 92
1 93
1 94
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 107
1 108
1 109
1 111
1 113
1 114
1 11...

result:

ok Correct (3 test cases)

Test #26:

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

input:

10
158
00011000101011101100010000000100010100000011011101010100101000000010100111110000000011110100001101100001010111000010100010010010010010000111000010000000100000
00011000101011101100010000000100010100000011011101010100101000000010100111110000000011110100001101100001010111000010100010010010010010...

output:

NO
NO
NO
NO
NO
NO
YES
6241
1 2
1 6
1 7
1 9
1 10
1 12
1 13
1 20
1 21
1 23
1 25
1 26
1 31
1 32
1 34
1 35
1 36
1 37
1 39
1 41
1 43
1 44
1 46
1 47
1 48
1 49
1 51
1 52
1 56
1 57
1 58
1 61
1 62
1 63
1 64
1 66
1 68
1 69
1 70
1 72
1 73
1 74
1 76
1 78
1 80
1 81
1 85
1 87
1 89
1 91
1 94
1 95
1 96
1 97
1 98
1 ...

result:

ok Correct (10 test cases)

Test #27:

score: 0
Accepted
time: 12ms
memory: 3548kb

input:

100
50
00010000111001010111001110011110100011110010110110
00010001111101010111001110011110100011110000010010
00010000111001010111001110011110100011110010110110
11101110000010101000110001100001011100001111101101
00010000111001010111001110011110100011110000110110
00010000111001010111001110011110100011...

output:

YES
624
1 4
1 9
1 10
1 11
1 14
1 16
1 18
1 19
1 20
1 23
1 24
1 25
1 28
1 29
1 30
1 31
1 33
1 37
1 38
1 39
1 40
1 43
1 45
1 46
1 48
1 49
2 4
2 8
2 9
2 10
2 11
2 12
2 14
2 16
2 18
2 19
2 20
2 23
2 24
2 25
2 28
2 29
2 30
2 31
2 33
2 37
2 38
2 39
2 40
2 46
2 49
3 4
3 9
3 10
3 11
3 14
3 16
3 18
3 19
3 20...

result:

ok Correct (100 test cases)

Test #28:

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

input:

1000
15
000000000100001
000010111010100
000010011010100
000000000000001
011001100001010
000010110001110
010011011010000
011001100001010
011000100001010
100000000000001
011000100001010
000011011010100
011001000001000
000011011010000
100100000100000
15
000000000001000
000001000000101
000000101000010
0...

output:

NO
NO
YES
58
1 2
1 3
1 7
1 9
1 12
1 14
1 15
2 4
2 5
2 6
2 8
2 10
2 11
2 13
3 4
3 5
3 6
3 8
3 10
3 11
3 13
4 7
4 8
4 9
4 12
4 14
4 15
5 7
5 9
5 12
5 14
5 15
6 9
6 12
6 14
6 15
7 9
7 10
7 11
7 12
7 13
7 14
8 9
8 12
8 14
8 15
9 10
9 11
9 13
10 12
10 14
10 15
11 12
11 14
11 15
12 13
13 14
13 15
YES
55
1...

result:

ok Correct (1000 test cases)

Test #29:

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

input:

10000
5
01101
10111
11000
01001
11010
5
00011
00011
00011
11100
11100
5
01101
10110
11011
01101
10110
5
00010
00100
01000
10001
00010
5
00101
00010
10001
01000
10100
5
00110
00001
10010
10100
01000
5
00111
00110
11011
11100
10100
5
01111
10111
11001
11001
11110
5
01001
10001
00010
00100
11000
5
0001...

output:

YES
7
1 2
1 3
1 5
2 3
2 4
2 5
4 5
YES
6
1 4
1 5
2 4
2 5
3 4
3 5
YES
8
1 2
1 3
1 5
2 3
2 4
3 4
3 5
4 5
NO
NO
NO
YES
7
1 3
1 4
1 5
2 3
2 4
3 4
3 5
YES
9
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 5
4 5
NO
NO
YES
9
1 2
1 3
1 5
2 3
2 4
2 5
3 4
3 5
4 5
NO
NO
YES
8
1 2
1 3
1 4
1 5
2 3
2 4
3 4
4 5
YES
7
1 3
1 4
1 5
2 3...

result:

ok Correct (10000 test cases)

Test #30:

score: 0
Accepted
time: 77ms
memory: 7288kb

input:

1
500
010010100001010011000001000111010110100011001100100000110000011000000110100010011110010100101011101000001000110001101111000100010000101111110000001011010100111110000101100101111001111101110000100001001000100100011100001001110000011111010111111011111101111100010001111100010111111001100111001000...

output:

YES
62434
1 2
1 5
1 7
1 12
1 14
1 17
1 18
1 24
1 28
1 29
1 30
1 32
1 34
1 35
1 37
1 41
1 42
1 45
1 46
1 49
1 55
1 56
1 62
1 63
1 70
1 71
1 73
1 77
1 80
1 81
1 82
1 83
1 86
1 88
1 91
1 93
1 95
1 96
1 97
1 99
1 105
1 109
1 110
1 114
1 115
1 117
1 118
1 119
1 120
1 124
1 128
1 133
1 135
1 136
1 137
1 1...

result:

ok Correct (1 test case)

Test #31:

score: 0
Accepted
time: 87ms
memory: 7292kb

input:

1
500
010101000001001101110000111011011100010000111100110000100110000001011100000111111101110001101100111110111011100100111001011100010000010100100110000111010000111101101010010100101101100011111011011000011000101100111000100010010111001110110011011100110100100010111010111100101110100111110011001010...

output:

YES
62415
1 2
1 4
1 6
1 12
1 15
1 16
1 18
1 19
1 20
1 25
1 26
1 27
1 29
1 30
1 32
1 33
1 34
1 38
1 43
1 44
1 45
1 46
1 49
1 50
1 55
1 58
1 59
1 66
1 68
1 69
1 70
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 84
1 85
1 86
1 90
1 91
1 93
1 94
1 97
1 98
1 99
1 100
1 101
1 103
1 104
1 105
1 107
1 108
1 109
1 112...

result:

ok Correct (1 test case)

Test #32:

score: 0
Accepted
time: 88ms
memory: 7168kb

input:

1
500
001101101010000000101111010110000010000110010010100010101000111010111111111110010101010101110010111100000000011000100010111101011000000010010001100001010110101111101010011011000001111111000110010000001111100010111011010000011011000010111000000000111010110110110110110110000101101111011110101011...

output:

YES
62390
1 3
1 4
1 6
1 7
1 9
1 11
1 19
1 21
1 22
1 23
1 24
1 26
1 28
1 29
1 35
1 40
1 41
1 44
1 47
1 49
1 53
1 55
1 57
1 61
1 62
1 63
1 65
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 80
1 82
1 84
1 86
1 88
1 90
1 91
1 92
1 95
1 97
1 98
1 99
1 100
1 110
1 111
1 115
1 119
1 121
1 122
1 1...

result:

ok Correct (1 test case)

Test #33:

score: 0
Accepted
time: 86ms
memory: 7296kb

input:

1
500
001110100010011100110100111000101000011011111010111001110111000000010101110101111001110110111100101110110001111001110110101001101010010101110010001011011000101111010101001010000000110010011100100001010101111000010000111111111101110001101100100101000001100000010101111110101110111001001010101101...

output:

YES
62424
1 3
1 4
1 5
1 7
1 11
1 14
1 15
1 16
1 19
1 20
1 22
1 25
1 26
1 27
1 31
1 33
1 38
1 39
1 41
1 42
1 43
1 44
1 45
1 47
1 49
1 50
1 51
1 54
1 55
1 56
1 58
1 59
1 60
1 68
1 70
1 72
1 73
1 74
1 76
1 78
1 79
1 80
1 81
1 84
1 85
1 86
1 88
1 89
1 91
1 92
1 93
1 94
1 97
1 99
1 100
1 101
1 103
1 104
...

result:

ok Correct (1 test case)

Test #34:

score: 0
Accepted
time: 94ms
memory: 7248kb

input:

1
500
011011000110100010110101010100100001001001000100111011111001011011101111010100011011000011100010011100000010100101111100011001101111111100000101101101111100001101110000010101110110101110110011011011100010110110110111011101010000110000101010111010000000110011111010111110010101110001011100000111...

output:

YES
62393
1 2
1 3
1 5
1 6
1 10
1 11
1 13
1 17
1 19
1 20
1 22
1 24
1 26
1 28
1 31
1 36
1 39
1 42
1 46
1 49
1 50
1 51
1 53
1 54
1 55
1 56
1 57
1 60
1 62
1 63
1 65
1 66
1 67
1 69
1 70
1 71
1 72
1 74
1 76
1 80
1 81
1 83
1 84
1 89
1 90
1 91
1 95
1 98
1 99
1 100
1 107
1 109
1 112
1 114
1 115
1 116
1 117
1...

result:

ok Correct (1 test case)

Test #35:

score: 0
Accepted
time: 48ms
memory: 4724kb

input:

3
288
000101100101010010110010101010000101101000110011000110011100111100110100010010000110111111100100011110000000101111010110000101011000010000101101001011101111101010010111111100111111111001101010110001111010101111110011100011111101101111010110110010101111100001100011001000001100001111100010
00001...

output:

NO
NO
YES
20582
1 3
1 6
1 8
1 9
1 10
1 12
1 15
1 18
1 21
1 22
1 26
1 27
1 29
1 30
1 32
1 37
1 38
1 40
1 41
1 43
1 44
1 45
1 52
1 53
1 57
1 63
1 65
1 67
1 72
1 73
1 75
1 80
1 81
1 83
1 84
1 85
1 86
1 87
1 95
1 100
1 102
1 103
1 105
1 106
1 107
1 108
1 110
1 113
1 114
1 116
1 117
1 118
1 119
1 123
1 1...

result:

ok Correct (3 test cases)

Test #36:

score: 0
Accepted
time: 51ms
memory: 4820kb

input:

3
288
000011000101100111000100010010111001110110011011100110100100010111010111100101110100111110011100101010110110011101001111110010101100000111110011001111010011110000010111011101011011000100001110101011000011110001110000110110110001001001001111011000111000101100011110100110100101011001100111
00100...

output:

NO
NO
YES
20762
1 2
1 12
1 14
1 16
1 19
1 20
1 22
1 23
1 25
1 27
1 28
1 29
1 30
1 34
1 35
1 37
1 38
1 40
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 55
1 56
1 58
1 63
1 64
1 65
1 70
1 71
1 73
1 76
1 78
1 80
1 81
1 83
1 85
1 86
1 87
1 88
1 89
1 93
1 96
1 99
1 100
1 102
1 104
1 106
1 110
1 111
1 113
1 114
1 ...

result:

ok Correct (3 test cases)

Test #37:

score: 0
Accepted
time: 48ms
memory: 4768kb

input:

3
288
010011110111000001100010111001110110100001010010101011100111111110010111010000110100101010101000000011101000110011110010011011000011111000001110001001101101101010000110100101110001111110101101001101110111010010010010100000010000100101100110100001110011111010110110101110011110010001010011
10100...

output:

YES
20600
1 2
1 5
1 6
1 7
1 8
1 10
1 11
1 12
1 18
1 19
1 23
1 25
1 26
1 27
1 30
1 31
1 32
1 34
1 35
1 37
1 42
1 44
1 47
1 49
1 51
1 53
1 54
1 55
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 68
1 70
1 71
1 72
1 74
1 79
1 80
1 82
1 85
1 87
1 89
1 91
1 93
1 101
1 102
1 103
1 105
1 109
1 110
1 113
1 114
1 ...

result:

ok Correct (3 test cases)

Test #38:

score: 0
Accepted
time: 56ms
memory: 4804kb

input:

3
288
001110011110011111111000010111011100110010111000111100111000000001111100110001010110100001110110000001010001100111111000001010000011101100111001001111001011101011110101110000010101100000110010101110100100001100110101000110110111111000101000110110100011011010111001101110110101001111000111
00100...

output:

YES
20583
1 3
1 4
1 5
1 8
1 9
1 10
1 11
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 26
1 28
1 29
1 30
1 32
1 33
1 34
1 37
1 38
1 41
1 43
1 44
1 45
1 49
1 50
1 51
1 52
1 55
1 56
1 57
1 66
1 67
1 68
1 69
1 70
1 73
1 74
1 78
1 80
1 82
1 83
1 85
1 90
1 91
1 92
1 94
1 95
1 102
1 104
1 108
1 109
1 112
1 113...

result:

ok Correct (3 test cases)

Test #39:

score: 0
Accepted
time: 52ms
memory: 4776kb

input:

3
288
001100111110100011111011110011000010101100000100100110110110011001000110001000111110000100110000110010000010011010101110101010011001111011011010100001000101100001011010111011010101101100001100110010111011000100010110111101011001111010001101001011001100001100010010100110011110001111010010
00000...

output:

YES
20706
1 3
1 4
1 7
1 8
1 9
1 10
1 11
1 13
1 17
1 18
1 19
1 20
1 21
1 23
1 24
1 25
1 26
1 29
1 30
1 35
1 37
1 39
1 40
1 46
1 49
1 52
1 53
1 55
1 56
1 58
1 59
1 62
1 63
1 66
1 70
1 71
1 75
1 79
1 80
1 81
1 82
1 83
1 88
1 91
1 92
1 97
1 98
1 101
1 107
1 110
1 111
1 113
1 115
1 117
1 118
1 119
1 121
...

result:

ok Correct (3 test cases)

Test #40:

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

input:

10
158
00010011000000001011011110010100111100101000110100010011001111111011100011011111000010100001000100111011010110110010100010010101110110010111010010000111000101
00110101111110110010110011100001101000101000110101101001111011111101011100010100010101011000110011000000111101011111101001001101101111...

output:

NO
NO
YES
6125
1 2
1 3
1 5
1 6
1 8
1 9
1 10
1 11
1 12
1 14
1 16
1 17
1 18
1 19
1 22
1 25
1 30
1 31
1 42
1 43
1 44
1 45
1 46
1 48
1 49
1 53
1 58
1 60
1 61
1 63
1 64
1 65
1 67
1 68
1 69
1 72
1 73
1 75
1 76
1 77
1 78
1 79
1 82
1 83
1 84
1 85
1 89
1 90
1 92
1 94
1 95
1 101
1 107
1 108
1 110
1 111
1 112
...

result:

ok Correct (10 test cases)

Test #41:

score: 0
Accepted
time: 14ms
memory: 3512kb

input:

100
50
01101100110111110011100001100100100001111110011000
10010111011010000010110011011001110111111001111011
10010000111111111110101101000111010001011101000011
01100011011100100000001001000001111000100110010011
10000011000101110001010000100011111110100111100001
11000011101100001010000000011010111011...

output:

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

result:

ok Correct (100 test cases)

Test #42:

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

input:

1000
15
001100001111111
000000010000100
100111011010001
101000001101011
001001011101101
001010010111010
000000000010101
011011001011000
101110010100110
100111001000010
101001110000101
100111010000101
110010101011000
100101001100001
101110100011010
15
011000001010110
100011010101011
100111110010101
0...

output:

NO
YES
58
1 2
1 3
1 9
1 11
1 13
1 14
2 5
2 6
2 8
2 10
2 12
2 14
2 15
3 4
3 5
3 6
3 7
3 8
3 11
3 13
3 15
4 5
4 8
4 9
4 10
4 12
4 15
5 6
5 8
5 9
5 10
5 12
5 13
6 7
6 9
6 11
7 8
7 9
7 10
7 12
7 15
8 9
8 10
8 11
8 12
9 10
9 11
9 12
9 13
9 14
9 15
10 11
10 13
10 14
10 15
13 14
13 15
14 15
NO
NO
YES
61
1 ...

result:

ok Correct (1000 test cases)

Test #43:

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

input:

10000
5
01001
10010
00011
01100
10100
5
00001
00001
00000
00001
11010
5
01001
10110
01010
01100
10000
5
00101
00010
10000
01001
10010
5
00001
00100
01011
00100
10100
5
01100
10000
10010
00100
00000
5
01101
10011
10001
01000
11100
5
01001
10001
00000
00001
11010
5
00000
00101
01000
00001
01010
5
0000...

output:

YES
5
1 2
1 5
2 4
3 4
3 5
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
6
1 2
1 5
2 3
2 4
2 5
4 5
YES
6
1 3
1 5
2 4
2 5
3 4
3 5
NO
NO
NO
NO
YES
6
1 3
1 4
1 5
2 3
2 4
4 5
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
9
1 2
1 3
1 4
2 3
2 4
2 5
3 4
3 5
4 5
NO
NO
NO
YES
7
1 4
1 5
2 3
2 4
2 5
3 5
4 5
NO
NO
...

result:

ok Correct (10000 test cases)