QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666443 | #9170. Cycle Game | maspy | AC ✓ | 78ms | 17752kb | C++23 | 16.3kb | 2024-10-22 18:29:48 | 2024-10-22 18:29:58 |
Judging History
answer
#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
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); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(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>
T floor(T a, T b) {
return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = floor(x, y);
return {q, x - q * y};
}
template <typename T, typename U>
T SUM(const vector<U> &A) {
T sm = 0;
for (auto &&a: A) sm += a;
return sm;
}
#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) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
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;
(check(x) ? ok : ng) = 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;
(check(x) ? ok : ng) = 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;
}
template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
vc<T> &res = first;
(res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io.hpp"
#define FASTIO
#include <unistd.h>
// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[10000][4];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i][j] = n % 10 | '0';
n /= 10;
}
}
}
} constexpr pre;
inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
if (pir < SZ) ibuf[pir++] = '\n';
}
inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
void rd(char &c) {
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
}
void rd(string &x) {
x.clear();
char c;
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
do {
x += c;
if (pil == pir) load();
c = ibuf[pil++];
} while (!isspace(c));
}
template <typename T>
void rd_real(T &x) {
string s;
rd(s);
x = stod(s);
}
template <typename T>
void rd_integer(T &x) {
if (pil + 100 > pir) load();
char c;
do
c = ibuf[pil++];
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (c == '-') { minus = 1, c = ibuf[pil++]; }
}
x = 0;
while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (minus) x = -x;
}
}
void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }
template <class T, class U>
void rd(pair<T, U> &p) {
return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
if constexpr (N < std::tuple_size<T>::value) {
auto &x = std::get<N>(t);
rd(x);
rd_tuple<N + 1>(t);
}
}
template <class... T>
void rd(tuple<T...> &tpl) {
rd_tuple(tpl);
}
template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
for (auto &d: x) rd(d);
}
void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
rd(h), read(t...);
}
void wt(const char c) {
if (por == SZ) flush();
obuf[por++] = c;
}
void wt(const string s) {
for (char c: s) wt(c);
}
void wt(const char *s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) wt(s[i]);
}
template <typename T>
void wt_integer(T x) {
if (por > SZ - 100) flush();
if (x < 0) { obuf[por++] = '-', x = -x; }
int outi;
for (outi = 96; x >= 10000; outi -= 4) {
memcpy(out + outi, pre.num[x % 10000], 4);
x /= 10000;
}
if (x >= 1000) {
memcpy(obuf + por, pre.num[x], 4);
por += 4;
} else if (x >= 100) {
memcpy(obuf + por, pre.num[x] + 1, 3);
por += 3;
} else if (x >= 10) {
int q = (x * 103) >> 10;
obuf[por] = q | '0';
obuf[por + 1] = (x - q * 10) | '0';
por += 2;
} else
obuf[por++] = x | '0';
memcpy(obuf + por, out + outi + 4, 96 - outi);
por += 96 - outi;
}
template <typename T>
void wt_real(T x) {
ostringstream oss;
oss << fixed << setprecision(15) << double(x);
string s = oss.str();
wt(s);
}
void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }
template <class T, class U>
void wt(const pair<T, U> val) {
wt(val.first);
wt(' ');
wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
if constexpr (N < std::tuple_size<T>::value) {
if constexpr (N > 0) { wt(' '); }
const auto x = std::get<N>(t);
wt(x);
wt_tuple<N + 1>(t);
}
}
template <class... T>
void wt(tuple<T...> tpl) {
wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
template <class T>
void wt(const vector<T> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
wt(head);
if (sizeof...(Tail)) wt(' ');
print(forward<Tail>(tail)...);
}
// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;
#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif
#define INT(...) \
int __VA_ARGS__; \
read(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
read(__VA_ARGS__)
#define U32(...) \
u32 __VA_ARGS__; \
read(__VA_ARGS__)
#define U64(...) \
u64 __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 3 "main.cpp"
#line 2 "/home/maspy/compro/library/ds/rollback_array.hpp"
template <typename T>
struct Rollback_Array {
int N;
vc<T> dat;
vc<pair<int, T>> history;
Rollback_Array() {}
Rollback_Array(vc<T> x) : N(len(x)), dat(x) {}
Rollback_Array(int N) : N(N), dat(N) {}
template <typename F>
Rollback_Array(int N, F f) : N(N) {
dat.reserve(N);
FOR(i, N) dat.eb(f(i));
}
int time() { return len(history); }
void rollback(int t) {
FOR_R(i, t, time()) {
auto& [idx, v] = history[i];
dat[idx] = v;
}
history.resize(t);
}
T get(int idx) { return dat[idx]; }
void set(int idx, T x) {
history.eb(idx, dat[idx]);
dat[idx] = x;
}
vc<T> get_all() {
vc<T> res(N);
FOR(i, N) res[i] = get(i);
return res;
}
};
#line 2 "/home/maspy/compro/library/ds/unionfind/rollback_unionfind.hpp"
struct Rollback_UnionFind {
Rollback_Array<int> dat; // parent or size
Rollback_UnionFind(int n) : dat(vc<int>(n, -1)) {}
int operator[](int v) {
while (dat.get(v) >= 0) v = dat.get(v);
return v;
}
ll size(int v) { return -dat.get((*this)[v]); }
int time() { return dat.time(); }
void rollback(int t) { dat.rollback(t); }
void reset() { rollback(0); }
bool merge(int a, int b) {
a = (*this)[a], b = (*this)[b];
if (a == b) return false;
if (dat.get(a) > dat.get(b)) swap(a, b);
dat.set(a, dat.get(a) + dat.get(b));
dat.set(b, a);
return true;
}
};
#line 5 "main.cpp"
void solve() {
INT(H, W, Q);
string ANS(Q, '?');
/*
F 面の個数
F4 (2,2) square
*/
Rollback_UnionFind uf(H * W);
int F = 0, F4 = 0, F9 = 0;
int MEMO_F = 0, MEMO_F4 = 0, MEMO_F9 = 0, MEMO_time = 0;
auto snap = [&]() -> void { MEMO_F = F, MEMO_F4 = F4, MEMO_time = uf.time(); };
auto rb = [&]() -> void {
F = MEMO_F, F4 = MEMO_F4, F9 = MEMO_F9;
uf.rollback(MEMO_time);
};
vv(int, A, H, W);
auto isin = [&](int x, int y) -> bool { return (0 <= x && x < H && 0 <= y && y < W); };
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
auto idx = [&](int x, int y) -> int { return W * x + y; };
auto upd = [&](int x, int y) -> void {
A[x][y] = 1;
FOR(d, 4) {
int nx = x + dx[d], ny = y + dy[d];
if (!isin(nx, ny)) continue;
if (A[nx][ny] == 1 && !uf.merge(idx(x, y), idx(nx, ny))) ++F;
}
FOR(a, x - 1, x + 1) FOR(b, y - 1, y + 1) {
int cnt = 0;
FOR(dx, 2) FOR(dy, 2) { cnt += (isin(a + dx, b + dy) && A[a + dx][b + dy] == 1); }
F4 += (cnt == 4);
}
FOR(a, x - 2, x + 1) FOR(b, y - 2, y + 1) {
int cnt = 0;
FOR(dx, 3) FOR(dy, 3) { cnt += (isin(a + dx, b + dy) && A[a + dx][b + dy] == 1); }
F9 += (cnt == 9);
}
};
FOR(q, Q) {
INT(x, y);
--x, --y;
snap();
upd(x, y);
if (F > F4 || F9 > 0) {
ANS[q] = '0';
rb();
A[x][y] = 0;
} else {
ANS[q] = '1';
}
}
print(ANS);
}
signed main() { solve(); }
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
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: 3780kb
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: 3716kb
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: 3556kb
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: 3964kb
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: 3652kb
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: 3748kb
input:
1 4 1 1 2
output:
1
result:
ok "1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3916kb
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: 3660kb
input:
3 10 3 3 9 2 5 2 7
output:
111
result:
ok "111"
Test #10:
score: 0
Accepted
time: 0ms
memory: 16584kb
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: 11ms
memory: 7908kb
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: 18ms
memory: 6852kb
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: 3680kb
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: 4932kb
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: 8ms
memory: 4316kb
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: 46ms
memory: 16444kb
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: 52ms
memory: 17752kb
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: 54ms
memory: 15996kb
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: 63ms
memory: 16388kb
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: 78ms
memory: 14484kb
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: 16ms
memory: 14892kb
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: 19ms
memory: 16968kb
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: 10ms
memory: 13948kb
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: 62ms
memory: 12804kb
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: 71ms
memory: 13832kb
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