# [examination summary] noip simulation 33

Time：2021-11-30

Two bombings in a row…

The first question is to sit down because of expectations, and then skip…

Then the second topic found that the topic was very around, and then transformed the meaning of a sentence, and then…..

$$\ huge {\ text {wrong conversion!!!!!}$$

However…

$$\ huge {\ text {sample passed!!!}}$$

What is it?

Then there is$$9pts$$ 。。。

then$$T3$$Hit a maximum spanning tree that you think is false.

Then the complete graph has not been judged correctly, resulting in….

only$$10pts$$

If you do this again, you will really be turned over….

# Hunter

Another conclusion.

In fact, there is no need to regret after seeing the solution

This is really not easy to push out.

Although the idea is very simple.

$ans = \sum_{i=2}^{n}\frac{w_i}{w_1 + w_i} + 1$

Then three lines of code….

#include
typedef long long ll;const ll mod = 998244353; ll n,w[1000001],ans = 1;inline ll ksm(ll x,ll y) {register ll ret = 1; while(y) {if(y & 1) ret = ret * x % mod;x = x * x % mod; y >>= 1;} return ret;}
signed main() {std::cin >> n >> w[1]; for(ll i=2;i<=n;++i) std::cin >> w[i],(ans += w[i] * ksm(w[1] + w[i],mod-2) % mod) %= mod; std::cout<

I’m not lying to you, just three lines.

# Defence

The meaning of this topic is not to make you beg$$0$$Number of!!!!

But for the longest continuity$$0$$Number of….

Then it’s obvious that you can merge segment trees….

Like a board….

A batch of water….

#include
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
namespace xin_io
{
#define debug cout<inline xin_stream &operator >> (type &x)
{
register type s = 0; register int f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return x = s * f,*this;
}}io;
}
using namespace xin_io; static const int maxn = 1e5+10,inf = 1e9+7,mod = 998244353; const ll llinf = 1e18+7;
namespace xin
{
class xin_edge{public:int next,ver;}edge[maxn];
int root[maxn],tot;
class xin_segment
{
private:
#define ls(fa) (t[fa].lson)
#define rs(fa) (t[fa].rson)
inline void up(int fa)
{
t[fa].size = t[ls(fa)].size + t[rs(fa)].size;
t[fa].s = std::max(t[ls(fa)].s , t[rs(fa)].s);
if(t[rs(fa)].lpos and t[ls(fa)].rpos) t[fa].s = std::max(t[fa].s,t[rs(fa)].lpos - t[ls(fa)].rpos - 1);
if(!t[rs(fa)].rpos) t[fa].rpos = t[ls(fa)].rpos; else t[fa].rpos = t[rs(fa)].rpos;
if(!t[ls(fa)].lpos) t[fa].lpos = t[rs(fa)].lpos; else t[fa].lpos = t[ls(fa)].lpos;
}
public:
class xin_tree{public:int s,lson,rson,lpos,rpos,size;}t[maxn * 32];
void insert(int &fa,int l,int r,int pos)
{
if(!fa) fa = ++tot;
if(l == r) {t[fa].lpos = t[fa].rpos = l; t[fa].size = 1; return ;}
register int mid = l + r >> 1;
if(pos <= mid) insert(ls(fa),l,mid,pos); else insert(rs(fa),mid+1,r,pos);
up(fa);
}
int merge(int x,int y,int l,int r)
{
if(!x or !y) return x | y;
if(l == r) return x;
register int mid = l + r >> 1;
ls(x) = merge(ls(x),ls(y),l,mid); rs(x) = merge(rs(x),rs(y),mid+1,r);
up(x);
return x;
}
}t;
int n,m,qnum;
int ans[maxn];
void dfs(int x)
{
asm(i,x)
{
register int y = edge[i].ver;
dfs(y);
root[x] = t.merge(root[x],root[y],1,m);
}
if(!t.t[root[x]].size) ans[x] = -1;
else ans[x] = std::max(t.t[root[x]].s,t.t[root[x]].lpos - 1 + m - t.t[root[x]].rpos);
}
inline short main()
{
io >> n >> m >> qnum;
try(i,1,n-1)
{
register int x,y; io >> x >> y;
}
try(i,1,qnum)
{
register int x,y; io >> x >> y;
t.insert(root[x],1,m,y);
}
dfs(1);
try(i,1,n) printf("%d\n",ans[i]);
return 0;
}
}
signed main() {return xin::main();}

# Connect

The first intuition of this topic is to find a maximum spanning tree and subtract it from the total price

Then it’s fake, and you can pass the sample.

then$$10pts$$End….

We can consider the pressure because we found this$$n$$The scope of is very small.

Then enumerate subsets of the complement, which is a good transfer..

%: pragma GCC optimize("O3","Ofast","inline")
#include
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
namespace xin_io
{
#define debug cout<inline xin_stream &operator >> (type &x)
{
register type s = 0; register int f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return x = s * f,*this;
}}io;
}
using namespace xin_io; static const int maxn = 15,inf = 1e9+7,mod = 998244353; const ll llinf = 1e18+7;
namespace xin
{
int sum[1<> n >> m;
try(i,1,m)
{
register int x,y,z; io >> x >> y >> z;
dis[x-1][y-1] = dis[y-1][x-1] = z;
}
try(i,1,(1 << n) - 1)try(j,0,n-1)try(k,j+1,n-1)
if(((i >> j) & 1) and ((i >> k) & 1))
sum[i] += dis[j][k];
memset(f,-0x3f,sizeof (f));
//		try(i,0,(1<

## Subtype Polymorphism and the LSP Principle

Java programmers often use the polymorphism of objects to call the right method in the right place, which is amazing. This method is implemented through the inheritance mechanism. However, a rigorous experiment can make this clear and reveal that it is more appropriate to understand polymorphism as a type-related concept than an explanation of inheritance […]