CF 6.6 6.8 out points diary

--- --- restore content begins

  Wrote effect is still not good not finished the first four title race is over and the title of my most popular group still lacks a simple algorithm spiritual problems always get complicated.

Water analysis 6.5 A very simple first question found to be a fast power of the reverse process. Within logn time to solve.

      This is a B flat compared to analog on a little bit more difficult because there may be simulated explosion ll take it into consideration before writing the case considered good to write.

      C one can not also do not understand the meaning of what the topic is, I can not read or write discarded after seeing the https://codeforces.com/contest/1175/problem/C

   D feel able to write a sequence into k Paragraphs 2 ... by a second section by selecting the maximum value dp then apparently f [i] [j] denotes the i-th former maximum number into the J segment is n dp ^ 2k looks quite uncomfortable to be optimized slope nk then? Then still hang.

I was greedy fucks out a forward section to take paragraph k k-1 every time I choose the biggest and the suffix has been found nlogn wa not take into account a number of factors and not the maximum from the suffix is ​​optimal because the current digital contribution not only caused only front but also have back, so that is not going to write, consider setting p1 p2 ... pk for each segment breakpoint obviously p1 = 1; pi <pi + 1 is taken bi i ~ and n is a suffix and then the time sum = 1 * (bp1-bp2) + 2 * (bp2-bp3) + .. k * bk; obtained .bp1 + bp2 + bp3 + bp4 ... bpk;

We just need to take the biggest discovery of several bp value can be forced to take note p1 1.

The remaining topics did not look over. . .

6.8 A subject of water is a very good relationship will be able to pay attention to AC

      B At first glance the feeling is not written but actually draw a map found each time to put the pieces can only be placed on a piece of the right or bottom taking care to maintain a good place to rotation.

      C is a more interesting topic does not seem to do in-depth understanding found only two cases which numbers 1 to enumerate each put a hand if there is no current, then it has taken until this digital digital simulation and then take out place go back.

      Or are among the ranks will direct analog to sort good if successful then it must be better than the first decision. This OK!

      D seems to be a permutation count looked not write now look at discards n <= 2e5 find solution to a problem reading is a very wonderful tree dp
topic: https://codeforces.com/contest/1173/problem/ D

Oh, something like this for a rootless tree for us at any point of view, then we can imagine to each point can be the root, it can be a root and then found 1 can all be put in any position.

Consider the subtree 1 due to the sub-tree must be Clearly on a circular arc. So sub-tree and fathers who put in the position of his father's initial decision to think carefully about the number of programs you can put 1 n positions in accordance with a way to let us put a few words are all traversed to the program.

So there is a good title transferred. Put the code below:

//#include<bits/stdc++.h>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<vector>
#include<cctype>
#include<utility>
#include<set>
#include<bitset>
#include<map>
#define INF 2147483646
#define ll long long
#define min(x,y) (x>y?y:x)
#define max(x,y) (x>y?x:y)
#define RI register ll
#define up(p,i,n) for(ll i=p;i<=n;++i)
#define db double
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline void put(ll x)
{
    x<0?x=-x,putchar('-'):0;
    int num=0;char ch[50];
    while(x)ch[++num]=x%10+'0',x/=10;
    num==0?putchar('0'):0;
    while(num)putchar(ch[num--]);
    putchar('\ n- ' ); return ; 
} 
const  int MAXN = 200010 ;
 int n-, len; 
LL FAC [MAXN], SZ [MAXN], F [MAXN]; // F [i] i is represented internally in the subtree rooted number scheme 
int VIS [MAXN];
 int LIN [MAXN << . 1 ], NEX [MAXN << . 1 ], Ver [MAXN << . 1 ]; 
inline void the Add ( int X, int Y) 
{ 
    Ver [ ++ len ] = Y; 
    NEX [len] = LIN [X]; 
    LIN [X] = len; 
} 
inline void dfs(int x)
{
    vis[x]=1;sz[x]=1;ll sum=1;
    for(int i=lin[x];i;i=nex[i])
    {
        int tn=ver[i];
        if(vis[tn])continue;
        dfs(tn);sum=sum*f[tn]%mod;
        ++sz[x];
    }
    //f[x]=fac[sz[x]];
    if(x!=1)f[x]=fac[sz[x]];
    else f[x]=fac[sz[x]-1];
    f[x]=f[x]*sum%mod;
}
int main()
{
    //freopen("1.in","r",stdin);
    n=read();fac[0]=1;
    for(int i=1;i<n;++i)
    {
        int x,y;
        x=read();y=read();
        add(x,y);add(y,x);
    }
    for(int i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod;
    dfs(1);
    put(f[1]*n%mod);
    return 0;
}
View Code

The rest of the title will not say. . Less likely to have no time to write.

 

Guess you like

Origin www.cnblogs.com/chdy/p/10993226.html