QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#195714#7514. Clique Challengeucup-team180#AC ✓480ms31856kbC++1741.1kb2023-10-01 06:29:532023-10-01 06:29:54

Judging History

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

  • [2023-10-01 06:29:54]
  • 评测
  • 测评结果:AC
  • 用时:480ms
  • 内存:31856kb
  • [2023-10-01 06:29:53]
  • 提交

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 <utility>
#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 permrepflag = true; (permrepflag ? exchange(permrepflag, 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 INTd(...)                                                                                                                                              \
    int __VA_ARGS__;                                                                                                                                           \
    IN2(__VA_ARGS__)
#define LL(...)                                                                                                                                                \
    ll __VA_ARGS__;                                                                                                                                            \
    IN(__VA_ARGS__)
#define LLd(...)                                                                                                                                               \
    ll __VA_ARGS__;                                                                                                                                            \
    IN2(__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 VECd(type, name, size)                                                                                                                                 \
    vector<type> name(size);                                                                                                                                   \
    IN2(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 VEC2d(type, name1, name2, size)                                                                                                                        \
    vector<type> name1(size), name2(size);                                                                                                                     \
    for(int i = 0; i < size; i++) IN2(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 VEC3d(type, name1, name2, name3, size)                                                                                                                 \
    vector<type> name1(size), name2(size), name3(size);                                                                                                        \
    for(int i = 0; i < size; i++) IN2(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 VEC4d(type, name1, name2, name3, name4, size)                                                                                                          \
    vector<type> name1(size), name2(size), name3(size), name4(size);                                                                                           \
    for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w)                                                                                                                                   \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN(name)
#define VVd(type, name, h, w)                                                                                                                                  \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN2(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() {}
void IN2() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}
template <class Head, class... Tail> void IN2(Head &head, Tail &...tail) {
    scan(head);
    --head;
    IN2(tail...);
}

template <int p = -1> void pat() {}
template <int p = -1, class Head, class... Tail> void pat(Head &h, Tail &...tail) {
    h += p;
    pat<p>(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);
}

vector<int> counter(const vector<int> &v, int max_num = -1) {
    if(max_num == -1) max_num = MAX(v);
    vector<int> res(max_num + 1);
    fore(e, v) res[e]++;
    return 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; }
template <class T, class S> bool inc(const T &x, const pair<S, S> &p) { return p.first <= x and x < p.second; }

// 便利関数
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> void connect(vector<T> &l, const vector<T> &r) { fore(e, r) l.eb(e); }
template <class T> vector<T> operator+(const vector<T> &l, const vector<T> &r) {
    vector<T> res(max(si(l), si(r)));
    rep(i, si(l)) res[i] += l[i];
    rep(i, si(r)) res[i] += r[i];
    return res;
}
template <class T> vector<T> operator-(const vector<T> &l, const vector<T> &r) {
    vector<T> res(max(si(l), si(r)));
    rep(i, si(l)) res[i] += l[i];
    rep(i, si(r)) res[i] -= r[i];
    return res;
}
template <class T> vector<T> &operator+=(const vector<T> &l, const vector<T> &r) {
    if(si(l) < si(r)) l.resize(si(r));
    rep(i, si(r)) l[i] += r[i];
    return l;
}
template <class T> vector<T> &operator-=(const vector<T> &l, const vector<T> &r) {
    if(si(l) < si(r)) l.resize(si(r));
    rep(i, si(r)) l[i] -= r[i];
    return l;
}
template <class T> vector<T> &operator+=(vector<T> &v, const T &x) {
    fore(e, v) e += x;
    return v;
}
template <class T> vector<T> &operator-=(vector<T> &v, const T &x) {
    fore(e, v) e -= x;
    return v;
}

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

namespace modular {
constexpr int MOD = 1000000007;
const int MAXN = 11000000;
template <int Modulus> class modint;
#define mint modint<MOD>
#define vmint vector<mint>
vector<mint> Inv;
mint inv(int x);
template <int Modulus> class modint {

  public:
    static constexpr int mod() { return Modulus; }
    int a = 0;

    constexpr modint(const ll x = 0) noexcept : a(((x % Modulus) + Modulus) % Modulus) {}
    constexpr int &value() noexcept { return a; }
    constexpr const int &value() const noexcept { return a; }
    constexpr modint operator-() const noexcept { return modint() - *this; }
    constexpr modint operator+() const noexcept { return *this; }
    constexpr modint &operator++() noexcept {
        if(++a == MOD) a = 0;
        return *this;
    }
    constexpr modint &operator--() noexcept {
        if(!a) a = MOD;
        a--;
        return *this;
    }
    constexpr modint operator++(int) {
        modint res = *this;
        ++*this;
        return res;
    }
    constexpr modint operator--(int) {
        mint res = *this;
        --*this;
        return res;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) { a -= Modulus; }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) { a += Modulus; }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = (ll)a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(const modint rhs) noexcept {
        a = (ll)a * (modular::inv(rhs.a)).a % Modulus;
        return *this;
    }
    constexpr modint pow(long long n) const noexcept {
        if(n < 0) {
            n %= Modulus - 1;
            n = (Modulus - 1) + n;
        }
        modint x = *this, r = 1;
        while(n) {
            if(n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    constexpr modint inv() const noexcept { return pow(Modulus - 2); }
    constexpr friend modint operator+(const modint &lhs, const modint &rhs) { return modint(lhs) += modint(rhs); }
    constexpr friend modint operator-(const modint &lhs, const modint &rhs) { return modint(lhs) -= modint(rhs); }
    constexpr friend modint operator*(const modint &lhs, const modint &rhs) { return modint(lhs) *= modint(rhs); }
    constexpr friend modint operator/(const modint &lhs, const modint &rhs) { return modint(lhs) /= modint(rhs); }
    constexpr friend modint operator==(const modint &lhs, const modint &rhs) { return lhs.a == rhs.a; }
    constexpr friend modint operator!=(const modint &lhs, const modint &rhs) { return lhs.a != rhs.a; }
    // constexpr friend modint operator^=(const modint &lhs, const modint &rhs) { return modint(lhs) ^= modint(rhs); }
};
vmint Fact{1, 1}, Ifact{1, 1};
mint inv(int n) {
    if(n > MAXN) return (mint(n)).pow(MOD - 2);
    if(Inv.empty()) Inv.emplace_back(0), Inv.emplace_back(1);
    if(Inv.size() > n)
        return Inv[n];
    else {
        for(int i = Inv.size(); i <= n; ++i) {
            auto [y, x] = div(int(MOD), i);
            Inv.emplace_back(Inv[x] * (-y));
        }
        return Inv[n];
    }
}
mint fact(int n) {
    if(Fact.size() > n)
        return Fact[n];
    else
        for(int i = Fact.size(); i <= n; ++i) Fact.emplace_back(Fact[i - 1] * i);
    return Fact[n];
}
mint ifact(int n) {
    if(Ifact.size() > n)
        return Ifact[n];
    else
        for(int i = Ifact.size(); i <= n; ++i) Ifact.emplace_back(Ifact[i - 1] * inv(i));
    return Ifact[n];
}
mint modpow(ll a, ll n) { return mint(a).pow(n); }
mint inv(mint a) { return inv(a.a); }
mint ifact(mint a) { return ifact(a.a); }
mint fact(mint a) { return fact(a.a); }
mint modpow(mint a, ll n) { return modpow(a.a, n); }
mint C(int a, int b) {
    if(a < 0 || b < 0) return 0;
    if(a < b) return 0;
    if(a > MAXN) {
        mint res = 1;
        b = min(b, a - b);
        rep(i, b) res *= a - i, res /= i + 1;
        return res;
    }
    return fact(a) * ifact(b) * ifact(a - b);
}
mint P(int a, int b) {
    if(a < 0 || b < 0) return 0;
    if(a < b) return 0;
    if(a > MAXN) {
        mint res = 1;
        rep(i, b) res *= a - i;
        return res;
    }
    return fact(a) * ifact(a - b);
}
template <int mod> ostream &operator<<(ostream &os, modint<mod> a) {
    os << a.a;
    return os;
}
template <int mod> istream &operator>>(istream &is, modint<mod> &a) {
    ll x;
    is >> x;
    a = x;
    return is;
}
template <int mod> ostream &operator<<(ostream &os, const vector<modint<mod>> &a) {
    if(!a.empty()) {
        os << a[0];
        for(int i = 1; i < si(a); i++) os << " " << a[i];
    }
    return os;
}
struct modinfo {
    int mod, root;
};
constexpr modinfo base0{1045430273, 3};
constexpr modinfo base1{1051721729, 6};
constexpr modinfo base2{1053818881, 7};
using mint0 = modint<base0.mod>;
using mint1 = modint<base1.mod>;
using mint2 = modint<base2.mod>;
using Poly = vmint;
template <int mod> void FMT(vector<modint<mod>> &f, bool inv = false) {
    using V = vector<modint<mod>>;
    static V g(30), ig(30);
    if(g.front().a == 0) {
        modint<mod> root = 2;
        while((root.pow((mod - 1) / 2)).a == 1) root += 1;
        rep(i, 30) g[i] = -(root.pow((mod - 1) >> (i + 2))), ig[i] = g[i].inv();
    }
    int n = size(f);
    if(!inv) {
        for(int m = n; m >>= 1;) {
            modint<mod> w = 1;
            for(int s = 0, k = 0; s < n; s += 2 * m) {
                for(int i = s, j = s + m; i < s + m; ++i, ++j) {
                    auto x = f[i], y = f[j] * w;
                    long long ni = (long long)x.a + y.a;
                    f[i].a = (ni >= mod ? ni - mod : ni);
                    long long nj = (long long)x.a + mod - y.a;
                    f[j].a = (nj >= mod ? nj - mod : nj);
                }
                w *= g[__builtin_ctz(++k)];
            }
        }
    } else {
        for(int m = 1; m < n; m *= 2) {
            modint<mod> w = 1;
            for(int s = 0, k = 0; s < n; s += 2 * m) {
                for(int i = s, j = s + m; i < s + m; ++i, ++j) {
                    auto x = f[i], y = f[j];
                    long long ni = (long long)x.a + y.a;
                    f[i].a = (ni >= mod ? ni - mod : ni);
                    long long nj = (long long)x.a + mod - y.a;
                    f[j].a = (nj >= mod ? nj - mod : nj);
                    f[j] *= w;
                }
                w *= ig[__builtin_ctz(++k)];
            }
        }
    }
    modint<mod> c;
    if(inv)
        c = modint<mod>(n).inv();
    else
        c = 1;
    for(auto &&e : f) e *= c;
}
Poly operator-(Poly f) {
    for(auto &&e : f) e = -e;
    return f;
}
Poly &operator+=(Poly &l, const Poly &r) {
    l.resize(max(l.size(), r.size()));
    rep(i, r.size()) l[i] += r[i];
    return l;
}
Poly operator+(Poly l, const Poly &r) { return l += r; }
Poly &operator-=(Poly &l, const Poly &r) {
    l.resize(max(l.size(), r.size()));
    rep(i, r.size()) l[i] -= r[i];
    return l;
}
Poly operator-(Poly l, const Poly &r) { return l -= r; }
Poly &operator<<=(Poly &f, size_t n) { return f.insert(f.begin(), n, 0), f; }
Poly operator<<(Poly f, size_t n) { return f <<= n; }
Poly &operator>>=(Poly &f, size_t n) { return f.erase(f.begin(), f.begin() + min(f.size(), n)), f; }
Poly operator>>(Poly f, size_t n) { return f >>= n; }

constexpr int mod0 = 998244353, mod1 = 1300234241, mod2 = 1484783617;
using M0 = modint<mod0>;
using M1 = modint<mod1>;
using M2 = modint<mod2>;

template <int mod> void mul(vector<modint<mod>> &l, vector<modint<mod>> &r) {
    int n = size(l), m = size(r), sz = 1 << __lg(2 * (n + m - 1) - 1);
    l.resize(sz), FMT<mod>(l);
    r.resize(sz), FMT<mod>(r);
    rep(i, sz) l[i] *= r[i];
    FMT<mod>(l, true);
    l.resize(n + m - 1);
}
Poly operator*(const Poly &l, const Poly &r) {
    if(l.empty() or r.empty()) return Poly();
    int n = size(l), m = size(r), sz = 1 << __lg(2 * (n + m - 1) - 1);
    vector<M0> l0(n), r0(m);
    vector<M1> l1(n), r1(m);
    vector<M2> l2(n), r2(m);
    rep(i, n) l0[i] = l[i].a, l1[i] = l[i].a, l2[i] = l[i].a;
    rep(i, m) r0[i] = r[i].a, r1[i] = r[i].a, r2[i] = r[i].a;
    mul<mod0>(l0, r0), mul<mod1>(l1, r1), mul<mod2>(l2, r2);
    Poly res(n + m - 1);
    // garner
    static constexpr M1 inv0 = 613999507;
    static constexpr M2 inv1 = 1147332803, inv0m1 = 45381342;
    static constexpr mint m0 = mod0, m0m1 = m0 * mod1;
    rep(i, n + m - 1) {
        int y0 = l0[i].a;
        int y1 = (inv0 * (l1[i] - y0)).a;
        int y2 = (inv0m1 * (l2[i] - y0) - inv1 * y1).a;
        res[i] = m0 * y1 + m0m1 * y2 + y0;
    }
    return res;
}
Poly &operator*=(Poly &l, const Poly &r) { return l = l * r; }
Poly integ(const Poly &f) {
    Poly res(f.size() + 1);
    for(int i = 1; i < (int)res.size(); ++i) res[i] = f[i - 1] / i;
    return res;
}
struct Prd {
    deque<Poly> deq;
    Prd() = default;
    void emplace(const Poly &f) { deq.emplace_back(f); }
    Poly calc() {
        if(deq.empty()) return {1};
        sort(all(deq), [&](const Poly &f, const Poly &g) { return si(f) < si(g); });
        while(deq.size() > 1) {
            deq.emplace_back(deq[0] * deq[1]);
            for(int i = 0; i < 2; ++i) deq.pop_front();
        }
        return deq.front();
    }
};
Poly prd(vector<Poly> &v) {
    Prd p;
    for(auto &e : v) p.emplace(e);
    return p.calc();
}
// Poly deriv(const Poly &f) {
//     if(f.size() == 0) return Poly();
//     Poly res(f.size() - 1);
//     rep(i, res.size()) res[i] = f[i + 1] * (i + 1);
//     return res;
// }
// ostream &operator<<(ostream &os, const Poly &a) {
//     for(auto e : a) os << e.a << " ";
//     return os;
// }

vmint power_table(mint x, int len) {
    vmint res(len + 1);
    res[0] = 1;
    rep(i, len) res[i + 1] = res[i] * x;
    return res;
}
// ボールの数、一個以上必要な数、入っていなくてもいい数(区別あり)
mint choose(int num, int a, int b = 0) {
    if(num == 0) return !a;
    return C(num + b - 1, a + b - 1);
}
} // namespace modular
using namespace modular;

int main() {
    INT(n, m);
    auto g = getG(n, m);

    vv(int, G, n, n);
    rep(i, n) fore(e, g[i]) G[i][e] = true;

    vi used(n, 1);

    mint ans;

    rep(iter, n) {
        dump(iter);
        int mi = inf<int>, x;
        rep(i, n) {
            dump(i);
            if(!used[i]) continue;
            int c = 0;
            fore(e, g[i]) {
                if(used[e]) c++;
            }
            if(chmin(mi, c)) x = i;
        }

        vi v;
        fore(e, g[x]) if(used[e]) v.eb(e);

        auto isC = [&](int l, int r) -> vi {
            // dump(l, r);
            // dump(v);
            int n = r - l;
            vi res(1 << n);
            rep(i, l, r) rep(j, l, r) {
                if(i == j) continue;
                if(!G[v[i]][v[j]]) { res[bit(i - l) + bit(j - l)] = 1; }
            }
            // dump(l, r);
            zeta_subsetsum(res);
            fore(e, res) e = !e;
            return res;
        };

        int mid = si(v) / 2;
        auto lc = isC(0, mid), rc = isC(mid, si(v));

        zeta_subsetsum(rc);

        vi lg(mid);
        rep(i, mid) {
            dump(i);
            rep(j, mid, si(v)) {
                if(G[v[i]][v[j]]) lg[i] |= bit(j - mid);
            }
        }

        rep(i, si(lc)) {
            if(lc[i]) {
                int tmp = mask(si(v) - mid);
                rep(j, mid) if(test(i, j)) tmp &= lg[j];

                ans += rc[tmp];
            }
        }

        used[x] = false;
    }
    OUT(ans);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

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

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 3ms
memory: 7212kb

input:

1000 100
446 789
167 547
254 777
777 185
33 446
777 847
185 877
757 167
72 383
847 446
254 478
959 185
757 446
847 959
959 167
757 847
747 757
446 167
989 757
547 777
33 747
33 254
254 843
33 547
446 980
877 205
185 72
980 959
33 205
877 757
33 847
478 843
757 478
167 877
72 789
877 959
980 478
167 ...

output:

1373

result:

ok single line: '1373'

Test #4:

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

input:

1000 1000
770 105
219 498
686 498
343 534
15 591
919 588
149 588
298 915
551 523
710 116
105 637
523 991
343 476
145 420
604 588
254 120
551 421
476 298
900 710
915 343
445 421
986 867
445 588
219 356
919 105
584 875
991 604
776 919
588 254
919 421
356 348
105 551
15 113
919 15
356 523
343 155
770 9...

output:

6621319

result:

ok single line: '6621319'

Test #5:

score: 0
Accepted
time: 36ms
memory: 9216kb

input:

1000 1000
840 251
559 572
77 993
857 254
176 77
30 423
838 251
862 466
920 254
254 593
593 423
780 575
487 865
952 176
480 77
351 487
620 390
231 496
423 761
993 385
383 390
220 620
862 805
920 838
77 339
838 231
691 384
930 251
840 77
593 993
838 930
176 761
383 761
480 487
251 383
295 390
289 808
...

output:

6403686

result:

ok single line: '6403686'

Test #6:

score: 0
Accepted
time: 33ms
memory: 8860kb

input:

1000 1000
179 73
322 80
586 342
73 819
973 184
508 131
351 342
576 179
397 23
523 926
684 73
479 722
973 80
576 397
301 508
903 618
672 192
33 903
973 885
523 661
885 8
787 988
647 990
393 211
722 586
751 926
960 322
179 131
131 988
196 342
508 351
672 342
644 926
990 819
301 80
73 397
104 131
678 3...

output:

6066915

result:

ok single line: '6066915'

Test #7:

score: 0
Accepted
time: 35ms
memory: 8632kb

input:

1000 1000
179 707
71 73
410 726
459 410
84 432
500 73
578 864
71 145
538 578
265 145
707 565
674 772
859 676
826 71
538 459
548 479
609 45
674 707
30 145
45 726
41 73
446 265
145 479
587 642
179 632
908 548
674 410
361 632
500 642
929 976
73 446
41 361
71 726
179 212
341 929
45 859
826 179
632 144
4...

output:

6242289

result:

ok single line: '6242289'

Test #8:

score: 0
Accepted
time: 31ms
memory: 8472kb

input:

1000 1000
146 917
487 589
225 927
972 449
969 728
99 288
615 564
728 146
880 561
563 745
442 880
118 392
634 564
636 917
442 738
280 254
225 710
254 449
221 564
394 969
556 99
634 589
976 301
117 487
561 867
98 880
392 880
917 819
556 634
941 969
653 927
972 615
146 819
969 98
653 941
809 699
590 30...

output:

9171879

result:

ok single line: '9171879'

Test #9:

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

input:

1000 1000
709 558
844 316
552 395
944 619
805 279
837 392
822 772
964 805
597 397
814 344
527 401
964 299
922 782
746 349
795 537
945 57
527 176
815 937
257 955
245 108
245 593
932 155
597 812
18 856
116 218
671 142
511 945
481 405
966 695
782 38
130 638
470 692
671 307
837 571
925 43
411 249
613 38...

output:

2186

result:

ok single line: '2186'

Test #10:

score: 0
Accepted
time: 3ms
memory: 7092kb

input:

1000 1000
833 350
567 76
488 416
350 135
874 275
555 996
263 152
14 380
409 442
672 836
490 5
421 901
781 875
135 209
162 442
6 47
111 180
317 162
876 368
393 656
712 535
583 976
918 591
29 887
436 599
702 5
512 778
901 111
423 591
274 599
686 655
2 656
444 172
836 800
865 920
3 19
781 375
157 683
8...

output:

2193

result:

ok single line: '2193'

Test #11:

score: 0
Accepted
time: 3ms
memory: 7184kb

input:

1000 1000
655 894
253 168
615 321
526 160
225 578
845 473
14 839
321 659
138 448
575 787
342 557
338 501
192 504
888 172
531 616
83 136
623 137
746 344
385 337
505 394
634 740
242 449
321 630
804 971
386 160
466 641
83 133
570 527
448 273
888 653
3 479
467 18
630 93
271 574
653 5
764 370
972 466
501...

output:

2159

result:

ok single line: '2159'

Test #12:

score: 0
Accepted
time: 4ms
memory: 7056kb

input:

1000 1000
210 626
59 74
95 486
328 63
894 222
908 764
299 197
871 600
954 241
431 660
816 997
186 34
737 604
889 568
454 115
61 933
417 221
279 971
333 340
143 374
168 409
426 50
875 423
86 413
805 719
222 319
461 864
244 679
49 220
98 579
329 737
568 926
328 330
694 445
318 480
576 748
242 989
968 ...

output:

2013

result:

ok single line: '2013'

Test #13:

score: 0
Accepted
time: 4ms
memory: 7068kb

input:

1000 1000
937 639
771 95
626 134
869 66
465 29
889 944
194 239
284 303
935 111
795 806
737 770
665 343
862 528
232 571
342 458
401 490
452 628
425 384
998 578
192 168
64 651
486 311
840 667
400 255
364 206
486 289
761 912
189 907
158 339
891 336
392 782
598 233
899 539
19 780
190 535
933 700
500 232...

output:

2004

result:

ok single line: '2004'

Test #14:

score: 0
Accepted
time: 4ms
memory: 7688kb

input:

1000 1000
568 607
217 544
12 124
766 801
924 290
957 218
816 552
913 189
982 916
896 289
304 74
426 190
844 543
849 972
386 59
626 472
869 838
234 581
232 707
623 685
873 344
295 496
352 557
314 35
329 432
155 422
803 322
42 735
36 760
249 306
706 533
748 161
887 911
872 64
440 450
662 607
274 659
7...

output:

2002

result:

ok single line: '2002'

Test #15:

score: 0
Accepted
time: 4ms
memory: 7104kb

input:

1000 1000
726 492
65 652
168 218
347 489
35 415
73 324
80 419
237 352
378 3
708 286
933 810
116 563
819 610
670 386
392 940
434 926
341 617
820 842
618 974
592 344
724 578
955 761
26 902
545 496
688 636
273 225
749 840
661 784
917 595
503 84
414 252
925 877
352 479
792 914
54 666
324 257
642 637
801...

output:

2002

result:

ok single line: '2002'

Test #16:

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

input:

1000 1000
344 107
264 268
28 38
211 260
741 682
654 885
607 213
610 296
869 556
685 269
996 929
61 370
804 605
786 570
41 448
104 549
245 166
36 84
265 135
704 409
60 299
895 645
868 140
3 483
448 341
778 460
930 13
796 688
936 751
808 458
859 502
918 43
920 287
680 976
918 172
378 156
962 834
635 3...

output:

2002

result:

ok single line: '2002'

Test #17:

score: 0
Accepted
time: 3ms
memory: 7064kb

input:

1000 1000
117 152
117 375
190 586
117 586
278 546
788 450
117 90
511 586
450 595
586 492
870 278
17 117
586 275
520 471
796 117
520 112
117 431
292 520
320 520
278 95
586 677
450 402
298 520
586 109
450 409
520 607
684 278
520 898
340 278
17 520
586 64
586 100
520 647
450 270
520 617
685 117
117 985...

output:

6290

result:

ok single line: '6290'

Test #18:

score: 0
Accepted
time: 3ms
memory: 7060kb

input:

1000 1000
88 346
534 200
881 661
869 23
35 869
26 785
158 785
881 981
835 881
88 466
88 559
760 88
905 869
869 672
869 256
945 534
881 664
905 30
631 868
536 124
869 271
712 88
534 30
513 785
785 902
491 869
869 868
505 869
488 897
905 144
88 513
785 536
785 599
303 905
534 869
158 897
384 905
236 9...

output:

132867

result:

ok single line: '132867'

Test #19:

score: 0
Accepted
time: 4ms
memory: 7576kb

input:

1000 1000
463 338
246 242
91 76
130 858
818 250
255 639
135 571
809 250
794 255
91 170
386 678
639 513
507 684
463 407
463 969
463 769
685 463
250 513
126 684
684 444
53 969
250 876
811 639
286 571
386 684
571 407
794 463
507 463
295 170
678 809
91 678
811 349
777 53
463 286
261 401
130 346
91 625
8...

output:

9143208

result:

ok single line: '9143208'

Test #20:

score: 0
Accepted
time: 32ms
memory: 7804kb

input:

1000 1000
624 79
120 926
418 455
310 792
116 165
688 185
34 792
985 129
884 79
624 847
356 494
79 785
15 891
792 455
274 554
891 518
453 116
792 188
356 57
884 669
926 940
608 673
847 884
884 455
871 985
418 15
185 926
871 608
78 145
554 494
356 669
129 792
624 129
274 79
284 129
688 116
940 650
884...

output:

119880110

result:

ok single line: '119880110'

Test #21:

score: 0
Accepted
time: 175ms
memory: 13388kb

input:

1000 780
456 159
722 862
983 491
946 335
159 379
516 983
330 823
491 335
607 645
910 379
538 872
823 456
518 840
414 456
507 453
910 872
456 461
235 607
340 379
379 20
351 491
946 159
159 722
840 116
823 679
840 594
10 983
910 10
125 594
777 116
760 516
20 840
909 491
516 862
872 838
228 760
517 679...

output:

511621042

result:

ok single line: '511621042'

Test #22:

score: 0
Accepted
time: 15ms
memory: 8208kb

input:

1000 528
760 566
75 156
566 600
566 478
156 216
582 489
395 712
75 955
930 81
344 216
395 930
380 172
156 172
616 142
81 582
75 493
81 925
996 712
771 55
996 760
771 25
712 600
600 634
210 478
56 55
380 700
87 380
55 210
955 930
771 566
142 712
719 930
582 771
87 582
700 344
925 760
318 489
707 489
...

output:

589935502

result:

ok single line: '589935502'

Test #23:

score: 0
Accepted
time: 3ms
memory: 7700kb

input:

1000 300
794 991
641 688
983 652
689 863
762 458
997 526
553 102
114 924
997 648
114 16
652 102
289 553
794 16
762 652
691 289
991 983
693 689
688 693
553 326
233 326
326 641
458 114
353 102
648 326
353 326
924 526
693 458
526 114
762 553
458 326
233 410
326 762
353 689
641 924
410 924
326 997
693 3...

output:

33555406

result:

ok single line: '33555406'

Test #24:

score: 0
Accepted
time: 105ms
memory: 15376kb

input:

1000 1000
678 283
616 283
675 678
449 486
486 892
734 781
465 343
496 379
35 301
299 409
496 781
978 538
434 283
453 406
751 289
812 979
289 379
374 979
449 206
299 219
486 649
496 883
334 807
892 449
678 812
892 299
383 289
978 453
242 971
734 37
35 892
971 217
423 467
978 283
334 138
465 374
978 4...

output:

53556160

result:

ok single line: '53556160'

Test #25:

score: 0
Accepted
time: 3ms
memory: 7136kb

input:

1000 1000
78 443
134 843
114 831
45 245
630 312
985 457
813 702
431 78
572 646
362 749
190 195
248 197
739 312
749 346
104 620
646 848
792 362
646 243
460 630
190 399
617 457
396 195
151 749
568 243
19 565
19 721
551 630
168 437
630 31
96 157
329 621
869 758
329 550
261 749
620 630
212 431
646 758
7...

output:

103300

result:

ok single line: '103300'

Test #26:

score: 0
Accepted
time: 3ms
memory: 7216kb

input:

1000 999
702 735
84 611
593 671
901 43
512 383
394 247
341 663
434 17
857 142
885 287
759 533
257 982
713 234
75 661
272 242
577 797
570 271
948 478
890 593
113 469
425 72
943 513
452 937
611 291
928 50
261 776
872 469
208 10
855 987
510 190
16 785
562 815
901 965
34 895
790 368
948 511
442 457
798 ...

output:

3331

result:

ok single line: '3331'

Test #27:

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

input:

1000 1000
561 417
561 221
739 163
431 493
561 113
739 433
431 64
619 739
265 561
260 674
266 739
561 619
561 198
431 522
518 561
522 561
730 776
431 924
863 730
674 866
739 236
579 730
431 237
561 86
418 431
561 247
810 674
730 981
674 199
739 863
739 813
730 221
74 561
739 79
431 943
776 431
288 73...

output:

7128

result:

ok single line: '7128'

Test #28:

score: 0
Accepted
time: 4ms
memory: 7624kb

input:

1000 1000
33 910
133 738
274 738
703 511
818 349
452 882
33 589
751 882
243 980
3 511
349 415
222 415
620 312
415 749
162 980
243 3
818 118
980 312
483 862
511 12
882 703
563 862
929 289
749 738
88 3
929 3
452 620
274 415
582 593
749 620
563 164
34 620
952 33
7 452
620 818
818 703
582 186
582 903
96...

output:

34603935

result:

ok single line: '34603935'

Test #29:

score: 0
Accepted
time: 20ms
memory: 7996kb

input:

1000 990
255 105
147 35
153 337
754 337
179 683
570 807
850 545
147 672
337 705
447 748
781 864
604 294
781 147
35 82
570 604
474 54
296 748
683 563
193 718
864 105
255 147
296 683
147 748
672 54
228 186
296 222
186 604
186 563
545 746
89 513
754 296
82 447
474 35
604 447
781 850
683 186
705 147
337...

output:

442451836

result:

ok single line: '442451836'

Test #30:

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

input:

1000 1000
718 915
120 276
503 601
798 754
81 338
537 83
857 331
718 461
338 651
915 429
915 408
814 375
718 897
871 355
207 603
494 331
52 563
116 81
814 674
857 537
289 81
718 871
81 909
929 375
537 573
537 658
725 364
402 814
573 120
754 333
331 674
537 601
798 338
563 227
871 289
364 429
857 923
...

output:

603980708

result:

ok single line: '603980708'

Test #31:

score: 0
Accepted
time: 3ms
memory: 7068kb

input:

1000 1000
958 768
706 122
253 922
629 958
931 413
283 860
188 567
766 729
269 231
965 288
743 207
991 207
61 965
522 520
567 164
231 691
164 915
723 992
588 389
498 967
936 279
766 207
36 946
339 989
218 183
132 99
70 202
634 971
860 848
663 848
663 158
669 405
13 207
983 231
221 740
882 967
140 253...

output:

96119

result:

ok single line: '96119'

Test #32:

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

input:

1000 1000
538 269
110 87
434 7
892 344
432 612
700 505
795 647
82 323
339 395
849 499
755 165
833 55
720 356
612 66
898 257
922 276
729 162
395 883
840 629
886 668
278 735
394 859
677 156
435 805
474 339
92 140
832 764
233 26
192 635
165 784
138 417
585 474
278 619
739 82
154 651
884 503
504 883
575...

output:

4727

result:

ok single line: '4727'

Test #33:

score: 0
Accepted
time: 3ms
memory: 7692kb

input:

1000 1000
856 285
780 619
299 191
355 538
339 369
440 573
458 865
853 170
1 984
387 500
656 704
783 255
596 773
767 300
819 533
39 474
455 741
3 884
525 253
852 483
186 488
807 255
781 364
173 514
145 317
146 584
98 585
752 182
88 763
806 828
492 921
775 50
963 40
657 49
742 157
452 832
344 20
793 1...

output:

2499

result:

ok single line: '2499'

Test #34:

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

input:

1000 999
225 313
436 33
227 970
316 147
255 623
774 491
98 448
416 945
498 479
452 440
649 108
71 669
269 172
978 892
804 486
626 904
940 212
35 189
78 957
680 328
791 68
587 99
69 313
583 910
14 558
376 219
428 144
370 337
154 49
297 885
964 473
308 56
953 507
981 602
9 666
757 238
809 370
283 133
...

output:

1999

result:

ok single line: '1999'

Test #35:

score: 0
Accepted
time: 379ms
memory: 31740kb

input:

1000 990
534 306
192 420
625 205
266 815
371 257
541 312
312 554
526 986
257 794
809 266
156 137
767 266
192 767
541 870
649 625
554 454
809 792
1000 378
46 526
792 985
306 554
755 957
541 957
1000 257
720 809
153 205
796 306
985 306
870 454
274 794
794 901
986 937
96 720
306 156
796 794
635 837
23 ...

output:

807527901

result:

ok single line: '807527901'

Test #36:

score: 0
Accepted
time: 180ms
memory: 15488kb

input:

1000 1000
672 525
486 525
521 469
649 109
254 553
163 517
34 773
37 553
561 34
37 578
746 811
250 811
517 360
822 922
566 652
822 378
521 922
612 597
305 561
935 240
109 120
811 578
694 797
935 387
517 561
935 649
797 264
612 594
746 120
944 897
649 705
974 710
566 561
974 797
944 240
378 264
822 79...

output:

513746449

result:

ok single line: '513746449'

Test #37:

score: 0
Accepted
time: 90ms
memory: 11300kb

input:

1000 1000
403 894
280 779
618 403
859 474
619 606
403 647
824 918
833 257
838 937
482 824
478 838
779 85
645 85
474 824
894 734
779 618
403 522
740 789
918 619
257 2
318 712
278 897
478 318
695 606
894 214
449 859
736 918
858 824
62 214
736 860
647 736
264 736
918 897
618 789
695 62
354 712
918 838
...

output:

95754463

result:

ok single line: '95754463'

Test #38:

score: 0
Accepted
time: 40ms
memory: 9400kb

input:

1000 1000
833 152
949 597
833 343
65 925
618 744
758 919
175 70
858 534
328 526
398 271
994 318
814 175
744 614
758 483
152 70
249 814
919 343
597 246
233 837
744 526
236 249
710 1
23 660
246 373
614 19
334 999
70 343
614 221
70 23
236 919
534 221
858 949
221 233
999 814
65 758
328 236
363 925
814 7...

output:

5693083

result:

ok single line: '5693083'

Test #39:

score: 0
Accepted
time: 359ms
memory: 31796kb

input:

1000 990
22 39
24 2
39 41
44 39
41 5
38 4
19 30
40 27
24 16
7 22
28 34
32 17
32 4
44 6
27 22
6 33
43 30
45 7
46 35
45 20
42 11
10 27
3 1
26 19
7 25
32 39
12 30
1 41
18 7
9 13
14 7
12 40
4 18
10 32
1 13
37 22
12 10
33 42
34 15
11 9
9 43
24 45
8 10
32 42
41 28
6 23
24 40
19 15
37 27
30 9
32 20
35 17
1...

output:

807527901

result:

ok single line: '807527901'

Test #40:

score: 0
Accepted
time: 152ms
memory: 13848kb

input:

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

output:

654727113

result:

ok single line: '654727113'

Test #41:

score: 0
Accepted
time: 357ms
memory: 31856kb

input:

1000 990
40 5
36 31
20 33
5 25
29 17
42 27
23 18
31 39
38 20
38 45
11 23
46 43
21 24
27 23
2 15
15 21
37 4
36 1
10 26
13 17
37 30
31 44
20 16
2 23
12 40
34 20
6 11
1 5
27 9
6 12
15 19
37 44
1 27
14 2
22 24
36 21
14 45
40 1
22 46
16 33
40 27
46 15
29 31
39 25
34 17
42 23
12 45
16 29
31 13
8 46
42 15
...

output:

807527901

result:

ok single line: '807527901'

Test #42:

score: 0
Accepted
time: 163ms
memory: 15388kb

input:

1000 1000
34 22
7 19
40 45
29 34
26 41
9 24
15 25
26 37
41 4
22 41
25 11
16 32
28 21
45 34
12 34
8 4
26 2
28 42
31 12
36 29
4 28
2 19
37 19
18 31
46 43
35 43
47 20
5 32
23 30
7 42
47 33
2 38
18 20
35 31
13 26
9 27
24 21
11 16
38 41
8 30
46 13
18 40
33 20
45 13
16 47
21 34
12 37
28 43
10 23
14 35
22 ...

output:

561952342

result:

ok single line: '561952342'

Test #43:

score: 0
Accepted
time: 480ms
memory: 19616kb

input:

44 924
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
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
2 22
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
3 21
3 22
4 5
4 6
4 7
4 ...

output:

381059391

result:

ok single line: '381059391'