QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512834#9170. Cycle Gameucup-team987#AC ✓1161ms38624kbC++1715.0kb2024-08-10 16:00:332024-08-10 16:00:34

Judging History

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

  • [2024-08-10 16:00:34]
  • 评测
  • 测评结果:AC
  • 用时:1161ms
  • 内存:38624kb
  • [2024-08-10 16:00:33]
  • 提交

answer

/**
 * date   : 2024-08-10 17:00:26
 * author : Nyaan
 */

#define NDEBUG

using namespace std;

// intrinstic
#include <immintrin.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tr2/dynamic_bitset>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// utility

namespace Nyaan {
using ll = long long;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;

template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<vector<T>>;
using vi = vector<int>;
using vl = vector<long long>;
using vd = V<double>;
using vs = V<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template <typename T, typename U>
struct P : pair<T, U> {
  template <typename... Args>
  P(Args... args) : pair<T, U>(args...) {}

  using pair<T, U>::first;
  using pair<T, U>::second;

  P &operator+=(const P &r) {
    first += r.first;
    second += r.second;
    return *this;
  }
  P &operator-=(const P &r) {
    first -= r.first;
    second -= r.second;
    return *this;
  }
  P &operator*=(const P &r) {
    first *= r.first;
    second *= r.second;
    return *this;
  }
  template <typename S>
  P &operator*=(const S &r) {
    first *= r, second *= r;
    return *this;
  }
  P operator+(const P &r) const { return P(*this) += r; }
  P operator-(const P &r) const { return P(*this) -= r; }
  P operator*(const P &r) const { return P(*this) *= r; }
  template <typename S>
  P operator*(const S &r) const {
    return P(*this) *= r;
  }
  P operator-() const { return P{-first, -second}; }
};

using pl = P<ll, ll>;
using pi = P<int, int>;
using vp = V<pl>;

constexpr int inf = 1001001001;
constexpr long long infLL = 4004004004004004004LL;

template <typename T>
int sz(const T &t) {
  return t.size();
}

template <typename T, typename U>
inline bool amin(T &x, U y) {
  return (y < x) ? (x = y, true) : false;
}
template <typename T, typename U>
inline bool amax(T &x, U y) {
  return (x < y) ? (x = y, true) : false;
}

template <typename T>
inline T Max(const vector<T> &v) {
  return *max_element(begin(v), end(v));
}
template <typename T>
inline T Min(const vector<T> &v) {
  return *min_element(begin(v), end(v));
}
template <typename T>
inline long long Sum(const vector<T> &v) {
  return accumulate(begin(v), end(v), 0LL);
}

template <typename T>
int lb(const vector<T> &v, const T &a) {
  return lower_bound(begin(v), end(v), a) - begin(v);
}
template <typename T>
int ub(const vector<T> &v, const T &a) {
  return upper_bound(begin(v), end(v), a) - begin(v);
}

constexpr long long TEN(int n) {
  long long ret = 1, x = 10;
  for (; n; x *= x, n >>= 1) ret *= (n & 1 ? x : 1);
  return ret;
}

template <typename T, typename U>
pair<T, U> mkp(const T &t, const U &u) {
  return make_pair(t, u);
}

template <typename T>
vector<T> mkrui(const vector<T> &v, bool rev = false) {
  vector<T> ret(v.size() + 1);
  if (rev) {
    for (int i = int(v.size()) - 1; i >= 0; i--) ret[i] = v[i] + ret[i + 1];
  } else {
    for (int i = 0; i < int(v.size()); i++) ret[i + 1] = ret[i] + v[i];
  }
  return ret;
};

template <typename T>
vector<T> mkuni(const vector<T> &v) {
  vector<T> ret(v);
  sort(ret.begin(), ret.end());
  ret.erase(unique(ret.begin(), ret.end()), ret.end());
  return ret;
}

template <typename F>
vector<int> mkord(int N, F f) {
  vector<int> ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), f);
  return ord;
}

template <typename T>
vector<int> mkinv(vector<T> &v) {
  int max_val = *max_element(begin(v), end(v));
  vector<int> inv(max_val + 1, -1);
  for (int i = 0; i < (int)v.size(); i++) inv[v[i]] = i;
  return inv;
}

vector<int> mkiota(int n) {
  vector<int> ret(n);
  iota(begin(ret), end(ret), 0);
  return ret;
}

template <typename T>
T mkrev(const T &v) {
  T w{v};
  reverse(begin(w), end(w));
  return w;
}

template <typename T>
bool nxp(T &v) {
  return next_permutation(begin(v), end(v));
}

// 返り値の型は入力の T に依存
// i 要素目 : [0, a[i])
template <typename T>
vector<vector<T>> product(const vector<T> &a) {
  vector<vector<T>> ret;
  vector<T> v;
  auto dfs = [&](auto rc, int i) -> void {
    if (i == (int)a.size()) {
      ret.push_back(v);
      return;
    }
    for (int j = 0; j < a[i]; j++) v.push_back(j), rc(rc, i + 1), v.pop_back();
  };
  dfs(dfs, 0);
  return ret;
}

// F : function(void(T&)), mod を取る操作
// T : 整数型のときはオーバーフローに注意する
template <typename T>
T Power(T a, long long n, const T &I, const function<void(T &)> &f) {
  T res = I;
  for (; n; f(a = a * a), n >>= 1) {
    if (n & 1) f(res = res * a);
  }
  return res;
}
// T : 整数型のときはオーバーフローに注意する
template <typename T>
T Power(T a, long long n, const T &I = T{1}) {
  return Power(a, n, I, function<void(T &)>{[](T &) -> void {}});
}

template <typename T>
T Rev(const T &v) {
  T res = v;
  reverse(begin(res), end(res));
  return res;
}

template <typename T>
vector<T> Transpose(const vector<T> &v) {
  using U = typename T::value_type;
  if(v.empty()) return {};
  int H = v.size(), W = v[0].size();
  vector res(W, T(H, U{}));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      res[j][i] = v[i][j];
    }
  }
  return res;
}

template <typename T>
vector<T> Rotate(const vector<T> &v, int clockwise = true) {
  using U = typename T::value_type;
  int H = v.size(), W = v[0].size();
  vector res(W, T(H, U{}));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (clockwise) {
        res[W - 1 - j][i] = v[i][j];
      } else {
        res[j][H - 1 - i] = v[i][j];
      }
    }
  }
  return res;
}

}  // namespace Nyaan


// bit operation

namespace Nyaan {
__attribute__((target("popcnt"))) inline int popcnt(const u64 &a) {
  return __builtin_popcountll(a);
}
inline int lsb(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int ctz(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int msb(const u64 &a) { return a ? 63 - __builtin_clzll(a) : -1; }
template <typename T>
inline int gbit(const T &a, int i) {
  return (a >> i) & 1;
}
template <typename T>
inline void sbit(T &a, int i, bool b) {
  if (gbit(a, i) != b) a ^= T(1) << i;
}
constexpr long long PW(int n) { return 1LL << n; }
constexpr long long MSK(int n) { return (1LL << n) - 1; }
}  // namespace Nyaan


// inout

namespace Nyaan {

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  int s = (int)v.size();
  for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

istream &operator>>(istream &is, __int128_t &x) {
  string S;
  is >> S;
  x = 0;
  int flag = 0;
  for (auto &c : S) {
    if (c == '-') {
      flag = true;
      continue;
    }
    x *= 10;
    x += c - '0';
  }
  if (flag) x = -x;
  return is;
}

istream &operator>>(istream &is, __uint128_t &x) {
  string S;
  is >> S;
  x = 0;
  for (auto &c : S) {
    x *= 10;
    x += c - '0';
  }
  return is;
}

ostream &operator<<(ostream &os, __int128_t x) {
  if (x == 0) return os << 0;
  if (x < 0) os << '-', x = -x;
  string S;
  while (x) S.push_back('0' + x % 10), x /= 10;
  reverse(begin(S), end(S));
  return os << S;
}
ostream &operator<<(ostream &os, __uint128_t x) {
  if (x == 0) return os << 0;
  string S;
  while (x) S.push_back('0' + x % 10), x /= 10;
  reverse(begin(S), end(S));
  return os << S;
}

void in() {}
template <typename T, class... U>
void in(T &t, U &...u) {
  cin >> t;
  in(u...);
}

void out() { cout << "\n"; }
template <typename T, class... U, char sep = ' '>
void out(const T &t, const U &...u) {
  cout << t;
  if (sizeof...(u)) cout << sep;
  out(u...);
}

struct IoSetupNya {
  IoSetupNya() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(7);
  }
} iosetupnya;

}  // namespace Nyaan


// debug


#ifdef NyaanDebug
#define trc(...) (void(0))
#else
#define trc(...) (void(0))
#endif

#ifdef NyaanLocal
#define trc2(...) (void(0))
#else
#define trc2(...) (void(0))
#endif


// macro

#define each(x, v) for (auto&& x : v)
#define each2(x, y, v) for (auto&& [x, y] : v)
#define all(v) (v).begin(), (v).end()
#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
#define reg(i, a, b) for (long long i = (a); i < (b); i++)
#define regr(i, a, b) for (long long i = (b)-1; i >= (a); i--)
#define fi first
#define se second
#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)
#define inl(...)         \
  long long __VA_ARGS__; \
  in(__VA_ARGS__)
#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__)
#define in2(s, t)                           \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i]);                         \
  }
#define in3(s, t, u)                        \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i]);                   \
  }
#define in4(s, t, u, v)                     \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i], v[i]);             \
  }
#define die(...)             \
  do {                       \
    Nyaan::out(__VA_ARGS__); \
    return;                  \
  } while (0)


namespace Nyaan {
void solve();
}
int main() { Nyaan::solve(); }


//


struct RollbackUnionFind {
  vector<int> data;
  stack<pair<int, int> > history;
  int inner_snap;

  RollbackUnionFind(int sz) : inner_snap(0) { data.assign(sz, -1); }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    history.emplace(x, data[x]);
    history.emplace(y, data[y]);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if (data[k] < 0) return k;
    return find(data[k]);
  }

  int same(int x, int y) { return find(x) == find(y); }

  int size(int k) { return (-data[find(k)]); }

  void undo() {
    data[history.top().first] = history.top().second;
    history.pop();
    data[history.top().first] = history.top().second;
    history.pop();
  }

  void snapshot() { inner_snap = int(history.size() >> 1); }

  int get_state() { return int(history.size() >> 1); }

  void rollback(int state = -1) {
    if (state == -1) state = inner_snap;
    state <<= 1;
    assert(state <= (int)history.size());
    while (state < (int)history.size()) undo();
  }
};

/**
 * @brief RollbackつきUnion Find
 * @docs docs/data-structure/rollback-union-find.md
 */


using namespace Nyaan;

void q() {
  inl(du, mmy, K);
  vp p(K);
  in(p);

  vp ps = mkuni(p);
  sort(all(ps));

  RollbackUnionFind uf(K);
  set<pl> points, boxes;
  string ans(K, '0');

  V<pl> points_snap, boxes_snap;
  // snapshot を取る
  auto snapshot = [&]() {
    points_snap.clear();
    boxes_snap.clear();
    uf.snapshot();
  };
  // rollback する
  auto rollback = [&]() {
    each(pp, points_snap) points.erase(pp);
    each(pp, boxes_snap) boxes.erase(pp);
    uf.rollback();
  };

  // 左上を (i, j) とする box が発生するか?
  auto is_box = [&](int i, int j) -> bool {
    return points.count({i + 0, j + 0}) and points.count({i + 0, j + 1}) and
           points.count({i + 1, j + 0}) and points.count({i + 1, j + 1});
  };
  // 左上を (i, j) とする box の box が発生するか?
  auto is_boxs_box = [&](int i, int j) {
    return boxes.count({i + 0, j + 0}) and boxes.count({i + 0, j + 1}) and
           boxes.count({i + 1, j + 0}) and boxes.count({i + 1, j + 1});
  };
  // (i, j) box を追加する, 破綻したら false を返す
  auto add_box = [&](int i, int j) {
    assert(is_box(i, j));
    boxes.emplace(i, j);
    boxes_snap.emplace_back(i, j);
    rep(di, 2) rep(dj, 2) {
      if (is_boxs_box(i - di, j - dj)) return false;
    }
    return true;
  };

  // uf の index
  auto idx = [&](int i, int j) { return lb(ps, pl{i, j}); };

  // (i, j) を追加する。破綻したら false を返す
  auto add_point = [&](int i, int j) -> bool {
    points.emplace(i, j);
    points_snap.emplace_back(i, j);

    int flag[2][2];
    rep(di, 2) rep(dj, 2) flag[di][dj] = is_box(i - di, j - dj);

    // コーナー :
    if (flag[0][0] == 1 and flag[0][1] == 0 and flag[1][0] == 0 and
        flag[1][1] == 1 and uf.same(idx(i - 1, j), idx(i + 1, j)))
      return false;
    if (flag[0][0] == 0 and flag[0][1] == 1 and flag[1][0] == 1 and
        flag[1][1] == 0 and uf.same(idx(i - 1, j), idx(i + 1, j)))
      return false;

    set<pi> add;
    // box を追加
    if (flag[0][0] == 1) {
      if (!add_box(i - 0, j - 0)) return false;
      uf.unite(idx(i, j), idx(i + 1, j)), add.emplace(+1, 0);
      uf.unite(idx(i, j), idx(i, j + 1)), add.emplace(0, +1);
    }
    if (flag[0][1] == 1) {
      if (!add_box(i - 0, j - 1)) return false;
      uf.unite(idx(i, j), idx(i + 1, j)), add.emplace(+1, 0);
      uf.unite(idx(i, j), idx(i, j - 1)), add.emplace(0, -1);
    }
    if (flag[1][0] == 1) {
      if (!add_box(i - 1, j - 0)) return false;
      uf.unite(idx(i, j), idx(i - 1, j)), add.emplace(-1, 0);
      uf.unite(idx(i, j), idx(i, j + 1)), add.emplace(0, +1);
    }
    if (flag[1][1] == 1) {
      if (!add_box(i - 1, j - 1)) return false;
      uf.unite(idx(i, j), idx(i - 1, j)), add.emplace(-1, 0);
      uf.unite(idx(i, j), idx(i, j - 1)), add.emplace(0, -1);
    }

    // 辺を追加
    reg(di, -1, 2) reg(dj, -1, 2) {
      if (abs(di) + abs(dj) != 1) continue;
      if (!add.count({di, dj}) and points.count({i + di, j + dj})) {
        if (uf.same(idx(i, j), idx(i + di, j + dj))) return false;
        uf.unite(idx(i, j), idx(i + di, j + dj));
      }
    }
    return true;
  };

  rep(k, K) {
    snapshot();
    int x = p[k].fi, y = p[k].se;
    if (add_point(x, y)) {
      ans[k] = '1';
    } else {
      rollback();
    }
  }

  out(ans);
}

void Nyaan::solve() {
  int t = 1;
  // in(t);
  while (t--) q();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

4 3 7
2 1
2 2
2 3
3 1
3 2
4 1
4 2

output:

1111111

result:

ok "1111111"

Test #2:

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

input:

3 3 8
1 1
1 2
1 3
2 3
3 3
3 2
3 1
2 1

output:

11111110

result:

ok "11111110"

Test #3:

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

input:

10 10 7
9 1
6 6
3 8
8 7
5 10
1 7
1 2

output:

1111111

result:

ok "1111111"

Test #4:

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

input:

9 10 50
1 9
1 6
2 3
3 1
7 4
9 4
1 3
2 5
9 2
7 9
5 6
8 10
9 5
5 5
4 10
9 7
5 9
3 2
4 5
1 1
4 7
3 6
2 8
4 3
8 6
5 10
4 8
5 4
7 2
9 6
4 2
7 8
5 2
3 5
9 1
6 1
1 5
9 9
5 8
6 3
8 8
8 4
7 7
7 1
3 7
2 2
3 10
6 9
8 3
7 6

output:

11111111111111111111111111111111111111111111111111

result:

ok "11111111111111111111111111111111111111111111111111"

Test #5:

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

input:

3 5 11
1 5
2 4
1 2
1 3
3 3
3 1
3 4
2 3
1 4
2 1
2 5

output:

11111111111

result:

ok "11111111111"

Test #6:

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

input:

7 9 12
7 3
2 3
6 2
2 2
4 2
2 8
5 7
4 4
6 8
2 7
7 2
1 9

output:

111111111111

result:

ok "111111111111"

Test #7:

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

input:

1 4 1
1 2

output:

1

result:

ok "1"

Test #8:

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

input:

9 8 67
5 5
8 3
9 5
7 4
5 1
9 3
4 2
2 5
1 7
7 8
7 2
8 5
6 1
8 8
4 4
5 4
1 5
3 4
6 7
2 3
3 7
5 7
2 4
2 7
1 3
7 3
2 8
6 6
6 2
6 3
7 5
9 6
7 6
3 6
1 1
6 4
3 1
5 3
8 7
2 1
4 1
8 4
8 6
3 5
5 8
1 6
1 2
4 6
9 4
1 4
3 3
4 8
8 1
4 7
9 8
3 8
6 5
6 8
3 2
2 2
7 1
9 2
4 3
1 8
4 5
8 2
7 7

output:

1111111111111111111111111111111111111111111110010101101000101101101

result:

ok "111111111111111111111111111111...1111111110010101101000101101101"

Test #9:

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

input:

3 10 3
3 9
2 5
2 7

output:

111

result:

ok "111"

Test #10:

score: 0
Accepted
time: 23ms
memory: 5176kb

input:

222212 1 21562
105762 1
167947 1
127551 1
117618 1
174844 1
139867 1
156729 1
30554 1
54488 1
151832 1
132914 1
109432 1
212091 1
136499 1
17818 1
48806 1
95752 1
66607 1
39930 1
23054 1
160823 1
169054 1
96680 1
150677 1
52895 1
93103 1
118079 1
79155 1
194811 1
141874 1
138763 1
2600 1
121471 1
17...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #11:

score: 0
Accepted
time: 178ms
memory: 17172kb

input:

1 167058 126088
1 15282
1 63796
1 77270
1 88793
1 42787
1 129851
1 34468
1 74525
1 121105
1 157182
1 92736
1 102044
1 11284
1 23439
1 142720
1 128610
1 27437
1 105575
1 130827
1 152824
1 76358
1 152954
1 65509
1 139802
1 66299
1 108943
1 140446
1 112411
1 95814
1 115750
1 9667
1 55383
1 89323
1 6734...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #12:

score: 0
Accepted
time: 218ms
memory: 14376kb

input:

9 12788 86384
4 11931
2 8183
1 5816
7 10320
8 5754
4 10778
4 12280
7 12746
1 4699
3 7876
4 3044
2 4903
9 10252
8 10512
7 6546
8 1338
5 9700
1 9833
6 11315
2 4067
7 9350
9 8200
2 1718
1 2542
2 4596
9 367
5 12426
1 12166
5 7652
4 2316
9 1946
3 6187
4 3306
1 63
8 4132
3 12491
2 3951
8 4169
7 11801
9 46...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0010111100011000000100110101100"

Test #13:

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

input:

10 6 58
7 3
1 5
9 2
10 4
1 2
1 6
9 6
5 4
8 2
9 3
5 1
4 5
7 4
10 1
10 3
5 3
4 3
6 5
1 4
7 2
10 6
8 3
5 6
9 4
2 2
1 1
6 4
3 5
3 2
6 2
3 6
8 1
8 4
8 5
7 5
6 1
4 4
3 4
3 1
7 1
4 1
2 4
6 6
9 5
7 6
2 1
5 5
10 2
2 5
4 2
2 6
10 5
9 1
4 6
5 2
6 3
1 3
8 6

output:

1111111111111111111111111111111101111111111011011001000000

result:

ok "1111111111111111111111111111111101111111111011011001000000"

Test #14:

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

input:

23660 2 4698
10158 1
1229 1
51 2
10559 2
15495 2
19343 1
18458 1
19633 2
23151 1
11738 2
21366 1
12968 2
10474 1
10552 2
8067 2
7125 2
14643 1
7579 2
21608 2
7067 2
20400 1
14397 2
21474 2
8294 2
1332 1
18105 1
2285 1
1223 1
13429 2
18580 2
11156 2
5498 1
6830 1
8848 2
21334 2
11946 1
10177 1
5349 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #15:

score: 0
Accepted
time: 65ms
memory: 6792kb

input:

51 732 29706
14 458
6 600
18 452
43 262
24 685
51 192
14 248
50 672
16 65
45 191
25 196
1 447
4 574
32 493
16 100
39 715
17 397
37 644
32 580
32 622
22 160
20 694
29 120
30 302
7 283
18 290
51 420
20 553
42 681
11 724
26 528
50 497
46 500
3 534
36 58
42 167
18 534
1 654
50 276
37 386
19 649
14 41
8 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0100001111101110110110000010000"

Test #16:

score: 0
Accepted
time: 626ms
memory: 32416kb

input:

75000 4 225000
71753 3
13211 2
61737 3
59039 3
3674 3
50461 4
12758 3
69966 1
57525 1
42178 1
15054 1
66939 2
2798 4
74983 2
7250 2
2247 4
11438 1
67858 4
66527 2
21625 2
14111 2
28737 1
7431 4
11317 3
47421 2
51295 4
39591 4
20811 3
51582 3
47874 2
3238 2
10987 3
1225 1
58741 4
2141 3
35454 4
5021 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1101011111100100010101000000000"

Test #17:

score: 0
Accepted
time: 662ms
memory: 34564kb

input:

100000 3 240000
63826 2
25561 1
24122 3
56762 3
66822 2
24467 2
5419 1
59533 2
71406 2
62274 1
63084 1
33262 3
16614 2
71724 1
99182 1
3574 3
2804 2
40022 2
90379 1
44898 2
59169 3
55663 1
79971 2
30606 3
58613 3
38992 3
51702 1
10168 3
44411 3
39048 1
25384 2
276 1
68607 1
34137 1
72641 2
92427 1
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0101001000001000101001011110010"

Test #18:

score: 0
Accepted
time: 751ms
memory: 35208kb

input:

60000 5 250000
19905 3
6687 2
7727 4
23854 3
1329 4
45419 4
15116 1
35612 4
11560 1
16969 5
43328 4
30175 2
1587 5
15890 1
53896 3
43465 4
26642 2
3443 5
6697 5
6489 3
44351 2
48037 2
39926 5
974 1
20783 2
51437 4
31394 2
33663 2
26261 5
49301 4
2074 1
16999 4
48098 5
28754 4
27961 3
614 5
57608 2
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0010100101111000100000011001011"

Test #19:

score: 0
Accepted
time: 800ms
memory: 38624kb

input:

100000 3 270000
50999 2
78476 3
21423 1
26134 3
69234 1
48259 3
40043 1
92586 1
96544 3
65679 1
63139 1
79464 2
76129 3
3836 3
65093 1
81997 3
13905 2
82341 2
32201 1
42796 2
69216 3
14753 3
50176 3
66724 2
21607 3
9619 2
96579 1
59856 2
5086 1
89747 1
4122 3
8806 3
57529 2
6476 3
6689 2
97261 1
936...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000011010000000010100010001010"

Test #20:

score: 0
Accepted
time: 913ms
memory: 36456kb

input:

29997 10 272700
22251 10
4359 10
3780 4
23168 10
19310 8
784 2
21855 1
19914 4
279 9
26868 6
11534 3
17252 8
10865 2
15782 3
10134 4
17047 4
8318 5
11552 4
21333 1
2023 10
17397 5
13151 3
21068 3
1171 3
21112 4
23374 4
289 8
9248 3
19337 3
10005 7
16909 2
14103 5
3098 8
23534 3
7782 1
4765 7
10294 8...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1100000010000000010000000100010"

Test #21:

score: 0
Accepted
time: 170ms
memory: 22668kb

input:

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

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111110111111101111111011111111"

Test #22:

score: 0
Accepted
time: 253ms
memory: 28192kb

input:

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

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000000000000000000000000000001"

Test #23:

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

input:

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

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...1111111111111111111111111111111"

Test #24:

score: 0
Accepted
time: 1161ms
memory: 36124kb

input:

1000 300 300000
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0000001001001100100000110100001"

Test #25:

score: 0
Accepted
time: 1005ms
memory: 37812kb

input:

30000 10 300000
1 1
1 3
1 5
1 7
1 9
3 1
3 3
3 5
3 7
3 9
5 1
5 3
5 5
5 7
5 9
7 1
7 3
7 5
7 7
7 9
9 1
9 3
9 5
9 7
9 9
11 1
11 3
11 5
11 7
11 9
13 1
13 3
13 5
13 7
13 9
15 1
15 3
15 5
15 7
15 9
17 1
17 3
17 5
17 7
17 9
19 1
19 3
19 5
19 7
19 9
21 1
21 3
21 5
21 7
21 9
23 1
23 3
23 5
23 7
23 9
25 1
25 3...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok "111111111111111111111111111111...0001000000000000100000000010000"

Extra Test:

score: 0
Extra Test Passed