某古 9 月月賽 I 遊記

2022-03-30 08:28:04 字數 3216 閱讀 7658

目錄b [cnoi2020]雷雨

c [cnoi2020]夢原

d [cnoi2020]線形生物

小結由於部落格已經估了好久沒寫了,所以跑來水更篇部落格。

第一次 ak div2 ,莫名感動。

這題難道有比 sam 還簡單的方法???

越短的串出現次數才可能會越多,直接統計每個字元出現的次數,輸出最大值即可。

#include#include#include#include#includeusing namespace std;

#define ch() getchar()

#define pc(x) putchar(x)

templateinline void read(t&x)

templateinline void write(t x)

const int maxn=10000007;

char s[maxn];int cnt[26];

int main()

templateinline void write(t x)

const int maxn=1005;

struct node

bool operator < (const node o)const

void pop(void) }}

int main()

艹,怎麼有人出和我一樣的屑題啊。

考慮加入乙個點會造成什麼樣的貢獻,如果它的 \(a\) 比它父親的 \(a\) 值要小,那麼在減小它父親的 \(a\) 的時候就可以順便減小它自己的 \(a\) ,否則就會增加它們兩個差的使用次數。

設 \(i\) 的父親可以選擇的集合為 \(s\) ,那麼 \(i\) 對答案造成的貢獻就是:

\[\dfrac(s)}\sum_\max(0,a_i-a_x)=\dfrac(s)}\sum_(a_i-a_x)[a_i\ge a_x]

\]相當於就是要求 \([i-k,i-1]\cap n^+\) 中 \(a\) 值比 \(a_i\) 小的數的個數和這些數 \(a\) 值的和,樹套樹可能過不了,離線後可以使用樹狀陣列差分求答案。

時間複雜度: \(\mathcal o(n\log_2n)\) 。

#include#include#include#include#includeusing namespace std;

#define ch() getchar()

#define pc(x) putchar(x)

templateinline void read(t&x)

templateinline void write(t x)

const int maxn=1000006,mod=998244353;

int mo(const int x)

int rt[maxn],tr[maxn],cnt;

void change(int pos,int val)

}int rt;

int query(int pos)

return re;

}struct edge

}e[maxn*2];

int hd[maxn],num;

void qwq(int u,int v,int id)

int a[maxn],a[maxn],inv[maxn],sum[maxn],mus[maxn];

int main()

for(int i=1;i<=n;++i)

} for(int i=2;i<=n;++i)

write(ans),pc('\n');

return 0;

}

設 \(e_i\) 表示從 \(i\) 走到 \(n+1\) 的期望步數,設 \(i\) 的到達集合為 \(s\) ,那麼有:

\[e_i=1+\dfrac(s)}\sum_e_j

\]不妨設 \(e_i=a_ie_1+b_i\) ,那麼顯然可以從 \(a_1,b_1\) 一直推出 \(a_,b_\) ,那麼 \(a_e_1+b_=e_=0\) ,所以 \(e_1=-\dfrac}}\) 。

具體如何推,不妨設 \(i\) 通過返祖邊到達的集合為 \(s^\) ,那麼:

\[e_i=1+\dfrac(s^)+1}(e_+\sum_}e_j)

\]\[e_=(\operatorname(s^)+1)(e_i-1)-\sum_}e_j

\]\[e_=e_1\times (a_i(\operatorname(s^)+1)-\sum_}a_j)+(\operatorname(s^)+1)(b_i-1)-\sum_}b_j

\]\[a_=a_i(\operatorname(s^)+1)-\sum_}a_j

\]\[b_=(\operatorname(s^)+1)(b_i-1)-\sum_}b_j

\]

#include#include#include#include#includeusing namespace std;

#define ch() getchar()

#define pc(x) putchar(x)

templateinline void read(t&x)

templateinline void write(t x)

const int maxn=1000005,maxm=1000005,mod=998244353;

int mo(const int x)

int power(int a,int x)

return re;

}int d[maxn];

struct edge

}e[maxm];

int hd[maxn],num,a[maxn],b[maxn];

void qwq(int u,int v)

int main()

a[1]=1,b[1]=0;

for(int i=1;i<=n;++i)

a[i+1]=mo(mod-sa+1ll*(d[i]+1)*a[i]%mod);

b[i+1]=mo(mod-mo(d[i]+1+sb)+1ll*(d[i]+1)*b[i]%mod);

} write(1ll*mo(mod-b[n+1])*power(a[n+1],mod-2)%mod),pc('\n');

return 0;

}

噫!好!我 ak 了!

這次的月賽還是很簡單的,算是良心賽,可以很好地考察一些選手地卡常技巧(大霧。

可能說明我搞了許久 oi 還是有進步的?但願如此。

某古 11 月月賽 I 遊記

難度好評,沒有像我上次打的那場比賽那麼水了,不過自己的分數還是好低,只會前三題。希望你古月賽的題目一直都能像這場這麼有意思。三角形面積公式 s fracah 由於 a 相等,所以題目給出的其實就是 h 之比。題目中給出了 a,b,c,d 不妨令 a le b le c le d 由於題目給出的是正方...

洛谷 9月月賽

題目描述 眾所周知,在一些特殊的部門,如果密碼能夠讓乙個人就解開,就會非常不安全。pic pre invoked code,預生成密碼 誕生了。這個密碼比較安全,是因為它必須由三個人保管。系統首先預先生成三個大整數a b c,計算出它們的與and 或or 和sum並儲存,然後將a b c分別告訴這三...

2018 1月 月賽總結

a題 n,m 1e18,p 1e5,lucas定理求組合數 include include include using namespace std typedef long long ll ll n,m,p 100003 ll f 100005 ll qpow ll a,ll b return an...