QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#878780 | #9700. Ying’s Cup | ucup-team112# | AC ✓ | 1313ms | 8196kb | C++23 | 23.9kb | 2025-02-01 17:38:17 | 2025-02-01 17:38:18 |
Judging History
answer
//#define _GLIBCXX_DEBUG
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif
#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
namespace template_tute{
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 4.1e18;
using P = pair<ll, ll>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max<ll>({a,b,c})-min<ll>({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};
template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
auto tmp = v;
for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
rearrange(ord, head);
rearrange(ord, tail...);
}
template<typename T> vector<int> ascend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
return ord;
}
template<typename T> vector<int> descend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
return ord;
}
template<typename T> vector<T> inv_perm(const vector<T>&ord){
vector<T>inv(ord.size());
for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
return inv;
}
ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
ll modulo(ll n,ll d){return (n%d+d)%d;};
template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};
template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(std::ios_base::badbit);
}
}
return dest;
}
namespace converter{
int dict[500];
const string lower="abcdefghijklmnopqrstuvwxyz";
const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string digit="0123456789";
const string digit1="123456789";
void regi_str(const string &t){
for(int i=0;i<t.size();i++){
dict[t[i]]=i;
}
}
void regi_int(const string &t){
for(int i=0;i<t.size();i++){
dict[i]=t[i];
}
}
vector<int>to_int(const string &s,const string &t){
regi_str(t);
vector<int>ret(s.size());
for(int i=0;i<s.size();i++){
ret[i]=dict[s[i]];
}
return ret;
}
vector<int>to_int(const string &s){
auto t=s;
sort(t.begin(),t.end());
t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
vector<vector<int>>to_int(const vector<string>&s,const string &t){
regi_str(t);
vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
for(int i=0;i<s.size();i++){
for(int j=0;j<s[0].size();j++){
ret[i][j]=dict[s[i][j]];
}
}
return ret;
}
vector<vector<int>>to_int(const vector<string>&s){
string t;
for(int i=0;i<s.size();i++){
t+=s[i];
}
sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
string to_str(const vector<int>&s,const string &t){
regi_int(t);
string ret;
for(auto z:s)ret+=dict[z];
return ret;
}
vector<string> to_str(const vector<vector<int>>&s,const string &t){
regi_int(t);
vector<string>ret(s.size());
for(int i=0;i<s.size();i++){
for(auto z:s[i])ret[i]+=dict[z];
}
return ret;
}
}
template< typename T = int >
struct edge {
int to;
T cost;
int id;
edge():to(-1),id(-1){};
edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
operator int() const { return to; }
};
template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
Graph<T>revgraph(const Graph<T> &g){
Graph<T>ret(g.size());
for(int i=0;i<g.size();i++){
for(auto e:g[i]){
int to = e.to;
e.to = i;
ret[to].push_back(e);
}
}
return ret;
}
template<typename T>
Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
Graph<T> ret(n);
for(int es = 0; es < m; es++){
int u,v;
T w=1;
cin>>u>>v;u-=indexed,v-=indexed;
if(weighted)cin>>w;
ret[u].emplace_back(v,w,es);
if(!directed)ret[v].emplace_back(u,w,es);
}
return ret;
}
template<typename T>
Graph<T> readParent(int n,int indexed=1,bool directed=true){
Graph<T>ret(n);
for(int i=1;i<n;i++){
int p;cin>>p;
p-=indexed;
ret[p].emplace_back(i);
if(!directed)ret[i].emplace_back(p);
}
return ret;
}
}
using namespace template_tute;
template< int mod >
struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if((x += p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if((x += mod - p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int) (1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
friend ModInt operator+(const ModInt& lhs, const ModInt& rhs) {
return ModInt(lhs) += rhs;
}
friend ModInt operator-(const ModInt& lhs, const ModInt& rhs) {
return ModInt(lhs) -= rhs;
}
friend ModInt operator*(const ModInt& lhs, const ModInt& rhs) {
return ModInt(lhs) *= rhs;
}
friend ModInt operator/(const ModInt& lhs, const ModInt& rhs) {
return ModInt(lhs) /= rhs;
}
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while(b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while(n > 0) {
if(n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
pair<int,int>frac(){
for(int j=1;j<=10000;j++){
auto v=*this*j;
if(v.x<=10000)return make_pair(v.x,j);
else if(v.x>=mod-10000)return make_pair(-(v.x-mod),j);
}
return make_pair(-1,-1);
}
friend ostream &operator<<(ostream &os, const ModInt &p) {
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt< mod >(t);
return (is);
}
static constexpr int get_mod() { return mod; }
};
template< typename T >
struct Combination {
vector< T > _fact, _rfact, _inv;
Combination(ll sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
_fact[0] = _rfact[sz] = _inv[0] = 1;
for(ll i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for(ll i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
for(ll i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
}
inline T fact(ll k) const { return _fact[k]; }
inline T rfact(ll k) const { return _rfact[k]; }
inline T inv(ll k) const { return _inv[k]; }
T P(ll n, ll r) const {
if(r < 0 || n < r) return 0;
return fact(n) * rfact(n - r);
}
T C(ll p, ll q) const {
if(q < 0 || p < q) return 0;
return fact(p) * rfact(q) * rfact(p - q);
}
T RC(ll p, ll q) const {
if(q < 0 || p < q) return 0;
return rfact(p) * fact(q) * fact(p - q);
}
T H(ll n, ll r) const {
if(n < 0 || r < 0) return (0);
return r == 0 ? 1 : C(n + r - 1, r);
}
//+1がm個、-1がn個で prefix sumが常にk以上
T catalan(ll m,ll n,ll k){
if(n>m-k)return 0;
else return C(n+m,m)-C(n+m,n+k-1);
}
};
using modint = ModInt< MOD9 >;modint mpow(ll n, ll x){return modint(n).pow(x);}modint mpow(modint n, ll x){return n.pow(x);}
//using modint=ld;modint mpow(ll n, ll x){return pow(n,x);}modint mpow(modint n, ll x){return pow(n,x);}
using Comb=Combination<modint>;
template< typename Mint >
struct NumberTheoreticTransformFriendlyModInt {
static constexpr uint32_t get_pr() {
uint32_t _mod = Mint::get_mod();
using u64 = uint64_t;
u64 ds[32] = {};
int idx = 0;
u64 m = _mod - 1;
for (u64 i = 2; i * i <= m; ++i) {
if (m % i == 0) {
ds[idx++] = i;
while (m % i == 0) m /= i;
}
}
if (m != 1) ds[idx++] = m;
uint32_t _pr = 2;
while (1) {
int flg = 1;
for (int i = 0; i < idx; ++i) {
u64 a = _pr, b = (_mod - 1) / ds[i], r = 1;
while (b) {
if (b & 1) r = r * a % _mod;
a = a * a % _mod;
b >>= 1;
}
if (r == 1) {
flg = 0;
break;
}
}
if (flg == 1) break;
++_pr;
}
return _pr;
};
static constexpr uint32_t root = get_pr();
static vector< Mint > dw, idw;
NumberTheoreticTransformFriendlyModInt() = default;
static void init() {
dw.resize(level);
idw.resize(level);
setwy(level);
}
static void fft4(vector<Mint> &a, int k) {
if ((int)a.size() <= 1) return;
if (k == 1) {
Mint a1 = a[1];
a[1] = a[0] - a[1];
a[0] = a[0] + a1;
return;
}
if (k & 1) {
int v = 1 << (k - 1);
for (int j = 0; j < v; ++j) {
Mint ajv = a[j + v];
a[j + v] = a[j] - ajv;
a[j] += ajv;
}
}
int u = 1 << (2 + (k & 1));
int v = 1 << (k - 2 - (k & 1));
Mint one = Mint(1);
Mint imag = dw[1];
while (v) {
// jh = 0
{
int j0 = 0;
int j1 = v;
int j2 = j1 + v;
int j3 = j2 + v;
for (; j0 < v; ++j0, ++j1, ++j2, ++j3) {
Mint t0 = a[j0], t1 = a[j1], t2 = a[j2], t3 = a[j3];
Mint t0p2 = t0 + t2, t1p3 = t1 + t3;
Mint t0m2 = t0 - t2, t1m3 = (t1 - t3) * imag;
a[j0] = t0p2 + t1p3, a[j1] = t0p2 - t1p3;
a[j2] = t0m2 + t1m3, a[j3] = t0m2 - t1m3;
}
}
// jh >= 1
Mint ww = one, xx = one * dw[2], wx = one;
for (int jh = 4; jh < u;) {
ww = xx * xx, wx = ww * xx;
int j0 = jh * v;
int je = j0 + v;
int j2 = je + v;
for (; j0 < je; ++j0, ++j2) {
Mint t0 = a[j0], t1 = a[j0 + v] * xx, t2 = a[j2] * ww,
t3 = a[j2 + v] * wx;
Mint t0p2 = t0 + t2, t1p3 = t1 + t3;
Mint t0m2 = t0 - t2, t1m3 = (t1 - t3) * imag;
a[j0] = t0p2 + t1p3, a[j0 + v] = t0p2 - t1p3;
a[j2] = t0m2 + t1m3, a[j2 + v] = t0m2 - t1m3;
}
xx *= dw[__builtin_ctzll((jh += 4))];
}
u <<= 2;
v >>= 2;
}
}
static void ifft4(vector<Mint> &a, int k) {
if ((int)a.size() <= 1) return;
if (k == 1) {
Mint a1 = a[1];
a[1] = a[0] - a[1];
a[0] = a[0] + a1;
return;
}
int u = 1 << (k - 2);
int v = 1;
Mint one = Mint(1);
Mint imag = idw[1];
while (u) {
// jh = 0
{
int j0 = 0;
int j1 = v;
int j2 = v + v;
int j3 = j2 + v;
for (; j0 < v; ++j0, ++j1, ++j2, ++j3) {
Mint t0 = a[j0], t1 = a[j1], t2 = a[j2], t3 = a[j3];
Mint t0p1 = t0 + t1, t2p3 = t2 + t3;
Mint t0m1 = t0 - t1, t2m3 = (t2 - t3) * imag;
a[j0] = t0p1 + t2p3, a[j2] = t0p1 - t2p3;
a[j1] = t0m1 + t2m3, a[j3] = t0m1 - t2m3;
}
}
// jh >= 1
Mint ww = one, xx = one * idw[2], yy = one;
u <<= 2;
for (int jh = 4; jh < u;) {
ww = xx * xx, yy = xx * imag;
int j0 = jh * v;
int je = j0 + v;
int j2 = je + v;
for (; j0 < je; ++j0, ++j2) {
Mint t0 = a[j0], t1 = a[j0 + v], t2 = a[j2], t3 = a[j2 + v];
Mint t0p1 = t0 + t1, t2p3 = t2 + t3;
Mint t0m1 = (t0 - t1) * xx, t2m3 = (t2 - t3) * yy;
a[j0] = t0p1 + t2p3, a[j2] = (t0p1 - t2p3) * ww;
a[j0 + v] = t0m1 + t2m3, a[j2 + v] = (t0m1 - t2m3) * ww;
}
xx *= idw[__builtin_ctzll(jh += 4)];
}
u >>= 4;
v <<= 2;
}
if (k & 1) {
u = 1 << (k - 1);
for (int j = 0; j < u; ++j) {
Mint ajv = a[j] - a[j + u];
a[j] += a[j + u];
a[j + u] = ajv;
}
}
}
static void ntt(vector<Mint> &a) {
if ((int)a.size() <= 1) return;
fft4(a, __builtin_ctz(a.size()));
}
static void intt(vector<Mint> &a) {
if ((int)a.size() <= 1) return;
ifft4(a, __builtin_ctz(a.size()));
Mint iv = Mint(a.size()).inverse();
for (auto &x : a) x *= iv;
}
static constexpr int mod = Mint::get_mod();
static constexpr int level = __builtin_ctzll(mod - 1);
static void setwy(int k) {
Mint w[level], y[level];
w[k - 1] = Mint(root).pow((mod - 1) / (1 << k));
y[k - 1] = w[k - 1].inverse();
for (int i = k - 2; i > 0; --i)
w[i] = w[i + 1] * w[i + 1], y[i] = y[i + 1] * y[i + 1];
dw[1] = w[1], idw[1] = y[1], dw[2] = w[2], idw[2] = y[2];
for (int i = 3; i < k; ++i) {
dw[i] = dw[i - 1] * y[i - 2] * w[i];
idw[i] = idw[i - 1] * w[i - 2] * y[i];
}
}
static vector<Mint>ffted(const vector<Mint>&a,int sz){
int k=2,M=4;
while(M<sz)M<<=1,++k;
setwy(k);
vector<Mint>ret(M);
for(int i=0;i<(int)a.size();i++)ret[i]=a[i];
fft4(ret,k);
return ret;
}
static vector<Mint> multiply(const vector<Mint> &a, const vector<Mint> &b
,vector<Mint>sa=vector<Mint>(),vector<Mint>sb=vector<Mint>()
) {
//OUT(l,a,b);
int l=a.size()+b.size()-1;
if (min<int>(a.size(), b.size()) <= 30) {
vector<Mint> s(l);
for (int i = 0; i < (int)a.size(); ++i)
for (int j = 0; j < (int)b.size(); ++j) s[i + j] += a[i] * b[j];
return s;
}
int k = 2, M = 4;
while (M < l) M <<= 1, ++k;
setwy(k);
vector<Mint> s(M);
if(sa.empty()){
for (int i = 0; i < (int)a.size(); ++i) s[i] = a[i];
fft4(s, k);
}
else{
s=sa;
}
if (a.size() == b.size() && a == b) {
for (int i = 0; i < M; ++i) s[i] *= s[i];
} else {
vector<Mint> t(M);
if(!sb.empty()){
t=sb;
}
else{
for (int i = 0; i < (int)b.size(); ++i) t[i] = b[i];
fft4(t, k);
}
for (int i = 0; i < M; ++i) s[i] *= t[i];
}
ifft4(s, k);
s.resize(l);
Mint invm = Mint(M).inverse();
for (int i = 0; i < l; ++i) s[i] *= invm;
return s;
}
static void ntt_doubling(vector<Mint> &a) {
int M = (int)a.size();
auto b = a;
intt(b);
Mint r = 1, zeta = Mint(root).pow((Mint::get_mod() - 1) / (M << 1));
for (int i = 0; i < M; i++) b[i] *= r, r *= zeta;
ntt(b);
copy(begin(b), end(b), back_inserter(a));
}
};
template< typename Mint >
vector< Mint > NumberTheoreticTransformFriendlyModInt<Mint>::dw = vector< Mint >();
template< typename Mint >
vector< Mint > NumberTheoreticTransformFriendlyModInt< Mint >::idw = vector< Mint >();
//ret[i-j]=x[i]*y[j]
template<typename Conv, typename T>
vector<T>multiply_minus(vector<T>x,vector<T>y){
reverse(y.begin(),y.end());
auto tmp = Conv::multiply(x,y);
vector<T>ret(x.size());
for(int i = 0; i < x.size(); i++){
ret[i] = tmp[y.size() - 1 + i];
}
return ret;
}
//
void solve(){
ll res=0,buf=0;
bool judge = true;
NumberTheoreticTransformFriendlyModInt<modint>::init();
ll n;cin>>n;
auto g=readGraph<int>(n,n-1);
//Graph<int>g(n);rep(i,1,n)g[i/2].EB(i);
//Graph<int>g(n);rep(i,1,n)g[0].EB(i);
Comb comb(2*n+5);
using NTT=NumberTheoreticTransformFriendlyModInt<modint>;
auto dfs=[&](auto &&f,int v,int par)->pair<vector<vector<modint>>,vector<vector<modint>>> {
auto dp0=vec(1,2,modint(0));
auto dpc=vec(1,2,modint(0));
dp0[0][0]=1;
dpc[0][1]=1;
for(auto to:g[v]){
if(to==par)continue;
auto [t0,tc]=f(f,to,v);
int dpsz=dp0[0].size(),tsz=t0[0].size();
int dpcnt=dp0.size(),tcnt=tc.size();
auto ndp0=vec(t0.size()+dp0.size(),dpsz+tsz-1,modint(0));
auto ndpc=vec(tc.size()+dpc.size(),dpsz+tsz-1,modint(0));
vector<modint>allt0(tsz);
rep(i,0,t0.size()){
rep(j,0,t0[i].size()){
allt0[j]+=t0[i][j];
}
}
auto under_fft=vector(t0.size()+1,vector<modint>());
{
auto under_tc=allt0;
rep(i,0,t0.size()+1){
under_fft[i]=NTT::ffted(under_tc,dpsz+tsz-1);
if(i<t0.size())rep(j,0,tsz)under_tc[j]+=tc[i][j];
}
}
auto over_fft=vector(t0.size()+1,vector<modint>());
{
auto over_tc=allt0;
rep(i,0,t0.size()+1){
over_fft[i]=NTT::ffted(over_tc,dpsz+tsz-1);
if(i<t0.size())rep(j,0,tsz)over_tc[j]-=t0[i][j];
}
}
//OUT(v,to,t0,tc);
rep(i,0,dp0.size()){
vector<modint>f(dpsz+tsz-1);
auto overt0=allt0;
auto under_tc=allt0;
auto dpifft=NTT::ffted(dp0[i],dpsz+tsz-1);
auto dpcfft=NTT::ffted(dpc[i],dpsz+tsz-1);
rep(j,0,t0.size()+1){
modint mult=comb.C(i+j,i)*comb.C(dpcnt+tcnt-i-1-j,tcnt-j);
{
//dp0*t0
//OUT(dp0[j],allt0);
auto f=NTT::multiply(dp0[i],under_tc,dpifft,under_fft[j]);
rep(o,0,f.size())ndp0[i+j][o]+=f[o]*mult;
if(j<t0.size())rep(o,0,tsz)under_tc[o]+=tc[j][o];
}
{
//dpc*t0
//OUT(overt0);
auto f=NTT::multiply(dpc[i],overt0,dpcfft, over_fft[j]);
rep(o,0,f.size())ndpc[i+j][o]+=f[o]*mult;
if(j<t0.size())rep(o,0,tsz)overt0[o]-=t0[j][o];
}
//OUT(v,to,i,j,mult,ndp0,ndpc);
}
}
dp0.swap(ndp0);
dpc.swap(ndpc);
int mxidx=0;
rep(i,0,dp0.size()){
rep(j,0,dp0[i].size()){
if(dp0[i][j]!=0)chmax(mxidx,j);
if(dpc[i][j]!=0)chmax(mxidx,j);
}
}
rep(i,0,dp0.size()){
dp0[i].resize(mxidx+1);//dp0[i].shrink_to_fit();
dpc[i].resize(mxidx+1);//dpc[i].shrink_to_fit();
}
//OUT(v,to,dp0,dpc);
}
return {dp0,dpc};
};
auto [dp,dc]=dfs(dfs,0,-1);
vector<modint>ret(n+1);
rep(i,0,dp.size()){
rep(j,0,dp[i].size()){
ret[j]+=dp[i][j];
ret[j]+=dc[i][j];
}
}
rrep(i,0,n){
rep(j,i+1,n+1){
ret[i]-=ret[j]*comb.C(j,i);
}
}
rep(i,1,n+1){
cout<<ret[i]<<endl;
}
OUT(ret);
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll res=0,buf=0;
bool judge = true;
int T = 1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
5 1 2 1 3 2 4 2 5
output:
28 54 38 0 0
result:
ok 5 number(s): "28 54 38 0 0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
10 6 10 5 9 10 3 9 10 7 4 4 1 3 2 3 7 8 4
output:
11540 253870 957220 1439080 737000 230090 0 0 0 0
result:
ok 10 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
10 8 4 4 7 3 1 6 10 6 4 9 10 2 5 5 6 9 1
output:
7140 204390 1027380 1597560 731880 60450 0 0 0 0
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 2 4 2 5 8 9 7 10 10 9 2 8 3 9 1 3 6 10
output:
14200 210620 1137900 1210580 811660 243840 0 0 0 0
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
9 9 8 4 1 9 1 2 7 8 5 8 7 6 5 1 3
output:
2472 34356 162036 107292 56724 0 0 0 0
result:
ok 9 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 3 8 4 7 8 6 4 6 6 10 9 1 3 2 4 5 9 10
output:
8800 148400 1210800 1396880 798640 65280 0 0 0 0
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
15 14 9 7 13 7 8 3 6 1 15 4 15 7 11 8 1 2 7 14 8 15 5 10 6 2 10 12 1
output:
56289600 967779134 923981730 96060068 10686262 235209478 265673053 195831107 217488197 0 0 0 0 0 0
result:
ok 15 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
15 6 9 10 12 6 10 7 15 9 7 8 15 4 12 11 1 13 6 2 9 3 12 1 3 9 14 7 5
output:
31011120 397655661 546345792 817109204 257395717 479471757 323343241 216283820 898626670 0 0 0 0 0 0
result:
ok 15 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
15 9 3 9 5 9 6 11 15 5 11 4 14 1 15 2 1 13 14 8 1 9 7 7 14 10 2 12 2
output:
7023120 201832948 304836830 97923512 115869813 704294252 680848885 806741309 252218772 795653541 0 0 0 0 0
result:
ok 15 numbers
Test #10:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
14 5 4 3 7 9 4 3 8 10 9 1 2 10 7 4 11 14 2 5 1 2 12 4 13 6 11
output:
1277136 187034232 817102492 231238823 482826933 368166096 908219189 329900647 0 0 0 0 0 0
result:
ok 14 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
15 9 12 1 9 13 10 7 4 11 6 7 3 14 1 11 3 15 14 11 10 2 10 5 12 1 13 12 8
output:
9790200 299361307 878733115 457013044 633916410 202070873 627253395 427436036 431668602 0 0 0 0 0 0
result:
ok 15 numbers
Test #12:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
30 21 17 4 6 30 28 12 19 3 6 18 11 5 17 13 30 3 27 5 28 7 30 3 25 3 7 27 24 4 16 20 26 30 1 5 9 9 2 23 12 13 20 17 19 22 14 18 20 17 14 11 29 10 27 15 23 11 8
output:
476665504 833146853 594913132 343840733 858440316 821830796 654815681 964050488 845418488 904523186 295267527 167669554 262061667 391216026 785126836 458297537 593077098 789556990 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 30 numbers
Test #13:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
30 13 21 15 29 9 3 22 8 3 15 15 25 14 8 19 8 24 27 28 4 12 27 8 18 28 25 24 25 8 9 21 5 7 17 11 23 11 16 3 11 26 10 10 16 8 7 11 20 27 21 26 30 15 6 1 6 2 28
output:
249311566 811045480 794072210 750170140 651800148 196077467 477989528 572918836 242191488 523238077 544740575 334825331 251208738 982415005 179148017 25972277 259519791 198540679 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 30 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
30 10 11 7 29 9 30 4 12 20 18 30 15 3 30 18 16 23 1 22 6 29 25 29 5 16 14 25 27 15 13 24 5 14 22 23 5 1 19 2 11 7 15 26 29 12 21 26 14 12 20 15 28 27 10 17 26 8 26
output:
951802166 75337913 968695388 666501385 268553896 268591487 700091004 819234540 144322774 215302608 21960660 240875748 383482009 549084481 792698573 853681515 56586856 68382350 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 30 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
29 5 13 18 19 7 2 10 16 2 3 28 22 17 14 25 29 14 8 27 17 9 6 15 11 7 20 8 1 15 12 13 18 9 26 10 23 10 5 17 7 9 24 10 17 21 29 22 1 16 24 4 28 20 21 20 11
output:
183093936 736732472 832827292 220921133 411064273 11608335 442961727 541248342 443664563 614435954 805482321 716726563 537008113 6091735 691949655 359540208 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 29 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
30 1 17 27 23 2 19 28 7 17 22 20 23 9 27 9 5 11 13 7 24 9 11 13 28 16 9 8 3 22 16 29 16 8 24 22 18 22 14 10 11 13 6 4 18 21 9 25 28 17 12 16 30 27 15 24 2 26 24
output:
808671184 292518367 616199530 559639988 739602615 50200053 943966753 160098660 786551596 68220094 4828146 85859498 850152734 502065476 849914909 707591022 19104728 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 30 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
30 2 1 3 1 1 4 4 5 6 5 4 7 8 6 9 8 9 10 9 11 9 12 11 13 14 11 12 15 13 16 15 17 18 17 19 16 19 20 20 21 19 22 22 23 22 24 22 25 26 24 24 27 28 26 29 26 27 30
output:
797780008 686571598 512601217 172589162 229077536 547622293 778878933 995407067 370565763 781815547 856193170 12039270 113119304 865952842 482288625 709423510 10626583 120877278 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 30 numbers
Test #18:
score: 0
Accepted
time: 3ms
memory: 3840kb
input:
70 48 32 5 25 9 43 42 18 13 35 32 28 17 66 53 36 21 52 47 17 20 34 67 13 34 40 52 36 49 50 11 66 30 32 44 43 20 51 47 56 6 66 11 24 69 50 39 19 11 30 9 62 18 21 68 34 69 39 28 10 14 24 4 30 67 47 44 6 66 22 65 1 42 16 59 8 12 50 32 45 24 60 46 17 69 8 43 41 33 61 27 2 22 2 8 67 60 52 55 15 13 61 37 ...
output:
943526961 320961617 166604850 701811460 389268693 738553375 215044618 451762417 891005935 810701751 125288699 585534137 985892828 931011067 707058487 7650954 536390154 943272279 709112563 723959681 929197521 402121766 553250601 260050045 712455754 1522617 370081754 452796510 644890353 36138167 57584...
result:
ok 70 numbers
Test #19:
score: 0
Accepted
time: 4ms
memory: 3712kb
input:
70 55 32 44 27 40 6 52 42 39 67 56 64 21 43 7 48 62 59 1 26 31 13 44 1 18 39 15 64 46 48 28 5 12 47 39 19 30 66 43 56 37 22 4 26 2 40 9 2 34 12 18 15 18 6 28 68 30 40 37 31 30 57 24 52 43 47 22 15 20 29 47 62 18 10 2 70 61 12 47 28 1 52 23 38 58 16 4 49 49 28 57 3 23 24 15 17 70 16 51 8 31 69 60 29 ...
output:
25910015 163992214 232378033 119711775 187475131 195677641 426749502 361226824 176083776 463491958 727433469 889576680 332436759 809785997 718639576 39870971 540913995 428104678 799845288 976730249 521491333 365953390 479106938 328510082 604649102 755282530 253636597 836671759 332287833 682395480 50...
result:
ok 70 numbers
Test #20:
score: 0
Accepted
time: 2ms
memory: 3712kb
input:
69 63 5 59 5 4 15 52 14 57 60 7 34 9 68 33 62 62 31 59 27 29 60 64 58 63 39 27 30 1 39 55 62 69 47 68 17 6 46 26 1 50 25 35 56 37 46 59 12 30 2 35 24 19 16 64 21 51 43 55 41 37 58 55 16 41 67 7 11 35 66 28 58 13 17 54 32 3 44 67 21 54 68 42 1 35 4 23 69 39 8 53 61 23 10 27 52 54 35 59 46 43 53 34 46...
output:
433178845 749347039 483550824 961302408 490763456 38943809 258235571 249129284 529624467 919699700 478839438 51132901 227139138 693529588 232856595 372323915 931822866 275207593 647509343 892538620 833150204 409551669 583012730 465413566 580934706 626121538 241910322 407826554 329925651 11988244 568...
result:
ok 69 numbers
Test #21:
score: 0
Accepted
time: 3ms
memory: 3840kb
input:
70 16 59 15 31 4 36 1 16 68 9 64 23 52 25 51 25 27 9 7 44 49 65 35 37 21 26 32 4 33 37 69 7 58 62 41 44 54 30 19 21 45 12 13 44 51 33 64 33 10 16 69 64 24 16 5 61 58 69 38 11 69 30 45 18 9 24 56 35 1 51 40 13 6 69 3 40 20 46 50 64 61 68 49 29 22 58 15 63 68 55 70 23 29 22 70 42 35 14 21 17 66 1 22 1...
output:
913892556 512515359 307932596 208166439 923812488 787814883 926522725 861402576 943667618 243713276 714542402 21996395 555468493 726536623 346707943 782684467 820344669 880144284 606053876 228354729 25060139 991208882 163764214 614834489 971165918 436603249 472900353 884414168 364542656 330974777 32...
result:
ok 70 numbers
Test #22:
score: 0
Accepted
time: 2ms
memory: 3840kb
input:
70 2 1 3 1 3 4 3 5 6 3 7 6 8 6 9 7 10 7 10 11 12 11 10 13 13 14 15 13 13 16 17 15 18 17 17 19 17 20 21 18 21 22 23 22 21 24 25 22 26 25 27 24 28 26 27 29 30 28 28 31 32 31 30 33 34 33 35 32 36 33 34 37 35 38 39 38 38 40 39 41 41 42 43 40 41 44 42 45 45 46 45 47 45 48 49 46 50 48 48 51 52 50 53 50 54...
output:
770169934 954555437 202257555 347334878 830323432 768480462 270384736 663728843 213556185 822256151 64172800 679424659 434554033 132510570 315113252 187753192 669137644 184968401 682886109 217514370 981985189 19129665 347549366 96071198 773619812 940957399 146067192 241287331 513595468 194094689 270...
result:
ok 70 numbers
Test #23:
score: 0
Accepted
time: 4ms
memory: 3968kb
input:
70 63 48 17 68 8 15 31 51 23 9 19 27 10 2 51 53 56 5 59 7 42 14 36 45 58 41 24 52 70 21 29 42 16 40 35 38 51 57 50 24 54 29 47 20 36 41 51 70 51 12 32 23 68 51 28 11 19 43 58 55 61 35 6 69 65 10 38 32 5 25 42 67 45 10 43 68 64 54 36 9 13 11 3 56 43 58 45 64 69 42 46 69 70 25 49 53 3 59 25 34 9 44 62...
output:
264422203 259298436 524867369 934958379 512456582 915748464 236380955 958526478 624343335 46856122 857595835 988798351 913132871 742485039 771978513 861720636 383944358 713516744 979650053 426134061 462415499 160845205 625982509 264284599 857319056 336185780 669646687 739448821 735484325 401233653 2...
result:
ok 70 numbers
Test #24:
score: 0
Accepted
time: 951ms
memory: 7808kb
input:
499 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 52 52 53 5...
output:
154029661 845001665 588557122 331004513 87119293 243589628 266481846 147445671 723892377 953399570 23874206 699082355 636337437 324612961 626615378 446859683 694059168 787587513 149004470 635734612 621444756 210884890 779365620 551506117 15704724 403748771 906444429 246784225 846106948 640128219 739...
result:
ok 499 numbers
Test #25:
score: 0
Accepted
time: 939ms
memory: 7680kb
input:
498 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 52 52 53 5...
output:
576137007 698536 705959869 459350169 613887621 376422552 900328015 918425372 851033096 643279868 515045927 107782280 474198026 593065562 958399880 98812746 600959826 162247473 259978802 763053996 89480037 867722997 92715192 529872829 910853989 935119642 95654181 955573778 151180755 97383478 30815805...
result:
ok 498 numbers
Test #26:
score: 0
Accepted
time: 721ms
memory: 6912kb
input:
449 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 52 52 53 5...
output:
751815647 426017185 189946231 837605210 831032354 558518285 609712385 770376473 693334904 134936351 532982601 250533254 139517032 523182123 20943426 27206945 383519608 556767776 27517590 500413486 826823026 418022166 434103911 995245814 561462243 103918631 698821468 459687218 593594456 251057760 800...
result:
ok 449 numbers
Test #27:
score: 0
Accepted
time: 524ms
memory: 6656kb
input:
398 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 52 52 53 5...
output:
816865800 985467713 971327665 632395692 196446727 434030679 627560633 627485844 690518955 454995971 243792985 450549538 100043661 886174999 104714586 987473276 24532275 653353159 139211535 243040095 979920292 162798353 813215115 604552457 213219564 149285135 67591743 54703787 644578633 662367371 938...
result:
ok 398 numbers
Test #28:
score: 0
Accepted
time: 77ms
memory: 4608kb
input:
205 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 52 52 53 5...
output:
753130417 109881001 685399927 861559523 151807032 22067972 614582330 316790429 378783717 575992167 91660065 720021539 865352199 971813962 435797246 865719812 619611866 937412322 908785703 927403083 612136223 897290670 901657475 401254407 359043429 459501291 47347742 420861174 906213402 353842071 581...
result:
ok 205 numbers
Test #29:
score: 0
Accepted
time: 273ms
memory: 5888kb
input:
317 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 52 52 53 5...
output:
537692343 70332772 131269515 673005701 470271276 733808699 437387223 925852785 517665139 598305587 815114704 735338355 630639875 169905755 142417305 877665425 232910454 933440866 86065313 658117379 740478559 66328597 653130205 664013451 540141148 375663590 811732978 974656532 822687271 842318519 648...
result:
ok 317 numbers
Test #30:
score: 0
Accepted
time: 67ms
memory: 4480kb
input:
195 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 52 52 53 5...
output:
77748471 398477838 589876897 629903989 552184816 787052062 874959254 688197019 964544174 66654714 385501062 703342362 923033837 26511983 988277234 187746498 191143482 840098727 119964152 811499910 309252543 763245158 468083088 423007512 670157523 205395175 724354927 254415808 210586892 252761012 319...
result:
ok 195 numbers
Test #31:
score: 0
Accepted
time: 34ms
memory: 4224kb
input:
150 116 71 34 7 65 101 5 46 111 13 137 101 1 55 44 21 38 41 106 137 78 59 100 46 35 28 124 1 89 91 19 68 18 99 138 3 69 84 121 51 86 148 96 8 136 114 78 10 45 59 62 111 17 121 76 133 128 57 10 82 45 22 82 14 62 54 9 12 147 75 93 118 66 100 77 36 48 84 13 108 115 89 29 98 150 99 54 39 2 16 24 104 62 ...
output:
221296425 233619510 597093928 590289712 520646361 398787779 484565637 451952423 966808834 186744490 419775993 552896963 156815267 588385113 462237525 747539400 791215426 62461466 329133131 749412389 946770150 966106474 801575459 480097895 759451763 96057697 309781826 691936385 16597521 943612018 664...
result:
ok 150 numbers
Test #32:
score: 0
Accepted
time: 29ms
memory: 4224kb
input:
150 61 85 45 79 111 108 96 19 76 12 127 104 82 1 117 31 109 57 23 101 51 36 74 137 144 123 34 15 144 53 60 124 98 106 114 45 39 66 54 4 8 37 108 56 58 96 118 43 62 135 127 134 67 123 31 42 10 32 12 105 135 8 16 75 103 119 68 146 18 14 84 117 35 109 54 136 135 50 28 9 148 6 94 42 74 113 79 148 56 13 ...
output:
713725525 805562334 96433020 546123807 550691934 597527928 6533268 108784302 346228487 668175131 725745656 308268308 531991783 504805897 823191919 88577010 559908403 373437029 643168298 582685816 738472610 829730996 92704611 527426356 551119256 512680311 249734977 802231938 430120193 835729579 72788...
result:
ok 150 numbers
Test #33:
score: 0
Accepted
time: 34ms
memory: 4096kb
input:
149 97 65 112 85 97 21 38 85 32 58 4 94 46 87 24 97 96 149 79 95 40 132 112 82 149 34 65 86 114 16 149 68 116 118 61 4 114 38 139 21 55 87 116 79 84 105 107 94 97 142 28 121 112 134 144 41 60 109 114 20 140 7 15 95 136 105 120 31 95 57 36 67 98 131 69 98 95 102 109 7 90 1 82 124 95 30 81 47 7 84 75 ...
output:
98042867 96892318 375476331 826808672 387356478 182904951 224552511 300909834 67785767 440277040 630023108 621935275 500093521 693308446 637811355 460126499 782411882 191034277 114291640 20098658 552825174 692896813 21273264 935546769 696524278 370374643 992604036 460222526 768855555 296709495 79758...
result:
ok 149 numbers
Test #34:
score: 0
Accepted
time: 36ms
memory: 4224kb
input:
150 67 64 16 91 106 96 83 97 6 66 53 64 70 17 97 76 6 112 14 1 37 52 42 78 118 139 97 125 5 62 50 33 81 107 42 116 129 42 63 32 103 124 143 34 23 85 133 35 132 15 117 82 70 27 29 66 142 57 33 49 79 31 146 12 136 126 65 97 64 131 88 145 102 30 150 9 41 8 69 92 66 126 143 128 144 93 40 27 12 65 131 97...
output:
862895765 456420712 402639020 89112608 995034647 608820005 960561754 120569939 231419101 990088535 848221961 910262651 930666128 527873138 347606922 469727448 814427204 644774591 489780107 639337324 629765393 695760351 536267340 159127690 102994880 377510967 123705146 521753217 395619906 902275239 2...
result:
ok 150 numbers
Test #35:
score: 0
Accepted
time: 25ms
memory: 4224kb
input:
150 2 1 1 3 3 4 5 2 6 4 6 7 6 8 8 9 7 10 11 10 9 12 10 13 14 12 13 15 13 16 16 17 18 15 16 19 20 18 21 18 19 22 23 20 22 24 25 24 26 25 27 25 27 28 27 29 30 28 31 28 29 32 33 30 33 34 34 35 36 33 37 34 38 36 39 37 38 40 40 41 42 39 40 43 44 42 44 45 46 43 47 46 48 46 49 46 49 50 51 48 52 50 52 53 52...
output:
920670062 463733942 472140513 386651320 175691980 779851065 972743419 650713153 164206870 690737598 81968990 395149724 99382252 586595508 489378741 783502764 517111220 246324086 47612930 773952049 323656923 176968903 301570017 467644419 59081691 49338463 448048355 90082381 753381881 189847025 747786...
result:
ok 150 numbers
Test #36:
score: 0
Accepted
time: 42ms
memory: 3968kb
input:
150 36 119 42 147 121 60 72 65 69 11 91 4 46 55 39 129 19 136 112 110 147 86 73 84 126 65 98 33 95 111 13 123 101 59 5 42 51 141 64 35 129 101 136 122 119 140 115 27 1 149 77 93 85 143 16 21 107 114 115 18 56 135 133 25 38 51 52 69 102 12 34 56 74 25 36 11 8 105 82 94 32 92 51 144 62 106 51 57 103 2...
output:
850082776 26004871 338267392 751281655 138411800 883677482 879611326 79151046 600215417 244678741 534465903 12453393 959482755 578220125 493219092 852056214 140518474 465654507 482847096 252282939 128985349 205480431 318675845 692762577 866275797 136996062 175465110 512401807 673518901 890548146 384...
result:
ok 150 numbers
Test #37:
score: 0
Accepted
time: 33ms
memory: 4480kb
input:
150 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 52 52 53 5...
output:
863397297 563570776 698316583 440383599 991396522 763829634 23113903 491282516 312338255 649052955 767053627 955088494 935433077 235695296 840027517 835088017 95680139 128426743 911697339 58888643 136149623 665701675 849916677 743050511 301268970 866071625 497117417 770475232 505934278 730317443 895...
result:
ok 150 numbers
Test #38:
score: 0
Accepted
time: 31ms
memory: 3840kb
input:
150 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 53 27 54 27 5...
output:
795549660 575116415 34771012 784418026 567016119 962178455 356109035 805358863 230506273 15689356 285843982 826705870 997188588 568990161 688127903 930740453 788088247 197589842 390445164 105719055 190866841 472055214 129652900 500774519 153294491 277517303 9666229 791923011 721258429 727084906 6832...
result:
ok 150 numbers
Test #39:
score: 0
Accepted
time: 28ms
memory: 3840kb
input:
150 1 2 3 2 4 1 1 5 6 5 7 5 8 6 9 7 10 7 3 11 12 6 13 3 14 2 15 2 16 10 6 17 18 7 19 15 20 1 5 21 10 22 10 23 24 1 3 25 1 26 27 3 28 24 8 29 30 1 19 31 32 5 33 16 34 23 21 35 24 36 37 31 38 15 12 39 29 40 2 41 42 18 26 43 29 44 4 45 18 46 47 45 35 48 49 35 50 11 34 51 17 52 34 53 54 14 55 15 37 56 5...
output:
477892339 861107133 91499080 18411298 828050894 925278484 138752131 923950221 694917313 62650040 13353244 783106978 159036537 611695535 525448272 927188500 758881145 332461574 906090868 263018229 824205178 740612904 97994176 425045475 460658948 881189832 902324169 743475670 1454614 491700138 9382768...
result:
ok 150 numbers
Test #40:
score: 0
Accepted
time: 25ms
memory: 4224kb
input:
150 2 1 3 1 2 4 5 3 3 6 4 7 8 7 9 7 10 7 10 11 9 12 10 13 14 13 15 13 16 14 17 16 15 18 16 19 20 17 20 21 22 19 21 23 23 24 25 22 25 26 26 27 28 27 28 29 27 30 31 30 30 32 33 30 32 34 32 35 33 36 37 34 37 38 39 36 39 40 38 41 40 42 40 43 43 44 45 43 45 46 46 47 45 48 49 48 47 50 51 49 51 52 53 50 54...
output:
392650722 592029195 112331471 474015453 836899789 119059153 643097913 968773580 203367894 260515872 362187408 180805394 320775982 233905889 334788497 544076554 446302051 858931094 165682096 313555562 755816689 829847569 896736777 545716931 968232429 380436982 85523190 910186860 638752557 984428996 9...
result:
ok 150 numbers
Test #41:
score: 0
Accepted
time: 1104ms
memory: 6400kb
input:
500 223 142 220 10 470 426 370 270 80 297 332 12 420 84 452 154 33 84 500 189 454 67 483 192 218 366 83 337 496 101 393 196 380 236 1 453 442 114 220 245 363 248 26 72 217 263 91 243 65 315 122 455 120 210 263 31 47 327 407 170 253 195 189 471 349 239 393 107 159 217 274 288 261 141 351 381 425 394 ...
output:
217468707 22882298 552814381 336641701 280982427 4518558 286600491 327908926 71236802 607480516 341144934 145652523 357795122 880648080 593855033 155591372 115979568 572282817 201023943 910037699 38519375 783989147 687331830 145029114 553765411 214029311 211398637 151704968 11990592 772349877 445702...
result:
ok 500 numbers
Test #42:
score: 0
Accepted
time: 1113ms
memory: 7748kb
input:
500 49 314 6 110 398 255 250 143 80 120 61 292 417 235 191 290 380 326 206 145 400 166 71 34 80 323 293 137 374 336 433 119 457 463 492 403 275 361 249 347 275 384 90 403 172 490 407 188 5 407 344 158 206 49 22 26 243 13 218 279 433 419 109 421 318 170 427 444 229 363 380 455 265 267 320 300 162 483...
output:
17917287 959921372 757861805 763547231 789925395 832660373 706850355 850297107 471930799 635626657 585991391 145308342 445793537 654485112 210465545 926834850 940662817 694429408 531996987 383765155 455430586 112385468 26168862 697668300 849419501 662404053 711156391 896540974 520045392 414621739 53...
result:
ok 500 numbers
Test #43:
score: 0
Accepted
time: 1313ms
memory: 7808kb
input:
499 13 465 190 132 384 96 199 193 261 10 379 62 61 365 280 331 186 314 406 117 475 232 497 458 2 446 150 87 211 51 216 174 97 292 425 454 374 478 273 439 359 188 357 111 166 477 332 185 187 313 195 200 260 86 89 144 319 303 400 355 138 106 402 455 267 30 33 437 389 153 331 13 149 45 307 44 11 306 20...
output:
895081361 103555181 578866162 490597126 665816135 309192356 60263574 444439210 638493658 785464101 192641111 321491623 169363877 361407501 475788144 66102833 242889663 503706375 938588358 927055504 282861522 260355268 753910201 725284774 200220281 773496080 422470654 963799110 460009349 420706288 13...
result:
ok 499 numbers
Test #44:
score: 0
Accepted
time: 871ms
memory: 7840kb
input:
500 141 365 363 324 356 85 389 336 6 238 287 80 18 383 332 260 77 216 44 256 216 164 411 306 13 252 439 341 478 432 337 95 120 78 238 320 201 144 184 292 2 228 129 197 455 115 314 163 425 250 492 417 436 314 127 120 308 337 148 112 407 15 77 58 397 84 319 87 86 291 228 154 48 126 473 469 268 468 95 ...
output:
145232419 459607844 882409319 453400253 886017870 679552878 302881182 901761962 374895433 911415295 471870649 939637572 762322883 289001565 449776769 923787798 100003097 647930805 716275914 670127560 513881741 193828867 529043666 358701046 136492841 605728655 696243956 449115719 962661510 794022549 ...
result:
ok 500 numbers
Test #45:
score: 0
Accepted
time: 866ms
memory: 8196kb
input:
500 2 1 1 3 2 4 5 3 3 6 4 7 5 8 6 9 10 7 9 11 9 12 12 13 14 12 15 14 15 16 16 17 16 18 18 19 18 20 20 21 19 22 21 23 24 23 25 23 26 23 24 27 28 26 29 28 27 30 30 31 32 29 33 32 33 34 35 34 36 35 37 36 38 36 36 39 40 37 41 40 42 40 43 42 44 41 42 45 46 43 46 47 48 46 47 49 50 49 50 51 52 49 52 53 52 ...
output:
876027314 791187132 110224056 814416850 531135568 159208865 303931590 71739249 544912755 305431690 485489903 976186361 44537910 564902229 873939344 404043704 986777826 355382783 122787087 182101691 882765307 485345622 360241953 417874086 672561454 400183801 510098036 725729495 200897606 897527447 85...
result:
ok 500 numbers
Test #46:
score: 0
Accepted
time: 1156ms
memory: 7916kb
input:
500 181 10 284 460 393 104 23 484 116 224 412 208 256 416 341 291 43 140 104 169 132 469 51 344 74 29 484 472 219 91 20 304 212 413 321 125 99 113 316 104 23 304 321 98 78 46 95 53 91 83 2 85 427 311 186 136 27 361 219 417 122 384 123 471 470 381 431 252 12 27 77 393 87 134 379 307 309 383 145 205 3...
output:
442132840 381735235 564742071 197584134 774494395 692387618 628894613 323167552 642633794 277146534 633096180 777103809 421672236 340066918 446533332 174322775 954514168 627796810 369172460 559242495 218649588 652690914 211164304 184240408 533221594 696704846 67890756 514651069 849685816 499126293 6...
result:
ok 500 numbers
Test #47:
score: 0
Accepted
time: 947ms
memory: 7680kb
input:
500 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 52 52 53 5...
output:
308059322 227229598 394807253 909658943 13339434 690533221 816673242 101053296 541241898 630195210 961112458 239005104 920695145 259114263 317750216 351232439 137409107 402710500 754120929 434480438 98652665 416793626 246073764 971430956 504912834 111220008 231247384 827992380 923791110 112046367 61...
result:
ok 500 numbers
Test #48:
score: 0
Accepted
time: 1161ms
memory: 6400kb
input:
500 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 53 27 54 27 5...
output:
294336027 437832300 519483074 982615151 15818066 491618823 465583446 449848895 872971689 572808711 742935802 389753733 760747549 398469764 679250782 135239691 69069598 927593865 626348276 390112480 80782402 478791565 5197565 441974308 986625339 225513524 787759480 8289761 583074080 606521687 2559300...
result:
ok 500 numbers
Test #49:
score: 0
Accepted
time: 969ms
memory: 6272kb
input:
500 2 1 3 2 3 4 5 3 2 6 3 7 4 8 8 9 1 10 11 8 12 2 13 12 5 14 15 1 16 14 17 10 13 18 19 4 16 20 4 21 22 6 23 18 24 11 25 14 26 10 27 11 12 28 6 29 25 30 31 20 32 27 10 33 6 34 35 13 33 36 10 37 29 38 39 25 40 8 32 41 42 10 16 43 32 44 45 7 46 24 47 18 48 17 45 49 48 50 9 51 52 50 10 53 4 54 43 55 56...
output:
72331769 535169926 296603778 77102923 578734754 476460133 204417994 991329592 226336955 621836253 927852434 835305794 221425855 857159110 562595989 319893451 68968661 404101073 746361022 878847981 563947179 557615929 122210650 239531991 849912704 937810764 556587192 938758670 794667871 56898215 8918...
result:
ok 500 numbers
Test #50:
score: 0
Accepted
time: 845ms
memory: 8180kb
input:
500 1 2 2 3 4 3 5 4 6 5 7 4 8 5 7 9 10 9 11 8 12 11 12 13 14 11 15 12 13 16 17 16 18 15 16 19 19 20 18 21 22 19 21 23 24 21 24 25 23 26 27 24 26 28 27 29 30 27 30 31 32 31 33 31 34 32 33 35 34 36 37 34 38 36 38 39 39 40 41 40 40 42 43 40 43 44 42 45 44 46 47 44 45 48 49 48 50 49 50 51 50 52 53 50 54...
output:
957776375 244098521 938898741 75219269 204000187 919617087 669647280 107079588 21309585 877266187 683594694 488790722 924604695 696048432 497925808 161970944 321692786 206207566 44881904 872758838 808717148 636187153 914587795 421255208 642432271 489601215 462706575 748018339 491285812 236036082 495...
result:
ok 500 numbers
Extra Test:
score: 0
Extra Test Passed