QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#84367 | #5670. Group Guests | noimi | AC ✓ | 1259ms | 515960kb | C++20 | 37.2kb | 2023-03-06 12:22:13 | 2023-03-07 14:45:10 |
Judging History
answer
#pragma region Macros
#ifdef noimi
#include "my_template.hpp"
#else
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 <immintrin.h>
#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 <tuple>
#include <type_traits>
#include <variant>
#ifdef noimi
#define oj_local(a, b) b
#else
#define oj_local(a, b) a
#endif
#define LOCAL if(oj_local(0, 1))
#define OJ if(oj_local(1, 0))
using namespace std;
using ll = long long;
using ull = unsigned long long int;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vc<T>>;
template <typename T> using vvvc = vector<vvc<T>>;
using vi = vc<int>;
using vl = vc<ll>;
using vpi = vc<pii>;
using vpl = vc<pll>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T> int si(const T &x) { return x.size(); }
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); }
vi iota(int n) {
vi a(n);
return iota(a.begin(), a.end(), 0), a;
}
template <typename T> vi iota(const vector<T> &a, bool greater = false) {
vi res(a.size());
iota(res.begin(), res.end(), 0);
sort(res.begin(), res.end(), [&](int i, int j) {
if(greater) return a[i] > a[j];
return a[i] < a[j];
});
return res;
}
// macros
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define endl '\n'
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define fore0(a) rep(a.size())
#define fore1(i, a) for(auto &&i : a)
#define fore2(a, b, v) for(auto &&[a, b] : v)
#define fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) overload5(__VA_ARGS__, fore4, fore3, fore2, fore1, fore0)(__VA_ARGS__)
#define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))
#define perm(v) for(bool flag = true; (flag ? exchange(flag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
template <typename T = ll, typename S> T SUM(const S &v) { return accumulate(all(v), T(0)); }
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#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__))))
constexpr pii dx4[4] = {pii{1, 0}, pii{0, 1}, pii{-1, 0}, pii{0, -1}};
constexpr pii dx8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
namespace yesno_impl {
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
const string firstsecond[2] = {"second", "first"};
const string FirstSecond[2] = {"Second", "First"};
const string possiblestr[2] = {"impossible", "possible"};
const string Possiblestr[2] = {"Impossible", "Possible"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { cout << yesno[t] << endl; }
void no(bool t = 1) { yes(!t); }
void first(bool t = 1) { cout << firstsecond[t] << endl; }
void First(bool t = 1) { cout << FirstSecond[t] << endl; }
void possible(bool t = 1) { cout << possiblestr[t] << endl; }
void Possible(bool t = 1) { cout << Possiblestr[t] << endl; }
}; // namespace yesno_impl
using namespace yesno_impl;
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
IN(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
IN(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
IN(name)
#define VEC2(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) \
vector<type> name1(size), name2(size), name3(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) \
vector<type> name1(size), name2(size), name3(size), name4(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(tail...);
}
template <typename T, typename S> T ceil(T x, S y) {
assert(y);
return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y));
}
template <typename T, typename S> T floor(T x, S y) {
assert(y);
return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : x / y - (x % y == 0 ? 0 : 1)));
}
template <typename T, typename S, typename U> U bigmul(const T &x, const S &y, const U &lim) { // clamp(x * y, -lim, lim)
if(x < 0 and y < 0) return bigmul(-x, -y, lim);
if(x < 0) return -bigmul(-x, y, lim);
if(y < 0) return -bigmul(x, -y, lim);
return y == 0 or x <= lim / y ? x * y : lim;
}
template <class T> T POW(T x, int n) {
T res = 1;
for(; n; n >>= 1, x *= x)
if(n & 1) res *= x;
return res;
}
template <class T, class S> T POW(T x, S n, const ll &mod) {
T res = 1;
x %= mod;
for(; n; n >>= 1, x = x * x % mod)
if(n & 1) res = res * x % mod;
return res;
}
vector<pll> factor(ll x) {
vector<pll> ans;
for(ll i = 2; i * i <= x; i++)
if(x % i == 0) {
ans.push_back({i, 1});
while((x /= i) % i == 0) ans.back().second++;
}
if(x != 1) ans.push_back({x, 1});
return ans;
}
template <class T> vector<T> divisor(T x) {
vector<T> ans;
for(T i = 1; i * i <= x; i++)
if(x % i == 0) {
ans.pb(i);
if(i * i != x) ans.pb(x / i);
}
return ans;
}
template <typename T> void zip(vector<T> &x) {
vector<T> y = x;
UNIQUE(y);
for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }
}
template <class S> void fold_in(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void fold_in(vector<S> &v, Head &&a, Tail &&...tail) {
for(auto e : a) v.emplace_back(e);
fold_in(v, tail...);
}
template <class S> void renumber(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void renumber(vector<S> &v, Head &&a, Tail &&...tail) {
for(auto &&e : a) e = lb(v, e);
renumber(v, tail...);
}
template <class S, class... Args> vector<S> zip(vector<S> &head, Args &&...args) {
vector<S> v;
fold_in(v, head, args...);
sort(all(v)), v.erase(unique(all(v)), v.end());
renumber(v, head, args...);
return v;
}
template <typename S> void rearrange(const vector<S> &id) {}
template <typename S, typename T> void rearrange_exec(const vector<S> &id, vector<T> &v) {
vector<T> w(v.size());
rep(i, si(id)) w[i] = v[id[i]];
v.swap(w);
}
// 並び替える順番, 並び替える vector 達
template <typename S, typename Head, typename... Tail> void rearrange(const vector<S> &id, Head &a, Tail &...tail) {
rearrange_exec(id, a);
rearrange(id, tail...);
}
template <typename T> vector<T> RUI(const vector<T> &v) {
vector<T> res(v.size() + 1);
for(int i = 0; i < v.size(); i++) res[i + 1] = res[i] + v[i];
return res;
}
template <typename T> void zeta_supersetsum(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] += f[b | i];
}
template <typename T> void zeta_subsetsum(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] += f[b];
}
template <typename T> void mobius_subset(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] -= f[b | i];
}
template <typename T> void mobius_superset(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] -= f[b];
}
// 反時計周りに 90 度回転
template <typename T> void rot(vector<vector<T>> &v) {
if(empty(v)) return;
int n = v.size(), m = v[0].size();
vector<vector<T>> res(m, vector<T>(n));
rep(i, n) rep(j, m) res[m - 1 - j][i] = v[i][j];
v.swap(res);
}
// x in [l, r)
template <class T, class S> bool inc(const T &x, const S &l, const S &r) { return l <= x and x < r; }
// 便利関数
constexpr ll ten(int n) { return n == 0 ? 1 : ten(n - 1) * 10; }
constexpr ll tri(ll n) { return n * (n + 1) / 2; }
// l + ... + r
constexpr ll tri(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }
ll max(int x, ll y) { return max((ll)x, y); }
ll max(ll x, int y) { return max(x, (ll)y); }
int min(int x, ll y) { return min((ll)x, y); }
int min(ll x, int y) { return min(x, (ll)y); }
// bit 演算系
#define bit(i) (1LL << i) // (1 << i)
#define test(b, i) (b >> i & 1) // b の i bit 目が立っているか
ll pow2(int i) { return 1LL << i; }
int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); }
// int allbit(int n) { return (1 << n) - 1; }
constexpr ll mask(int n) { return (1LL << n) - 1; }
// int popcount(signed t) { return __builtin_popcount(t); }
// int popcount(ll t) { return __builtin_popcountll(t); }
int popcount(uint64_t t) { return __builtin_popcountll(t); }
static inline uint64_t popcount64(uint64_t x) {
uint64_t m1 = 0x5555555555555555ll;
uint64_t m2 = 0x3333333333333333ll;
uint64_t m4 = 0x0F0F0F0F0F0F0F0Fll;
uint64_t h01 = 0x0101010101010101ll;
x -= (x >> 1) & m1;
x = (x & m2) + ((x >> 2) & m2);
x = (x + (x >> 4)) & m4;
return (x * h01) >> 56;
}
bool ispow2(int i) { return i && (i & -i) == i; }
ll rnd(ll l, ll r) { //[l, r)
#ifdef noimi
static mt19937_64 gen;
#else
static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
#endif
return uniform_int_distribution<ll>(l, r - 1)(gen);
}
ll rnd(ll n) { return rnd(0, n); }
template <class t> void random_shuffle(vc<t> &a) { rep(i, si(a)) swap(a[i], a[rnd(0, i + 1)]); }
int in() {
int x;
cin >> x;
return x;
}
ll lin() {
unsigned long long x;
cin >> x;
return x;
}
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x) { return pair<T, S>(-x.first, -x.second); }
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi - y.fi, x.se - y.se); }
template <class T, class S> pair<T, S> operator+(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi + y.fi, x.se + y.se); }
template <class T> pair<T, T> operator&(const pair<T, T> &l, const pair<T, T> &r) { return pair<T, T>(max(l.fi, r.fi), min(l.se, r.se)); }
template <class T, class S> pair<T, S> operator+=(pair<T, S> &l, const pair<T, S> &r) { return l = l + r; }
template <class T, class S> pair<T, S> operator-=(pair<T, S> &l, const pair<T, S> &r) { return l = l - r; }
template <class T> bool intersect(const pair<T, T> &l, const pair<T, T> &r) { return (l.se < r.se ? r.fi < l.se : l.fi < r.se); }
template <class T> vector<T> &operator++(vector<T> &v) {
fore(e, v) e++;
return v;
}
template <class T> vector<T> operator++(vector<T> &v, int) {
auto res = v;
fore(e, v) e++;
return res;
}
template <class T> vector<T> &operator--(vector<T> &v) {
fore(e, v) e--;
return v;
}
template <class T> vector<T> operator--(vector<T> &v, int) {
auto res = v;
fore(e, v) e--;
return res;
}
template <class T> vector<T> &operator+=(vector<T> &l, const vector<T> &r) {
fore(e, r) l.eb(e);
return l;
}
template <typename T> struct edge {
int from, to;
T cost;
int id;
edge(int to, T cost) : from(-1), to(to), cost(cost) {}
edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}
constexpr bool operator<(const edge<T> &rhs) const noexcept { return cost < rhs.cost; }
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
friend ostream operator<<(ostream &os, const edge &e) { return os << e.to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T = int> Edges<T> read_edges(int m, bool weighted = false) {
Edges<T> res;
res.reserve(m);
for(int i = 0; i < m; i++) {
int u, v, c = 0;
scan(u), scan(v), u--, v--;
if(weighted) scan(c);
res.eb(u, v, c, i);
}
return res;
}
using Tree = vector<vector<int>>;
using Graph = vector<vector<int>>;
template <class T> using Wgraph = vector<vector<edge<T>>>;
Graph getG(int n, int m = -1, bool directed = false, int margin = 1) {
Tree res(n);
if(m == -1) m = n - 1;
while(m--) {
int a, b;
cin >> a >> b;
a -= margin, b -= margin;
res[a].emplace_back(b);
if(!directed) res[b].emplace_back(a);
}
return res;
}
Graph getTreeFromPar(int n, int margin = 1) {
Graph res(n);
for(int i = 1; i < n; i++) {
int a;
cin >> a;
res[a - margin].emplace_back(i);
}
return res;
}
template <class T> Wgraph<T> getWg(int n, int m = -1, bool directed = false, int margin = 1) {
Wgraph<T> res(n);
if(m == -1) m = n - 1;
while(m--) {
int a, b;
T c;
scan(a), scan(b), scan(c);
a -= margin, b -= margin;
res[a].emplace_back(b, c);
if(!directed) res[b].emplace_back(a, c);
}
return res;
}
void add(Graph &G, int x, int y) { G[x].eb(y), G[y].eb(x); }
template <class S, class T> void add(Wgraph<S> &G, int x, int y, T c) { G[x].eb(y, c), G[y].eb(x, c); }
#define TEST \
INT(testcases); \
while(testcases--)
i128 abs(const i128 &x) { return x > 0 ? x : -x; }
istream &operator>>(istream &is, i128 &v) {
string s;
is >> s;
v = 0;
for(int i = 0; i < (int)s.size(); i++) {
if(isdigit(s[i])) { v = v * 10 + s[i] - '0'; }
}
if(s[0] == '-') { v *= -1; }
return is;
}
ostream &operator<<(ostream &os, const i128 &v) {
if(v == 0) { return (os << "0"); }
i128 num = v;
if(v < 0) {
os << '-';
num = -num;
}
string s;
for(; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
reverse(s.begin(), s.end());
return (os << s);
}
namespace aux {
template <typename T, unsigned N, unsigned L> struct tp {
static void output(std::ostream &os, const T &v) {
os << std::get<N>(v) << (&os == &cerr ? ", " : " ");
tp<T, N + 1, L>::output(os, v);
}
};
template <typename T, unsigned N> struct tp<T, N, N> {
static void output(std::ostream &os, const T &v) { os << std::get<N>(v); }
};
} // namespace aux
template <typename... Ts> std::ostream &operator<<(std::ostream &os, const std::tuple<Ts...> &t) {
if(&os == &cerr) { os << '('; }
aux::tp<std::tuple<Ts...>, 0, sizeof...(Ts) - 1>::output(os, t);
if(&os == &cerr) { os << ')'; }
return os;
}
template <typename T, typename S, typename U> std::ostream &operator<<(std::ostream &os, const priority_queue<T, S, U> &_pq) {
auto pq = _pq;
vector<T> res;
while(!empty(pq)) res.emplace_back(pq.top()), pq.pop();
return os << res;
}
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) {
if(&os == &cerr) { return os << "(" << p.first << ", " << p.second << ")"; }
return os << p.first << " " << p.second;
}
template <class Ch, class Tr, class Container> std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, const Container &x) {
bool f = true;
if(&os == &cerr) os << "[";
for(auto &y : x) {
if(&os == &cerr)
os << (f ? "" : ", ") << y;
else
os << (f ? "" : " ") << y;
f = false;
}
if(&os == &cerr) os << "]";
return os;
}
#define dump(...) static_cast<void>(0)
#define dbg(...) static_cast<void>(0)
void OUT() { cout << endl; }
template <class Head, class... Tail> void OUT(const Head &head, const Tail &...tail) {
cout << head;
if(sizeof...(tail)) cout << ' ';
OUT(tail...);
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template <class T, class S> constexpr pair<T, S> inf<pair<T, S>> = {inf<T>, inf<S>};
template <class T> void OUT2(const T &t, T INF = inf<T>, T res = -1) { OUT(t != INF ? t : res); }
template <class T> void OUT2(vector<T> &v, T INF = inf<T>, T res = -1) {
fore(e, v) if(e == INF) e = res;
OUT(v);
fore(e, v) if(e == res) e = INF;
}
template <class F> struct REC {
F f;
REC(F &&f_) : f(forward<F>(f_)) {}
template <class... Args> auto operator()(Args &&...args) const { return f(*this, forward<Args>(args)...); }
};
template <class S> vector<pair<S, int>> runLength(const vector<S> &v) {
vector<pair<S, int>> res;
for(auto &e : v) {
if(res.empty() or res.back().fi != e)
res.eb(e, 1);
else
res.back().se++;
}
return res;
}
vector<pair<char, int>> runLength(const string &v) {
vector<pair<char, int>> res;
for(auto &e : v) {
if(res.empty() or res.back().fi != e)
res.eb(e, 1);
else
res.back().se++;
}
return res;
}
struct string_converter {
char start = 0;
char type(const char &c) const { return (islower(c) ? 'a' : isupper(c) ? 'A' : isdigit(c) ? '0' : 0); }
int convert(const char &c) {
if(!start) start = type(c);
return c - start;
}
int convert(const char &c, const string &chars) { return chars.find(c); }
template <typename T> auto convert(const T &v) {
vector<decltype(convert(v[0]))> ret;
ret.reserve(size(v));
for(auto &&e : v) ret.emplace_back(convert(e));
return ret;
}
template <typename T> auto convert(const T &v, const string &chars) {
vector<decltype(convert(v[0], chars))> ret;
ret.reserve(size(v));
for(auto &&e : v) ret.emplace_back(convert(e, chars));
return ret;
}
int operator()(const char &v, char s = 0) {
start = s;
return convert(v);
}
int operator()(const char &v, const string &chars) { return convert(v, chars); }
template <typename T> auto operator()(const T &v, char s = 0) {
start = s;
return convert(v);
}
template <typename T> auto operator()(const T &v, const string &chars) { return convert(v, chars); }
} toint;
template <class T, class F> T bin_search(T ok, T ng, const F &f) {
while(abs(ok - ng) > 1) {
T mid = ok + ng >> 1;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
template <class T, class F> T bin_search_double(T ok, T ng, const F &f, int iter = 80) {
while(iter--) {
T mid = (ok + ng) / 2;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
struct Setup_io {
Setup_io() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(11);
}
} setup_io;
#endif
#pragma endregion
#undef LL
namespace StaticGraphImpl {
template <typename T, bool Cond = is_void<T>::value> struct E;
template <typename T> struct E<T, false> {
int to;
T cost;
E() {}
E(const int &v, const T &c) : to(v), cost(c) {}
operator int() const { return to; }
};
template <typename T> struct E<T, true> {
int to;
E() {}
E(const int &v) : to(v) {}
operator int() const { return to; }
};
template <typename T = void> struct StaticGraph {
private:
template <typename It> struct Es {
It b, e;
It begin() const { return b; }
It end() const { return e; }
int size() const { return int(e - b); }
auto &&operator[](int i) const { return b[i]; }
};
int N, M, ec;
vector<int> head;
vector<pair<int, E<T>>> buf;
vector<E<T>> es;
void build() {
partial_sum(begin(head), end(head), begin(head));
es.resize(M);
for(auto &&[u, e] : buf) es[--head[u]] = e;
}
public:
StaticGraph(int _n, int _m) : N(_n), M(_m), ec(0), head(N + 1, 0) { buf.reserve(M); }
template <typename... Args> void add_edge(int u, Args &&...args) {
#pragma GCC diagnostic ignored "-Wnarrowing"
buf.emplace_back(u, E<T>{std::forward<Args>(args)...});
#pragma GCC diagnostic warning "-Wnarrowing"
++head[u];
if((int)buf.size() == M) build();
}
Es<typename vector<E<T>>::iterator> operator[](int u) { return {begin(es) + head[u], begin(es) + head[u + 1]}; }
const Es<typename vector<E<T>>::const_iterator> operator[](int u) const { return {begin(es) + head[u], begin(es) + head[u + 1]}; }
int size() const { return N; }
};
} // namespace StaticGraphImpl
using StaticGraphImpl::StaticGraph;
/**
* @brief Static Graph
* @docs docs/graph/static-graph.md
*/
struct UnionFind {
vector<int> data;
int num;
UnionFind(int n) : num(n) { data.assign(n, -1); }
bool unite(int x, int y) {
x = find(x), y = find(y);
if(x == y) return false;
num--;
if(data[x] > data[y]) swap(x, y);
data[x] += data[y];
data[y] = x;
return true;
}
bool same(int x, int y) { return find(x) == find(y); }
int find(int x) {
if(data[x] < 0) return x;
return (data[x] = find(data[x]));
}
int size(int x) { return -data[find(x)]; }
const int operator[](const int k) { return find(k); }
vector<vector<int>> belong() {
vector<vector<int>> res(data.size());
for(int i = 0; i < data.size(); i++) res[find(i)].emplace_back(i);
return res;
}
void reset() {
num = data.size();
data.assign(num, -1);
}
};
// LowLink ... enumerate bridge and articulation point
// bridge ... 橋 articulation point ... 関節点
template <typename G> struct LowLink {
int N;
const G &g;
vector<int> ord, low, articulation;
vector<pair<int, int>> bridge;
LowLink(const G &_g) : g(_g) {
N = g.size();
ord.resize(N, -1);
low.resize(N, -1);
int k = 0;
for(int i = 0; i < N; i++)
if(ord[i] == -1) k = dfs(i, k, -1);
}
int dfs(int idx, int k, int par) {
low[idx] = (ord[idx] = k++);
int cnt = 0;
bool is_arti = false, flg = false;
for(auto &to : g[idx]) {
if(ord[to] == -1) {
cnt++;
k = dfs(to, k, idx);
low[idx] = min(low[idx], low[to]);
is_arti |= (par != -1) && (low[to] >= ord[idx]);
if(ord[idx] < low[to]) { bridge.emplace_back(minmax(idx, (int)to)); }
} else if(to != par || exchange(flg, true)) {
low[idx] = min(low[idx], ord[to]);
}
}
is_arti |= par == -1 && cnt > 1;
if(is_arti) articulation.push_back(idx);
return k;
}
};
template <typename G> struct BiConnectedComponents : LowLink<G> {
using LL = LowLink<G>;
vector<int> used;
vector<vector<pair<int, int>>> bc;
vector<pair<int, int>> tmp;
BiConnectedComponents(const G &_g) : LL(_g) { build(); }
void build() {
used.assign(this->g.size(), 0);
for(int i = 0; i < (int)used.size(); i++) {
if(!used[i]) dfs(i, -1);
}
}
void dfs(int idx, int par) {
used[idx] = true;
for(auto &to : this->g[idx]) {
if(to == par) continue;
if(!used[to] || this->ord[to] < this->ord[idx]) { tmp.emplace_back(minmax<int>(idx, to)); }
if(!used[to]) {
dfs(to, idx);
if(this->low[to] >= this->ord[idx]) {
bc.emplace_back();
while(true) {
auto e = tmp.back();
bc.back().emplace_back(e);
tmp.pop_back();
if(e.first == min<int>(idx, to) && e.second == max<int>(idx, to)) { break; }
}
}
}
}
}
};
/**
* @brief 二重頂点連結分解
*/
#line 4 "tree/block-cut-tree.hpp"
// aux : block cut tree
// id(V) : new id of node V
// is_arti(V) : return if V is articulation
template <typename G> struct BlockCutTree {
const G &g;
BiConnectedComponents<G> bcc;
vector<vector<int>> aux;
vector<int> idar, idcc;
BlockCutTree(const G &_g) : g(_g), bcc(g) { build(); }
void build() {
auto ar = bcc.articulation;
idar.resize(g.size(), -1);
idcc.resize(g.size(), -1);
for(int i = 0; i < (int)ar.size(); i++) idar[ar[i]] = i;
aux.resize(ar.size() + bcc.bc.size());
// cout << bcc.bc.size() << endl;
// fore(e, bcc.bc) fore(p, e) cout << p.first << " " << p.second << endl;
vector<int> last(g.size(), -1);
for(int i = 0; i < (int)bcc.bc.size(); i++) {
vector<int> st;
for(auto &[u, v] : bcc.bc[i]) st.push_back(u), st.push_back(v);
for(auto &u : st) {
if(idar[u] == -1)
idcc[u] = i + ar.size();
else if(last[u] != i) {
add(i + ar.size(), idar[u]);
last[u] = i;
}
}
}
}
vector<int> &operator[](int i) { return aux[i]; }
int size() const { return aux.size(); }
int id(int i) { return idar[i] == -1 ? idcc[i] : idar[i]; }
bool is_arti(int i) { return idar[i] != -1; }
int arti() const { return bcc.articulation.size(); }
private:
void add(int i, int j) {
if(i == -1 or j == -1) return;
aux[i].push_back(j);
aux[j].push_back(i);
};
};
/**
* @brief Block Cut Tree
*/
bool C3find(const Graph &g) {
vpi edges;
int n = si(g);
vi sz(n);
rep(i, n) { fore(e, g[i]) if(i < e) edges.eb(i, e), sz[i]++, sz[e]++; }
StaticGraph G(n, si(edges));
fore(x, y, edges) {
if(sz[x] > sz[y]) swap(x, y);
G.add_edge(x, y);
}
rep(i, n) sz[i] = 0;
rep(i, n) {
fore(e, G[i]) { sz[e] = 1; }
fore(x, G[i]) {
fore(y, G[x]) {
if(sz[y]) return true;
}
}
fore(e, G[i]) sz[e] = 0;
}
return false;
}
int main() {
INT(m, n);
auto g = getG(n, m);
UnionFind uf(n);
rep(i, n) fore(e, g[i]) uf.unite(i, e);
vector<vpi> v(n);
rep(i, n) fore(e, g[i]) if(i < e) v[uf[i]].eb(i, e);
auto bel = uf.belong();
int a = 0, b = 0;
auto f = [&](Graph &g) {
int n = si(g);
int m = 0;
rep(i, n) fore(e, g[i]) if(i < e) m++;
if(~m & 1) return;
BlockCutTree bct(g);
vi sub(bct.size()), par(bct.size(), -1);
REC([&](auto &&f, int x, int p) -> void { fore(e, bct[x]) if(e != p) f(e, x), par[e] = x; })(0, -1);
int N = bct.bcc.articulation.size();
rep(i, bct.bcc.bc.size()) sub[i + N] = bct.bcc.bc[i].size();
REC([&](auto &&f, int x, int p) -> void { fore(e, bct[x]) if(e != p) f(e, x), sub[x] += sub[e]; })(0, -1);
rep(i, n) dump(bct.id(i));
dump(N);
dump(sub);
vi need(bct.size(), -1);
rep(i, n) {
if(bct.is_arti(i)) {
fore(e, bct[bct.id(i)]) {
// dump(i, bct.id(i), e, par[e], sub[bct.id(i)], sub[e]);
if(par[bct.id(i)] != e) {
if(sub[e] & 1) {
if(need[bct.id(i)] == -1)
need[bct.id(i)] = e;
else
need[bct.id(i)] = -2;
}
} else {
if(~sub[bct.id(i)] & 1) {
if(need[bct.id(i)] == -1)
need[bct.id(i)] = e;
else
need[bct.id(i)] = -2;
}
}
}
}
}
dump(need);
vi num(n);
rep(i, bct.bcc.bc.size()) {
fore(x, y, bct.bcc.bc[i]) {
num[x]++;
num[y]++;
}
vi tmp;
fore(xx, y, bct.bcc.bc[i]) {
for(int x : {xx, y}) {
if(num[x]) {
if(num[x] > 2)
tmp.eb(x), num[x] = 0;
else {
if(!bct.is_arti(x))
tmp.eb(x);
else {
bool flag;
if(par[bct.id(x)] == i + N)
flag = (~sub[bct.id(x)] & 1);
else { flag = (sub[i + N] & 1); }
if(flag) { tmp.eb(x); }
}
num[x] = 0;
}
}
}
}
dump(bct.bcc.bc[i], tmp);
SORT(tmp);
Graph G(si(tmp));
fore(x, y, bct.bcc.bc[i]) {
int xi = lb(tmp, x), yi = lb(tmp, y);
if(xi < si(tmp) and tmp[xi] == x and yi < si(tmp) and tmp[yi] == y) add(G, lb(tmp, x), lb(tmp, y));
}
if(C3find(G)) return;
}
Graph G(n);
rep(i, bct.bcc.bc.size()) {
dump(i, bct.bcc.bc[i]);
fore(x, y, bct.bcc.bc[i]) {
if(bct.is_arti(x)) G[x].eb(i);
if(bct.is_arti(y)) G[y].eb(i);
}
}
dump(G);
rep(i, n) {
if(!bct.is_arti(i)) {
if(si(g[i]) >= 3) {
b++;
return;
}
} else {
int c = 0;
vi v;
fore(e, G[i]) v.eb(e);
SORT(v);
dump(i, v);
fore(x, y, runLength(v)) {
c += y - 1;
dump(x, y, par[x + N], bct.id(i), sub[x + N], sub[bct.id(i)]);
if(par[x + N] == bct.id(i)) {
if(~(sub[x + N] - y) & 1) c++;
} else {
if(~(m - sub[bct.id(i)] - y) & 1) c++;
}
}
if(c >= 3) {
b++;
return;
}
}
}
a++;
};
rep(i, n) {
if(empty(v[i])) continue;
Graph G(si(bel[i]));
SORT(bel[i]);
fore(e, bel[i]) {
fore(j, g[e]) {
if(e < j) add(G, lb(bel[i], e), lb(bel[i], j));
}
}
f(G);
}
OUT(a, b);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3468kb
input:
2 4 1 2 3 4
output:
2 0
result:
ok single line: '2 0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
2 3 1 2 3 1
output:
0 0
result:
ok single line: '0 0'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
5 5 1 2 2 3 2 4 5 2 5 4
output:
0 0
result:
ok single line: '0 0'
Test #4:
score: 0
Accepted
time: 723ms
memory: 89280kb
input:
999990 666660 1 2 1 5 1 7 1 8 1 9 1 10 2 4 2 6 2 9 2 10 3 4 4 8 5 8 6 7 6 10 11 13 11 15 11 20 12 17 12 19 13 16 13 19 14 16 14 19 15 17 15 18 16 17 16 19 17 18 17 20 21 26 21 27 21 29 22 26 22 27 22 29 23 26 23 30 24 26 24 28 25 27 25 30 26 27 26 29 28 29 31 33 31 40 32 35 33 35 33 37 33 38 33 39 3...
output:
383 523
result:
ok single line: '383 523'
Test #5:
score: 0
Accepted
time: 751ms
memory: 89292kb
input:
999990 666660 1 2 1 3 1 5 1 8 2 4 2 7 3 8 3 9 3 10 4 5 4 10 5 9 6 7 6 9 9 10 11 12 11 14 11 19 11 20 12 16 13 17 13 19 14 15 14 16 15 16 15 18 16 18 16 19 17 20 18 20 21 24 21 26 21 28 22 23 23 24 23 27 23 28 24 25 24 27 25 26 25 27 25 30 26 29 27 29 27 30 31 32 31 36 31 37 32 37 33 34 33 35 33 39 3...
output:
349 522
result:
ok single line: '349 522'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
4 4 1 2 2 4 2 3 3 4
output:
0 0
result:
ok single line: '0 0'
Test #7:
score: 0
Accepted
time: 723ms
memory: 93028kb
input:
999991 647053 1 2 1 4 1 7 1 8 1 10 2 4 2 9 3 8 3 9 3 11 4 6 6 10 7 9 7 11 8 9 9 10 10 11 12 13 12 15 12 21 13 16 13 19 13 22 14 17 14 19 14 20 15 19 15 22 16 20 17 18 17 19 18 20 19 22 20 21 23 25 23 27 23 28 23 30 24 25 24 31 24 32 25 30 25 31 26 32 26 33 27 30 28 32 29 31 29 32 29 33 30 31 34 37 3...
output:
375 322
result:
ok single line: '375 322'
Test #8:
score: 0
Accepted
time: 708ms
memory: 93036kb
input:
999991 647053 1 8 2 7 2 9 2 11 3 6 4 5 5 7 5 8 5 9 5 10 5 11 6 8 6 10 8 9 8 10 8 11 10 11 12 13 12 16 12 22 13 14 13 15 13 16 15 18 15 20 15 22 16 19 16 20 16 21 17 18 17 20 19 22 20 22 21 22 23 24 23 26 23 28 23 33 24 25 24 30 25 26 25 29 25 33 26 32 26 33 28 29 28 31 28 33 29 33 31 33 32 33 34 36 ...
output:
366 307
result:
ok single line: '366 307'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
5 5 1 2 2 4 2 3 5 4 3 4
output:
0 1
result:
ok single line: '0 1'
Test #10:
score: 0
Accepted
time: 798ms
memory: 98908kb
input:
999991 705876 1 5 1 9 2 5 2 7 2 8 3 4 5 6 6 7 6 9 6 10 6 11 6 12 7 9 7 11 8 10 9 10 11 12 13 14 13 15 13 16 13 18 13 19 14 17 15 19 15 21 16 21 17 19 18 24 19 20 20 21 21 22 21 23 22 23 23 24 25 28 25 31 25 34 26 31 27 28 27 32 28 29 28 33 28 36 29 32 29 33 29 36 30 35 31 34 31 35 32 34 32 35 37 45 ...
output:
1032 1376
result:
ok single line: '1032 1376'
Test #11:
score: 0
Accepted
time: 785ms
memory: 98848kb
input:
999991 705876 1 7 2 10 2 11 2 12 3 7 3 9 4 5 4 8 4 9 5 7 5 9 6 7 6 9 6 11 7 11 9 10 11 12 13 16 13 17 13 24 14 16 14 24 15 17 15 20 15 24 16 17 16 19 17 20 17 22 17 24 18 20 19 23 20 22 20 23 25 26 25 28 25 35 26 31 27 33 27 35 28 32 29 33 29 35 29 36 30 33 30 34 32 33 32 35 33 35 33 36 34 35 37 38 ...
output:
990 1439
result:
ok single line: '990 1439'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3592kb
input:
6 6 1 4 3 2 4 3 4 6 4 5 4 2
output:
0 0
result:
ok single line: '0 0'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
7 7 1 6 6 7 6 2 2 5 2 3 2 4 3 4
output:
0 0
result:
ok single line: '0 0'
Test #14:
score: 0
Accepted
time: 2ms
memory: 3452kb
input:
8 8 1 2 2 7 2 8 7 8 5 2 2 3 2 4 5 6
output:
0 0
result:
ok single line: '0 0'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
12 8 1 2 1 3 2 3 3 4 3 5 4 5 6 5 6 7 5 7 2 7 7 8 2 8
output:
0 0
result:
ok single line: '0 0'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
5 4 1 2 1 3 2 3 2 4 3 4
output:
0 0
result:
ok single line: '0 0'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
6 7 1 2 2 7 2 3 3 4 4 5 5 6
output:
0 0
result:
ok single line: '0 0'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
7 8 1 4 4 5 6 7 6 8 2 4 2 3 6 3
output:
0 1
result:
ok single line: '0 1'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
7 8 1 2 1 3 1 4 5 6 5 7 5 8 1 5
output:
0 1
result:
ok single line: '0 1'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
4 4 1 3 1 4 2 4 2 3
output:
0 0
result:
ok single line: '0 0'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
5 5 1 2 1 5 2 4 4 3 3 5
output:
1 0
result:
ok single line: '1 0'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
9 12 1 2 1 3 4 5 5 6 7 9 8 9 10 11 10 12 11 12
output:
0 0
result:
ok single line: '0 0'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
186 228 1 2 1 3 5 6 5 8 9 11 9 12 13 14 13 15 13 16 17 18 18 19 21 23 22 23 25 26 25 27 26 27 29 32 30 31 33 34 33 36 34 35 37 39 37 40 38 39 41 42 41 43 41 44 42 43 45 46 46 48 49 51 50 52 53 54 53 55 54 56 57 60 58 60 61 62 61 64 62 64 65 67 65 68 66 68 69 70 69 71 69 72 70 72 74 75 74 76 77 78 78...
output:
18 4
result:
ok single line: '18 4'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
3 4 1 2 3 4 3 2
output:
1 0
result:
ok single line: '1 0'
Test #25:
score: 0
Accepted
time: 2ms
memory: 4184kb
input:
5110 5065 1 2 1 3 6 7 6 9 11 13 11 14 16 17 16 18 16 19 21 22 21 25 26 28 26 30 31 32 31 33 31 35 36 39 36 40 41 42 41 44 41 45 46 48 46 49 46 50 51 52 51 53 51 54 51 55 56 57 57 58 61 63 62 63 66 67 66 68 67 68 71 74 72 73 76 77 76 79 77 78 81 83 81 84 82 83 86 87 86 88 86 89 87 88 91 95 92 93 96 9...
output:
142 140
result:
ok single line: '142 140'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3572kb
input:
3 4 1 2 2 3 2 4
output:
0 1
result:
ok single line: '0 1'
Test #27:
score: 0
Accepted
time: 145ms
memory: 28644kb
input:
245745 196512 1 2 1 3 7 8 7 10 13 15 13 16 19 20 19 21 19 22 25 26 25 29 31 33 31 35 37 38 37 39 37 41 43 46 43 47 49 50 49 52 49 53 55 57 55 58 55 59 61 62 61 63 61 64 61 65 67 68 67 72 73 75 73 78 79 80 79 81 79 84 85 88 85 90 91 92 91 94 91 96 97 99 97 100 97 102 103 104 103 105 103 106 103 108 1...
output:
2097 2626
result:
ok single line: '2097 2626'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
5 6 1 6 2 6 3 6 4 6 5 6
output:
0 1
result:
ok single line: '0 1'
Test #29:
score: 0
Accepted
time: 591ms
memory: 111180kb
input:
999999 841330 1 2 1 3 8 9 8 11 15 17 15 18 22 23 22 24 22 25 29 30 29 33 36 38 36 40 43 44 43 45 43 47 50 53 50 54 57 58 57 60 57 61 64 66 64 67 64 68 71 72 71 73 71 74 71 75 78 79 78 83 85 87 85 90 92 93 92 94 92 97 99 102 99 104 106 107 106 109 106 111 113 115 113 116 113 118 120 121 120 122 120 1...
output:
7646 12754
result:
ok single line: '7646 12754'
Test #30:
score: 0
Accepted
time: 547ms
memory: 101404kb
input:
999992 755307 1 6 2 4 2 5 2 7 3 5 3 7 4 5 4 6 8 9 8 13 9 11 9 12 9 14 10 12 10 14 11 12 11 13 15 17 15 20 16 18 16 19 16 21 17 19 17 21 18 19 18 20 22 23 22 24 22 27 23 25 23 26 23 28 24 26 24 28 25 26 25 27 29 32 29 34 30 32 30 33 30 35 31 33 31 35 32 33 32 34 36 37 36 39 36 41 37 39 37 40 37 42 38...
output:
3532 7627
result:
ok single line: '3532 7627'
Test #31:
score: 0
Accepted
time: 534ms
memory: 99840kb
input:
999994 740684 1 3 1 4 1 5 2 5 2 6 3 4 3 5 3 6 3 7 4 6 4 7 8 9 8 10 8 11 8 12 9 12 9 13 10 11 10 12 10 13 10 14 11 13 11 14 15 20 16 19 16 20 17 18 17 19 17 20 17 21 18 20 18 21 22 23 22 27 23 26 23 27 24 25 24 26 24 27 24 28 25 27 25 28 29 31 29 34 30 33 30 34 31 32 31 33 31 34 31 35 32 34 32 35 36 ...
output:
3201 7345
result:
ok single line: '3201 7345'
Test #32:
score: 0
Accepted
time: 529ms
memory: 96048kb
input:
999992 706979 1 2 1 3 1 7 2 3 3 4 3 5 4 6 5 6 8 11 8 14 9 10 10 11 10 12 11 13 12 13 15 16 15 18 15 21 16 17 17 18 17 19 18 20 19 20 22 24 22 25 22 28 23 24 24 25 24 26 25 27 26 27 29 30 29 31 29 32 29 35 30 31 31 32 31 33 32 34 33 34 36 40 36 42 37 38 38 39 38 40 39 41 40 41 43 44 43 47 43 49 44 45...
output:
2402 4121
result:
ok single line: '2402 4121'
Test #33:
score: 0
Accepted
time: 501ms
memory: 88968kb
input:
999994 646072 1 5 1 7 2 3 2 4 2 6 3 6 4 5 4 7 5 6 8 9 8 12 8 14 9 10 9 11 9 13 10 13 11 12 11 14 12 13 15 17 15 19 15 21 16 17 16 18 16 20 17 20 18 19 18 21 19 20 22 23 22 24 22 26 22 28 23 24 23 25 23 27 24 27 25 26 25 28 26 27 29 32 29 33 29 35 30 31 30 32 30 34 31 34 32 33 32 35 33 34 36 37 36 39...
output:
943 2394
result:
ok single line: '943 2394'
Test #34:
score: 0
Accepted
time: 607ms
memory: 101172kb
input:
999995 753298 1 2 1 6 1 7 2 3 2 5 2 6 3 4 5 7 8 10 8 13 8 14 9 10 9 12 9 13 10 11 12 14 15 16 15 17 15 20 15 21 16 17 16 19 16 20 17 18 19 21 22 25 22 27 22 28 23 24 23 26 23 27 24 25 26 28 29 30 29 32 29 34 29 35 30 31 30 33 30 34 31 32 33 35 36 38 36 39 36 41 36 42 37 38 37 40 37 41 38 39 40 42 43...
output:
3698 7209
result:
ok single line: '3698 7209'
Test #35:
score: 0
Accepted
time: 510ms
memory: 93748kb
input:
999989 688429 1 2 1 3 1 4 1 5 2 3 2 4 2 5 2 6 2 7 3 4 3 6 4 5 4 6 5 7 8 13 9 10 9 11 9 12 9 13 9 14 10 11 10 13 11 12 11 13 12 14 15 16 15 20 16 17 16 18 16 19 16 20 16 21 17 18 17 20 18 19 18 20 19 21 22 24 22 27 23 24 23 25 23 26 23 27 23 28 24 25 24 27 25 26 25 27 26 28 29 30 29 31 29 34 30 31 30...
output:
1310 3756
result:
ok single line: '1310 3756'
Test #36:
score: 0
Accepted
time: 516ms
memory: 91264kb
input:
999993 666330 1 3 1 5 1 6 1 7 2 3 2 4 2 5 2 6 2 7 3 4 3 6 4 6 4 7 5 7 8 9 8 10 8 12 8 13 8 14 9 10 9 11 9 12 9 13 9 14 10 11 10 13 11 13 11 14 12 14 15 18 15 19 15 20 15 21 16 17 16 18 16 19 16 20 16 21 17 18 17 20 18 20 18 21 19 21 22 23 22 25 22 26 22 27 22 28 23 24 23 25 23 26 23 27 23 28 24 25 2...
output:
835 3556
result:
ok single line: '835 3556'
Test #37:
score: 0
Accepted
time: 524ms
memory: 88424kb
input:
999993 641725 1 6 2 3 2 4 2 5 2 6 3 6 4 5 5 6 5 7 8 9 8 13 9 10 9 11 9 12 9 13 10 13 11 12 12 13 12 14 15 17 15 20 16 17 16 18 16 19 16 20 17 20 18 19 19 20 19 21 22 23 22 24 22 27 23 24 23 25 23 26 23 27 24 27 25 26 26 27 26 28 29 32 29 34 30 31 30 32 30 33 30 34 31 34 32 33 33 34 33 35 36 37 36 39...
output:
331 2414
result:
ok single line: '331 2414'
Test #38:
score: 0
Accepted
time: 452ms
memory: 87004kb
input:
999994 629048 1 2 1 3 1 5 1 7 2 3 2 4 2 5 3 4 4 7 5 6 5 7 8 11 8 12 8 14 9 10 9 11 9 12 10 11 11 14 12 13 12 14 15 16 15 18 15 19 15 21 16 17 16 18 16 19 17 18 18 21 19 20 19 21 22 24 22 25 22 26 22 28 23 24 23 25 23 26 24 25 25 28 26 27 26 28 29 30 29 31 29 32 29 33 29 35 30 31 30 32 30 33 31 32 32...
output:
164 2050
result:
ok single line: '164 2050'
Test #39:
score: 0
Accepted
time: 517ms
memory: 93080kb
input:
999999 680225 1 2 1 3 1 6 1 7 2 3 2 4 3 4 3 6 3 7 4 6 4 7 5 6 5 7 8 11 8 13 8 14 9 10 9 11 10 11 10 13 10 14 11 13 11 14 12 13 12 14 15 16 15 18 15 20 15 21 16 17 16 18 17 18 17 20 17 21 18 20 18 21 19 20 19 21 22 24 22 25 22 27 22 28 23 24 23 25 24 25 24 27 24 28 25 27 25 28 26 27 26 28 29 30 29 31...
output:
3578 4667
result:
ok single line: '3578 4667'
Test #40:
score: 0
Accepted
time: 539ms
memory: 96464kb
input:
999994 710822 1 2 1 3 1 5 2 4 2 7 3 6 3 7 4 5 6 7 8 11 8 12 9 11 9 14 10 13 10 14 11 12 13 14 15 16 15 18 15 19 16 18 16 21 17 20 17 21 18 19 20 21 22 24 22 25 22 26 23 25 23 28 24 27 24 28 25 26 27 28 29 30 29 31 29 32 29 33 30 32 30 35 31 34 31 35 32 33 34 35 36 41 37 39 37 42 38 41 38 42 39 40 41...
output:
1590 5625
result:
ok single line: '1590 5625'
Test #41:
score: 0
Accepted
time: 502ms
memory: 90256kb
input:
999999 654864 1 2 1 4 1 6 1 7 2 5 3 5 3 6 3 7 4 7 6 7 8 10 8 11 8 13 8 14 9 12 10 12 10 13 10 14 11 14 13 14 15 16 15 17 15 18 15 20 15 21 16 19 17 19 17 20 17 21 18 21 20 21 22 26 22 27 22 28 23 26 24 26 24 27 24 28 25 28 27 28 29 30 29 33 29 34 29 35 30 33 31 33 31 34 31 35 32 35 34 35 36 38 36 40...
output:
653 1686
result:
ok single line: '653 1686'
Test #42:
score: 0
Accepted
time: 505ms
memory: 93300kb
input:
999994 683298 1 2 1 4 1 7 2 4 2 6 2 7 3 4 3 5 3 7 4 5 4 6 4 7 6 7 8 10 8 11 8 14 9 11 9 13 9 14 10 11 10 12 10 14 11 12 11 13 11 14 13 14 15 16 15 17 15 18 15 21 16 18 16 20 16 21 17 18 17 19 17 21 18 19 18 20 18 21 20 21 22 26 22 28 23 25 23 27 23 28 24 25 24 26 24 28 25 26 25 27 25 28 27 28 29 30 ...
output:
944 4865
result:
ok single line: '944 4865'
Test #43:
score: 0
Accepted
time: 487ms
memory: 87732kb
input:
999994 634011 1 2 1 3 1 6 1 7 2 3 2 4 2 5 2 6 3 4 3 5 3 7 4 6 5 6 6 7 8 11 8 13 8 14 9 10 9 11 9 12 9 13 10 11 10 12 10 14 11 13 12 13 13 14 15 16 15 18 15 20 15 21 16 17 16 18 16 19 16 20 17 18 17 19 17 21 18 20 19 20 20 21 22 24 22 25 22 27 22 28 23 24 23 25 23 26 23 27 24 25 24 26 24 28 25 27 26 ...
output:
256 2136
result:
ok single line: '256 2136'
Test #44:
score: 0
Accepted
time: 476ms
memory: 82060kb
input:
999999 586642 2 3 2 4 2 5 2 7 3 4 3 5 3 6 4 5 4 7 5 6 6 7 8 9 9 10 9 11 9 12 9 14 10 11 10 12 10 13 11 12 11 14 12 13 13 14 15 17 16 17 16 18 16 19 16 21 17 18 17 19 17 20 18 19 18 21 19 20 20 21 22 23 22 24 23 24 23 25 23 26 23 28 24 25 24 26 24 27 25 26 25 28 26 27 27 28 29 32 30 31 30 32 30 33 30...
output:
223 715
result:
ok single line: '223 715'
Test #45:
score: 0
Accepted
time: 521ms
memory: 93524kb
input:
999990 686567 1 3 1 4 1 5 1 6 2 5 2 7 5 7 6 7 8 9 8 10 8 11 8 12 8 13 9 12 9 14 12 14 13 14 15 21 16 19 16 21 19 21 20 21 22 23 22 28 23 26 23 28 26 28 27 28 29 31 29 35 30 33 30 35 33 35 34 35 36 37 36 38 36 42 37 40 37 42 40 42 41 42 43 46 43 49 44 47 44 49 47 49 48 49 50 51 50 53 50 56 51 54 51 5...
output:
931 4522
result:
ok single line: '931 4522'
Test #46:
score: 0
Accepted
time: 488ms
memory: 87484kb
input:
999990 632338 1 2 1 3 1 4 1 5 1 6 1 7 2 7 4 5 4 6 5 7 6 7 9 10 9 14 11 12 11 13 12 14 13 14 15 16 16 17 16 21 18 19 18 20 19 21 20 21 22 24 23 24 23 28 25 26 25 27 26 28 27 28 29 30 29 31 30 31 30 35 32 33 32 34 33 35 34 35 36 39 37 38 37 42 39 40 39 41 40 42 41 42 43 44 43 46 44 45 44 49 46 47 46 4...
output:
151 2420
result:
ok single line: '151 2420'
Test #47:
score: 0
Accepted
time: 491ms
memory: 83672kb
input:
999993 597905 1 2 1 4 1 5 1 6 2 5 2 7 3 6 3 7 4 5 4 7 5 7 6 7 8 10 8 11 8 12 8 13 9 12 9 14 10 13 10 14 11 12 11 14 12 14 13 14 15 16 15 17 15 18 15 19 15 20 16 19 16 21 17 20 17 21 18 19 18 21 19 21 20 21 22 28 23 26 23 28 24 27 24 28 25 26 25 28 26 28 27 28 29 30 29 35 30 33 30 35 31 34 31 35 32 3...
output:
396 361
result:
ok single line: '396 361'
Test #48:
score: 0
Accepted
time: 486ms
memory: 85692kb
input:
999996 615720 1 4 2 3 2 4 2 6 3 5 3 6 5 6 5 7 6 7 8 9 8 11 9 10 9 11 9 13 10 12 10 13 12 13 12 14 13 14 15 17 15 18 16 17 16 18 16 20 17 19 17 20 19 20 19 21 20 21 22 23 22 24 22 25 23 24 23 25 23 27 24 26 24 27 26 27 26 28 27 28 29 33 30 31 30 32 30 34 31 33 31 34 33 34 33 35 34 35 36 37 36 40 37 3...
output:
277 414
result:
ok single line: '277 414'
Test #49:
score: 0
Accepted
time: 453ms
memory: 81692kb
input:
999990 581357 1 4 1 5 1 6 2 3 2 6 3 4 4 5 4 6 5 6 5 7 6 7 8 9 8 11 8 12 8 13 9 10 9 13 10 11 11 12 11 13 12 13 12 14 13 14 15 17 15 18 15 19 15 20 16 17 16 20 17 18 18 19 18 20 19 20 19 21 20 21 22 23 22 24 22 25 22 26 22 27 23 24 23 27 24 25 25 26 25 27 26 27 26 28 27 28 29 35 30 31 30 34 31 32 32 ...
output:
104 179
result:
ok single line: '104 179'
Test #50:
score: 0
Accepted
time: 442ms
memory: 76856kb
input:
999987 538132 1 2 1 3 1 4 2 3 2 4 2 6 2 7 3 4 3 7 4 5 4 7 5 6 5 7 6 7 8 12 9 10 9 11 9 13 9 14 10 11 10 14 11 12 11 14 12 13 12 14 13 14 15 16 15 19 16 17 16 18 16 20 16 21 17 18 17 21 18 19 18 21 19 20 19 21 20 21 22 24 22 26 23 24 23 25 23 27 23 28 24 25 24 28 25 26 25 28 26 27 26 28 27 28 29 30 2...
output:
102 6
result:
ok single line: '102 6'
Test #51:
score: 0
Accepted
time: 6ms
memory: 4416kb
input:
20215 8827 1 2 1 3 1 6 2 5 2 6 3 4 3 5 3 6 3 7 4 5 4 6 4 7 5 6 5 7 6 7 8 11 8 13 9 12 9 13 10 11 10 12 10 13 10 14 11 12 11 13 11 14 12 13 12 14 13 14 15 16 15 18 15 20 16 19 16 20 17 18 17 19 17 20 17 21 18 19 18 20 18 21 19 20 19 21 20 21 22 24 22 25 22 27 23 26 23 27 24 25 24 26 24 27 24 28 25 26...
output:
0 0
result:
ok single line: '0 0'
Test #52:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
4 5 1 2 2 3 3 4 4 5
output:
0 0
result:
ok single line: '0 0'
Test #53:
score: 0
Accepted
time: 499ms
memory: 84020kb
input:
999996 614440 1 2 1 3 1 4 1 5 1 7 1 8 2 3 2 4 2 6 2 7 3 6 3 7 4 5 4 6 4 8 5 7 9 14 9 15 9 16 10 11 10 12 10 14 10 15 11 14 11 15 12 13 12 14 12 16 13 15 17 18 17 22 17 23 17 24 18 19 18 20 18 22 18 23 19 22 19 23 20 21 20 22 20 24 21 23 25 27 25 30 25 31 25 32 26 27 26 28 26 30 26 31 27 30 27 31 28 ...
output:
38 1247
result:
ok single line: '38 1247'
Test #54:
score: 0
Accepted
time: 428ms
memory: 74444kb
input:
1000000 513824 1 4 2 5 2 8 3 6 4 5 4 6 4 7 4 8 5 6 6 7 6 8 9 10 9 12 10 13 10 16 11 14 12 13 12 14 12 15 12 16 13 14 14 15 14 16 17 19 17 20 18 21 18 24 19 22 20 21 20 22 20 23 20 24 21 22 22 23 22 24 25 26 25 27 25 28 26 29 26 32 27 30 28 29 28 30 28 31 28 32 29 30 30 31 30 32 33 37 34 37 34 40 35 ...
output:
8 0
result:
ok single line: '8 0'
Test #55:
score: 0
Accepted
time: 442ms
memory: 72664kb
input:
999993 491984 1 3 1 7 2 4 2 5 2 6 3 5 3 8 4 6 4 7 5 6 5 7 5 8 6 7 6 8 9 10 9 11 9 15 10 12 10 13 10 14 11 13 11 16 12 14 12 15 13 14 13 15 13 16 14 15 14 16 17 20 17 23 18 20 18 21 18 22 19 21 19 24 20 22 20 23 21 22 21 23 21 24 22 23 22 24 25 26 25 28 25 31 26 28 26 29 26 30 27 29 27 32 28 30 28 31...
output:
7 0
result:
ok single line: '7 0'
Test #56:
score: 0
Accepted
time: 482ms
memory: 82664kb
input:
999993 602296 1 3 1 4 2 3 2 4 2 6 2 7 2 8 3 4 4 7 4 8 5 8 6 7 7 8 9 10 9 11 9 12 10 11 10 12 10 14 10 15 10 16 11 12 12 15 12 16 13 16 14 15 15 16 17 21 18 19 18 20 18 22 18 23 18 24 19 20 20 23 20 24 21 24 22 23 23 24 25 26 25 29 26 27 26 28 26 30 26 31 26 32 27 28 28 31 28 32 29 32 30 31 31 32 33 ...
output:
10 374
result:
ok single line: '10 374'
Test #57:
score: 0
Accepted
time: 501ms
memory: 84724kb
input:
999997 620840 1 2 1 3 1 4 1 5 1 7 2 3 2 4 2 5 2 6 2 7 2 8 3 4 3 6 4 6 4 8 5 6 5 8 9 14 9 15 10 11 10 12 10 13 10 14 10 15 10 16 11 12 11 14 12 14 12 16 13 14 13 16 17 18 17 22 17 23 18 19 18 20 18 21 18 22 18 23 18 24 19 20 19 22 20 22 20 24 21 22 21 24 25 27 25 30 25 31 26 27 26 28 26 29 26 30 26 3...
output:
656 1809
result:
ok single line: '656 1809'
Test #58:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
5 6 1 2 3 4 5 6 2 3 4 5
output:
1 0
result:
ok single line: '1 0'
Test #59:
score: 0
Accepted
time: 373ms
memory: 87704kb
input:
999992 642852 1 4 1 7 1 8 1 9 2 4 2 5 3 6 4 6 5 6 5 8 5 9 6 8 7 9 8 9 10 12 10 15 10 17 10 18 11 12 11 18 12 17 13 15 13 16 13 17 14 15 14 16 14 18 15 18 19 21 19 23 19 25 19 27 20 22 20 24 20 25 20 27 21 23 21 24 22 25 23 24 23 25 23 26 28 31 28 33 29 32 29 34 29 35 29 36 30 33 31 32 31 33 31 35 32...
output:
123 0
result:
ok single line: '123 0'
Test #60:
score: 0
Accepted
time: 706ms
memory: 82328kb
input:
999990 599994 1 3 1 4 1 6 1 7 1 8 1 9 3 4 3 6 4 7 5 7 5 8 5 9 7 8 7 9 8 9 10 11 10 13 10 18 11 12 11 15 11 18 12 17 13 14 13 15 13 18 14 15 14 18 15 16 15 18 16 17 19 20 19 23 19 25 19 26 20 21 20 23 21 27 22 23 22 24 22 25 22 26 22 27 23 25 23 26 24 26 28 29 28 32 28 33 28 36 29 34 29 35 29 36 30 3...
output:
57 40
result:
ok single line: '57 40'
Test #61:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
8 9 9 8 6 7 3 2 5 4 1 2 4 3 6 5 7 8
output:
0 0
result:
ok single line: '0 0'
Test #62:
score: 0
Accepted
time: 1259ms
memory: 166228kb
input:
999999 1000000 1 560136 2 102142 2 236736 3 309371 3 491463 4 538764 5 470246 6 278170 7 227277 8 673767 9 37182 9 231457 11 414293 11 583390 11 812999 11 868721 11 925233 12 254802 12 517049 12 530488 12 910757 12 943612 13 901211 14 1496 14 802703 15 684146 18 159626 18 209532 18 394262 18 583396 ...
output:
20012 719
result:
ok single line: '20012 719'
Test #63:
score: 0
Accepted
time: 317ms
memory: 81028kb
input:
998991 1414 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 1 60 1...
output:
0 0
result:
ok single line: '0 0'
Test #64:
score: 0
Accepted
time: 794ms
memory: 409800kb
input:
999999 999999 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 ...
output:
1 0
result:
ok single line: '1 0'
Test #65:
score: 0
Accepted
time: 836ms
memory: 348884kb
input:
999997 749999 1 2 2 3 3 1 2 4 4 5 5 6 6 4 5 7 7 8 8 9 9 7 8 10 10 11 11 12 12 10 11 13 13 14 14 15 15 13 14 16 16 17 17 18 18 16 17 19 19 20 20 21 21 19 20 22 22 23 23 24 24 22 23 25 25 26 26 27 27 25 26 28 28 29 29 30 30 28 29 31 31 32 32 33 33 31 32 34 34 35 35 36 36 34 35 37 37 38 38 39 39 37 38 ...
output:
0 1
result:
ok single line: '0 1'
Test #66:
score: 0
Accepted
time: 695ms
memory: 317720kb
input:
999999 750001 1 2 2 3 3 1 2 4 4 5 5 6 6 4 5 7 7 8 8 9 9 7 8 10 10 11 11 12 12 10 11 13 13 14 14 15 15 13 14 16 16 17 17 18 18 16 17 19 19 20 20 21 21 19 20 22 22 23 23 24 24 22 23 25 25 26 26 27 27 25 26 28 28 29 29 30 30 28 29 31 31 32 32 33 33 31 32 34 34 35 35 36 36 34 35 37 37 38 38 39 39 37 38 ...
output:
0 0
result:
ok single line: '0 0'
Test #67:
score: 0
Accepted
time: 1140ms
memory: 515960kb
input:
999997 999998 1 2 1 3 1 4 3 6 5 6 5 7 5 8 7 10 9 10 9 11 9 12 11 14 13 14 13 15 13 16 15 18 17 18 17 19 17 20 19 22 21 22 21 23 21 24 23 26 25 26 25 27 25 28 27 30 29 30 29 31 29 32 31 34 33 34 33 35 33 36 35 38 37 38 37 39 37 40 39 42 41 42 41 43 41 44 43 46 45 46 45 47 45 48 47 50 49 50 49 51 49 5...
output:
1 0
result:
ok single line: '1 0'
Test #68:
score: 0
Accepted
time: 746ms
memory: 120500kb
input:
999915 952300 1 41 1 47 1 72 2 16 2 88 2 95 3 9 3 26 3 91 4 21 4 37 4 85 5 14 5 49 5 88 6 25 7 71 7 74 7 84 8 22 9 34 9 83 10 16 10 90 11 18 12 35 12 52 14 17 14 44 14 72 15 26 15 80 15 83 16 42 17 65 18 29 18 85 19 41 19 74 21 38 22 25 22 37 22 53 23 38 24 39 24 63 24 98 25 64 25 91 26 44 26 55 26 ...
output:
15511 1803
result:
ok single line: '15511 1803'
Test #69:
score: 0
Accepted
time: 741ms
memory: 123036kb
input:
999975 995000 1 359 1 729 1 966 2 263 2 487 4 372 4 391 4 877 5 883 6 248 6 254 6 703 7 141 7 333 8 496 8 602 8 934 9 747 10 283 11 386 11 815 12 954 13 963 14 437 14 891 15 274 15 826 16 56 16 278 16 893 18 247 18 789 18 826 19 409 19 695 20 158 20 624 20 838 20 993 21 289 21 734 22 936 22 938 23 2...
output:
19402 813
result:
ok single line: '19402 813'
Test #70:
score: 0
Accepted
time: 774ms
memory: 123020kb
input:
990495 990000 1 4654 2 553 2 4245 3 2524 3 3264 3 4715 3 5674 3 8204 4 5011 5 2857 5 9071 6 1514 6 5066 6 6536 6 7994 7 827 7 6412 8 7290 9 871 9 1936 9 2124 9 6867 11 8860 12 1347 12 3879 12 8952 13 1635 13 3529 14 3313 14 7551 14 8286 15 307 15 614 15 6202 15 7888 15 7935 16 2070 17 689 18 2352 18...
output:
19786 687
result:
ok single line: '19786 687'
Test #71:
score: 0
Accepted
time: 763ms
memory: 115256kb
input:
999955 909050 1 4 1 13 1 28 1 33 1 36 2 25 3 42 4 16 5 25 7 22 7 24 7 30 7 33 7 40 7 50 8 19 8 27 9 17 9 24 10 19 10 20 10 24 10 37 12 34 13 32 13 36 14 36 15 24 16 20 16 31 17 22 18 24 19 32 19 37 19 43 20 27 20 44 21 27 21 33 24 31 24 36 24 41 25 26 26 44 27 28 27 39 27 40 28 36 28 49 30 37 30 39 ...
output:
11763 2903
result:
ok single line: '11763 2903'
Test #72:
score: 0
Accepted
time: 789ms
memory: 122288kb
input:
999900 990000 1 33 1 290 1 323 1 327 1 341 2 12 2 17 2 46 2 198 3 204 3 256 4 27 4 313 6 236 7 217 9 153 9 431 10 21 10 415 10 419 11 58 12 55 12 128 14 390 15 34 16 240 16 321 17 262 18 231 18 238 19 78 19 130 19 266 19 271 20 203 20 474 20 494 21 25 21 429 22 348 22 484 23 388 23 463 24 209 24 243...
output:
19065 967
result:
ok single line: '19065 967'
Test #73:
score: 0
Accepted
time: 752ms
memory: 123408kb
input:
995995 995000 1 516 1 2254 1 3620 2 3500 3 184 3 917 3 1224 3 3467 3 4653 4 537 5 3604 6 687 6 1559 6 4129 7 462 7 1012 7 2094 7 2665 7 4363 7 4473 8 300 8 307 8 1678 8 2921 8 4070 9 3102 9 4561 11 1749 11 3944 11 4927 12 1479 12 3635 13 492 14 1693 14 2362 14 4867 15 2073 15 2166 15 2186 16 1523 16...
output:
19765 706
result:
ok single line: '19765 706'
Test #74:
score: 0
Accepted
time: 433ms
memory: 112404kb
input:
999905 196061 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6...
output:
0 1
result:
ok single line: '0 1'
Test #75:
score: 0
Accepted
time: 340ms
memory: 107500kb
input:
999905 196061 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6...
output:
0 0
result:
ok single line: '0 0'
Test #76:
score: 0
Accepted
time: 669ms
memory: 259732kb
input:
999995 833331 1 2 2 3 3 4 4 5 5 1 1 833331 6 7 7 8 8 9 9 10 10 6 6 833331 11 12 12 13 13 14 14 15 15 11 11 833331 16 17 17 18 18 19 19 20 20 16 16 833331 21 22 22 23 23 24 24 25 25 21 21 833331 26 27 27 28 28 29 29 30 30 26 26 833331 31 32 32 33 33 34 34 35 35 31 31 833331 36 37 37 38 38 39 39 40 40...
output:
1 0
result:
ok single line: '1 0'