2019.8.5 NOIP 15 simulation tests reflect summary

Daily explosions, managed to get better every time difference XD

He may still be learning the body slow down the progress of it, although no effect Logically speaking. I have heard you listen, you learn how many times I did not absenteeism.

So the problem really is the ability to do ......?

Although reluctant to admit, but apparently it is. For multiple examinations, the state health reasons are reasons for temporary reasons, while the visible decline can not use them to hide.

There exam today, let me see if I stop here.

 

 

T1 Construction City:

A combination of mathematical method + flapper inclusion and exclusion, grabbed a pen to write formulas, no difficulty flapper law, inclusion and exclusion on emmmm.

Never wrote inclusion and exclusion of the question ... I did not push themselves too formulas ...

Look at a range of data to see how much of the points could get, think of a DP. In fact, think is normal, because before the test had a similar problem, the solution of that question there are two kinds of DP and inclusion and exclusion. But the data range is not the same, here only for inclusion and exclusion.

I thought up on the test that question, but it is easy to launch DP, wrote a search when to shoot, to get out of the finished code.

Exam, catch fish in [doing it], and then the last ten minutes staring at the DP suddenly dying in shock sit disease thought prefix and can optimize away part of the content, and then try to code it. In fact, that question was also the prefix and the process. Then again exposed the problem of insufficient force my code, prefix and playing the bombing, capped 40 points.

Correct answer is very simple inclusion-exclusion [but] I did not launch. First of all cases calculated, France available interposer C (m-1, n-1). Take more then subtracting a city, the whole first subtracting m k, then forced together to give the city, is C (mk-1, n-1), then each city can optionally take much, so then multiplied by a C (n, 1). But this will be reduced and more, to ensure the city to take a much more in other cities may also be time-point, for example, two cities may take more cases to be repeated several times to forget. Thus plus two cities take many cases, C (m-2 & k-1, n-1) * C (n, 2). Then go on ... boundaries has been the inclusion-exclusion is mi * k-1> n-1.

Pretreatment about factorial and inverse. For n> m of the case, the city must not meet each take at least one of the output is determined at 0 enough. I forgot about this ... almost thought inverse factorial to be processed 10 9 ...

#include<iostream>
#include<cstdio>
using namespace std;
long long n,m,k;
const long long mod=998244353;
long long rec[20000010],inv[20000010],ans;
long long ks(long long x,long long k){
    long long num=1;
    while(k){
        if(k&1){
            num=num*x%mod;
        }
        x=x*x%mod;
        k>>=1;
    }
    return num;
}
long long C(int n,int m){
    return rec[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    if(n>m){
        printf("0\n");
        return 0;
    }
    rec[0]=inv[0]=rec[1]=1;
    for(int i=2;i<=m;i++){
        rec[i]=rec[i-1]*i%mod;
    }
    inv[m]=ks(rec[m],mod-2);
    for(int i=m-1;i>=1;i--){
        inv[i]=inv[i+1]*(i+1)%mod;
    }
    ans=C(m-1,n-1);
    for(int i=1;m-i*k>=n&&i<=n;i++){
        if(i&1)ans=(ans-(C(m-i*k-1,n-1)*C(n,i)%mod)+mod)%mod;
        else ans=(ans+(C(m-i*k-1,n-1)*C(n,i)%mod)%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}
View Code

Do not catch fish, not to catch fish, not to catch fish! Today reminded me to remind my future and all those who can see. Not too early to lose faith ... do not give up thinking.

To have confidence in themselves ah ink Yu-sheng! ! ! [Ah saying this out themselves feel powerless]

 

 

T2 bombing campaign:

This is a question the language of God, at least half of the people are wrong question. Connectivity is not restricted adjacent edges.

And I am even more wise, I was wrong to see the wrong answers to the questions, I bipartite graph coloring ...

Actually pressed the wrong understand, can not be the bipartite graph coloring. As long as he will complete graph explosion. I totally did not expect it about the five elements missing brain?

Correct answer is tarjan board. First, a point on the chain, must be a a blow, so the optimal solution must be greater than equal to the length of the longest chain. Then for other short chain, the longest chain, and can operate in parallel. So the answer is the longest chain length.

a condensing point in mind scc Tarjan, then the maximum possible topology of note chain length, like the output. When the comparison is f [y] [x] + siz [y] compared with f, because f [y] may have been the other side came the answer updated, while the siz [y] is the beginning of the initial value.

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int n,m,ans,f[2000010];
int ver[2000010],Next[2000010],head[2000010],tot,tim,vis[2000010];
int dfn[2000010],low[2000010],cnt,c[2000010],siz[2000010],stack[2000010],st;
int du[2000010],ver1[2000010],Next1[2000010],head1[2000010],tot1;
queue<int>q;
void add(int x,int y){
    ver[++tot]=y;
    Next[tot]=head[x];
    head[x]=tot; 
}
void add1(int x,int y){
    ver1[++tot1]=y;
    Next1[tot1]=head1[x];
    head1[x]=tot1; 
}
void tarjan(int x){
    low[x]=dfn[x]=++tim;
    stack[++st]=x;
    vis[x]=1;
    for(int i=head[x];i;i=Next[i]){
        int y=ver[i];
        if(!dfn[y]){
            tarjan(y);
            low[x]=min(low[x],low[y]);
        }
        else if(vis[y])low[x]=min(low[x],dfn[y]);
    }
    if(low[x]==dfn[x]){
        int p;
        cnt++;
        do{
            p=stack[st--];
            vis[p]=0;
            c[p]=cnt;
            siz[cnt]++;
        }while(p!=x);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,x,y;i<=m;i++){
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    for(int i=1;i<=n;i++){
        if(!dfn[i])tarjan(i);
    } 
    for(int i=1;i<=n;i++){
        for(int j=head[i];j;j=Next[j]){
            int y=ver[j];
            if(c[i]!=c[y]){
                add1(c[i],c[y]);
                du[c[y]]++;
            }
        }
    }
    for(int i=1;i<=cnt;i++){
        if(!du[i]){
            q.push(i);
            ans=max(ans,siz[i]);
        }
        f[i]=siz[i];
    }
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=head1[u];i;i=Next1[i]){
            int y=ver1[i];
            f[y]=max(f[y],f[u]+siz[y]);
            ans=max(ans,f[y]);
            du[y]--;
            if(!du[y])q.push(y);
        }
    }
    printf("%d",years);
    return  0 ; 
}
View Code

Carefully examine the topic at least three times! The third question pits are seen, the second question die so tragic ......

 

 

T3 rock-paper-scissors:

After this good to write about, now out of time, Xiandiu code.

#include<iostream>
#include<cstdio>
using namespace std;
int n;
double a[110],b[110],c[110],tol[110][5],f[55][55][55][55],g[55][55][55][55],ans;
double C[110][110];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lf%lf%lf",&a[i],&c[i],&b[i]);
        tol[i][1]=a[i]/300.0;
        tol[i][2]=b[i]/300.0;
        tol[i][3]=c[i]/300.0;
    }
    for(int i=0;i<=100;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=C[i-1][j-1]+C[i-1][j];
        }
    }
    g[0][0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=i;j>=0;j--){
            for(int k=i-j;k>=0;k--){
                for(int l=i-j-k;l>=0;l--){
                    g[i][j][k][l]=g[i-1][j][k][l];
                    if(j)g[i][j][k][l]+=g[i-1][j-1][k][l]*tol[i][1];
                    if(k)g[i][j][k][l]+=g[i-1][j][k-1][l]*tol[i][2];
                    if(l)g[i][j][k][l]+=g[i-1][j][k][l-1]*tol[i][3];
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i;j>=0;j--){
            for(int k=i-j;k>=0;k--){
                for(int l=i-j-k;l>=0;l--){
                    if(j){
                        f[j][k][l][1]+=f[j-1][k][l][1]*tol[i][1];
                        f[j][k][l][2]+=f[j-1][k][l][2]*tol[i][1];
                        f[j][k][l][3]+=f[j-1][k][l][3]*tol[i][1];
                    }
                    if(k){
                        f[j][k][l][1]+=f[j][k-1][l][1]*tol[i][2];
                        f[j][k][l][2]+=f[j][k-1][l][2]*tol[i][2];
                        f[j][k][l][3]+=f[j][k-1][l][3]*tol[i][2];
                    }
                    if(l){
                        f[j][k][l][1]+=f[j][k][l-1][1]*tol[i][3];
                        f[j][k][l][2]+=f[j][k][l-1][2]*tol[i][3];
                        f[j][k][l][3]+=f[j][k][l-1][3]*tol[i][3];
                    }
                    f[j][k][l][1]+=g[i-1][j][k][l]*tol[i][1];
                    f[j][k][l][2]+=g[i-1][j][k][l]*tol[i][2];
                    f[j][k][l][3]+=g[i-1][j][k][l]*tol[i][3];
                }
            }
        }
    }
    for(int j=0;j<n;j++){
        for(int k=0;k+j<n;k++){
            for(int l=0;l+k+j<n;l++){
                ans+=max(f[j][k][l][1]+f[j][k][l][2]*3,max(f[j][k][l][2]+f[j][k][l][3]*3,f[j][k][l][3]+f[j][k][l][1]*3))/(C[n][j+k+l]*(n-j-k-l));
            }
        }
    }
    printf("%.12lf",ans);
    return 0;
} 
View Code

 

 

So it is the daily explosion of an examination exposed a lot of problems, but this is the kind of feeling my limit.

Bad, I'm bad, nothing to say.

Today's exam ... I wish you and to myself RP ++, and hope she does not give up ...

Guess you like

Origin www.cnblogs.com/chloris/p/11330380.html