THUPC2019 / CTS2019 / APIO2019 / PKUSC2019 Travels

THUPC2019 / CTS2019 / APIO2019 / PKUSC2019 Travels

5.10

In the shop, train good shake ah

5.11

Hit THUPC2019 practice sessions, Huarong praise (four soldier,Bars duck!)

5.12

Hit THUPC2019

The opening burst several hair D, then do not want to write, threw ZCY, cerr wa actually a lot of hair

ZCY B is then seen sb problem, we both do not want to write, threw ZCY

Gmy and then I wrote M and J are two check-in problems, the three began to open C respectively, I, L

ZCY threw me a \ (O (m) \) of formula I optimization, I found that after 20 k was pushed

You inclusion and exclusion are \ (O (k ^ 2) \) again is not \ (O (2 ^ k) \) of optimization you doing this

Then I wrote the inclusion-exclusion part, the number of combinations he wrote part, pay up, WA? ? ?

woc The modulus is too small may not inverse ah, then change change change change change, pay up, over

I would have been at this time of gmy, but the two of us and nobody wanted to write, still threw ZCY

Has been finished WA, violence also pay WA

When we cross a fine spray card out of puts ( "nan");

Then too, conscience SPJ, last rk36 roll rough

Then commented links, advertising two hours, Topic? ? ? Not or will not

Three high-profile South, the Big Three points zcy and experience the thrill of flying by

In the evening to the hotel only to find I read the question wrong, I'm a sucker

Then go back and change the L and K.

5.13

In the cafeteria to see rvalue, was about to greet gone QAQ, but fortunately they met in the next examination room

Then hit CTS2019Day 1

A title play both violence 3h +

A look out scores okay

orz \(\color{red}{\mathrm{Itst}}\) 切t2

5.14

Hit CTS2019Day 2

Wrote 30 + 10 + 0

A look at a record of 10 + 10 + 0

Sucker, rolling blacksmith thick, convex hull can be wrong.

The reason probably is that I put the lower left corner of the reference point also throw into sorting it

5.15

It can accept the award, was a ag, no loss

The average person eating a hot pot fairy 90rmb, scared urine

5.16

lzh came, the atmosphere suddenly? Up

Then I pulled into the pit lol

5.17

Am talking about something totally did not understand much, I went to a direct result of the afternoon did not go.

5.18

Hit APIO2019, the autistic

Opening finished Sa violence, began to engage in t1 (device), thought seems to be quite a sucker.

Is split rings do interval coverage on the line.

I wrote a special 5k sentence, because then there are four analog to digital (A, B, B + 1, A / gcd (A, B + 1)), do not tune out.

Finally, 20 + 43 + 60 roll rough.

I asked everybody out 203, txc get together it is two hours ahead of departure ak

I, ah stable bottom

5.19

Morning and say terrible things, but it feels more fun than the day before that?

Awards night, I actually still block Cu, no loss, no loss

This time noi race card and all three together, only noi2019 went to the blacksmith (fog)

5.20

Forget doing the

5.21 ~ 5.24

review

5.25

Only I did not go tho the world in Beijing, and even live party can not go on .jpg

Afternoon playing PKUSC2019Day1

Look t1, it seems to be a reverse of the sucker title

Look t2, it seems to be a bad title

Look t3, as if still a sucker title

The first to write t3, for each point out out number 61 and then judge whether the increase can be composed of fixating

Staged a bitset optimization backpack, took 60 minutes and then Kaka always be able to feel passed (flg)

Then write t1, write opinions Chairman of the tree before, but this time 1h, feeling very stable (flg)

Just start t3, he wrote such a fool around:

  • When the number is greater than the number of available 22 simply as possible (22 dichotomous out)

Run fast, ah, a few direct 2. s

Yy then make constant a half practice, but it needs to control the handwritten digits = = bitset

So I opened that comes with mingw began to see the inside of bitset

Read about an hour, suddenly I realized that in the examination, it seems a waste of one hour is not worth it (shability)

T2 look at it, thought for a long time to find a point can enumerate

Enumeration a point less than the considered 0, considered between the impact greater than 2,0022.

Then the number of states is very small, and wrote a regular issuer of the card before.

Back card t3, plus a lot of metaphysics optimization (end did not handwritten bitset)

Suddenly found the last point passed Lv (1992ms), then the first point wa? ? ? Fortunately, however, take up to 93 minutes there ..

After the first point out the special judge to make life difficult last point (20xxms), sensory evaluation machine fluctuate normal, then I made a few will pay more over (flg).

Then finally find a hair 32, the flow Bureau

Advance the examination room pretending ak OK

I asked the group chiefs, many are ahead of 2h ak ah

The t3 as long as trie trees do like, ah, a total of n useful point, according to the depth of a bitset keep log on the line, wtcl it can not think.

Tomorrow to continue refueling QAQ

5.26

Look question, woc three tree problem, a blast to zero

See t1, n ^ finished chain approach looked after dp 2, and will forward solution

Initially wrote a segment merge trees and then find and mark down when not pass the new node, then 1h gone QAQ

Thinking into segment tree heuristic merge or splay heuristic merger will write a little better, go first to t2t3

Look t2, only 8 points

Look t3, looked a long time to understand chord chart is hell, violence will not play, say good-bye

T1 only to write it, this seems to be a time t1 maintain limited set of colors in the sub-tree, do not compare the new node wonderful time at this pass mark, write half found my approach when seeking the dot product of the need to take and divide, then multiply 0 to GG, and take off after the sentence has 0 took another 2h.

Pay out of, AcAcWaTle, this hell ah

Found m range does not seem to be 1e9 2e5 ah, then I have to re-open space bigger .. eh how to mle up.

Do you want to replace the splay heuristic merge to optimize space and time (this time has been the beginning of a segment tree merger thrown away QAQ)

I thought or forget, fight violence now, people had this problem should not be much (flg)

Play then sub binary tree .. t2, write a violence found that \ (m = \ n-lceil /. 4 \ rceil \) , obtains \ (m \) directly after a search on the search out answers.

That's the point behind it should also do so, they begin to guess \ (m \) What is, then guess not cold

Finally 0.5h just t3, feel the law should be able to look for, and then find there is no line sinogram certain length greater than or equal ring 4, write write violence, he did not tune out, rolled.

I asked achievements, many chiefs said today easier than yesterday? ? ?

47 + 49 + 0 = 96, is suspended or beaten to a high ysy and gmy 50 minutes per cut t1t2 how ah QAQ

And then I heard a lot of people ... I succeeded 600 is distinguished today

Listen Gangster Topic, t1 practices are just the same as I stressed out people can tune out, t2 that m is actually turned into a tree after dp chain cover (the number of leaves / 2), t3 note of the conclusions, each time a ride two polynomials with fft to divide and conquer.

5.27

Awards Presentation

He took a second foot

High School to award a good little ah

High School three days and poor prize line about 200 minutes

Write d2t1 on the train segment tree merger, even better written than heuristic merge? ? No need to deal with the situation ride 0

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
#define mod 998244353
#define N 400050
#define M 20000050
#define db(x) cerr<<#x<<" = "<<x<<endl
#define fov(i,x) for(i=0;i<(int)x.size();i++)
ll qp(ll x,ll y=mod-2) {ll re=1;for(;y;y>>=1,x=x*x%mod)if(y&1)re=re*x%mod; return re;}
int head[N],to[N],nxt[N],cnt,n,m,K;
int ls[M],rs[M],tot,siz[M];
int sum[M],tag1[M],tag2[M];
vector<int>V[N];
struct node {
    int rt;
    ll O,s;
    void gs() {
        s=(sum[rt]+(m-siz[rt])*O)%mod;
    }
}tr[N];
node X,Y;
inline void add(int u,int v) {to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;}
inline void giv1(ll v,int p) {
    if(!p)return ;
    sum[p]=sum[p]*v%mod; tag1[p]=tag1[p]*v%mod; tag2[p]=tag2[p]*v%mod;
}
inline void giv2(ll v,int p) {
    if(!p)return ;
    sum[p]=(sum[p]+siz[p]*v)%mod; tag2[p]=(tag2[p]+v)%mod;
}
inline void pushdown(int p) {
    if(tag1[p]!=1||tag2[p]) {
        giv1(tag1[p],ls[p]);
        giv2(tag2[p],ls[p]);
        giv1(tag1[p],rs[p]);
        giv2(tag2[p],rs[p]);
        tag1[p]=1; tag2[p]=0;
    }
}
inline void pushup(int p) {
    sum[p]=(sum[ls[p]]+sum[rs[p]])%mod;
    siz[p]=siz[ls[p]]+siz[rs[p]];
}
void update(int l,int r,int x,int &p) {
    if(!p) { p=++tot; tag1[p]=1; siz[p]=1; }
    if(l==r) { sum[p]=0; return ;}
    int mid=(l+r)>>1; pushdown(p);
    if(x<=mid) update(l,mid,x,ls[p]);
    else update(mid+1,r,x,rs[p]);
    pushup(p);
}
int merge(int l,int r,int x,int y) {
    if(!x&&!y) return 0;
    if(!y) {
        giv1(Y.O,x);
        return x;
    }
    if(!x) {
        giv1(X.O,y);
        return y;
    }
    if(l==r) {
        sum[x]=(sum[x]*sum[y])%mod;
        return x;
    }
    int mid=(l+r)>>1; 
    pushdown(x); pushdown(y);
    ls[x]=merge(l,mid,ls[x],ls[y]);
    rs[x]=merge(mid+1,r,rs[x],rs[y]);
    pushup(x); 
    return x;
}
void dfs(int x,int y) {
    int i;
    tr[x].O=1;
    fov(i,V[x]) update(1,m,V[x][i],tr[x].rt);
    for(i=head[x];i;i=nxt[i]) if(to[i]!=y) {
        dfs(to[i],x);
        X=tr[x], Y=tr[to[i]];
        tr[x].rt=merge(1,m,tr[x].rt,tr[to[i]].rt);
        tr[x].O=tr[x].O*tr[to[i]].O%mod;
    }
    tr[x].gs();
    ll s=tr[x].s;
    if(x!=1) {
        tr[x].O=(s-tr[x].O)%mod;
        giv1(mod-1,tr[x].rt);
        giv2(s,tr[x].rt);
    }
}
int main() {
    scanf("%d%d%d",&n,&m,&K);
    int i,x,y;
    for(i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
    for(i=1;i<=K;i++) scanf("%d%d",&x,&y),V[x].push_back(y);
    dfs(1,0);
    printf("%lld\n",(tr[1].s+mod)%mod);
}

to sum up

  • Be sure to see the input format
  • Think of a practice does not immediately realize, to think more details, if too many details on the exchange practice, do not be afraid to waste time, 5 hours of a game, to get rid of the huge amount of code title, only two hours can finish , so to think.

Guess you like

Origin www.cnblogs.com/suika/p/10959533.html