2015 a summary of the selected round in Shandong province

Source: Internet
Author: User

In fact, the selection of a round in the past has been a while, (Konjac konjac Shandong rank 49, the card line to two rounds ... But because of the reasons for the first course, has not been summed up ...

Day 1: There was a 75 point of violence on this date, and I got 55 points.

T1 20 points of violence is better to take, positive solution is to each two blocks between the element exchange BlaBla after DFS, anyway did not understand.

UPD: Looked at the solution on the net, in fact, the idea is also quite simple, poor to different 2^i length of the reverse order, if more than two, then this method can not be successful. If it is one or two, then the post-situation discussion is exchanged and the DFS continues. At the same time need a pretty obvious conclusion, when an operation sequence length is n, no matter how to change the order of operation, is the legal solution, so the answer plus Fac[n];code:

#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace
Std
	struct hp{int kind,len;
int a[5000];
}OPT[15];
int a[5000],ans=0,n;
int mi[15]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384};
int fac[15];
	void Swapi (int x,int y,int len) {int i;
for (i=0;i<len;++i) swap (a[x+i],a[y+i]);
	} void Dfs (int step,int now) {int i,j,top=0;
	int stack[3]={0,0,0};
	    if (now==n+1) {ans+=fac[step-1];
	  Return  } for (I=1;i<=mi[n];i+=opt[now+1].len) {if (A[i+opt[now].len-1]+1!=a[i+opt[now].len]) {if (top==2)
		    Return
		  Stack[++top]=i;
	}} if (top==0) {DFS (step,now+1); return;} 
	    if (top==1) {i=stack[1];
		    if (A[i+opt[now+1].len-1]+1==a[i]) {SWAPI (I,i+opt[now].len,opt[now].len);
		    DFS (STEP+1,NOW+1);
	      Swapi (I,i+opt[now].len,opt[now].len);	
	  } return;
	    } if (top==2) {i=stack[1]; j=stack[2]; if (a[i+opt[now].len-1]+1==a[J+opt[now].len]&&a[j+opt[now].len-1]+1==a[i+opt[now].len]) {SWAPI (I,j,opt[now].len);
	        DFS (STEP+1,NOW+1);
	        Swapi (I,j,opt[now].len);
	        Swapi (I+opt[now].len,j+opt[now].len,opt[now].len);
	        DFS (STEP+1,NOW+1);
	      Swapi (I+opt[now].len,j+opt[now].len,opt[now].len); } if (A[j+opt[now].len-1]+1==a[i]&&a[j+opt[now+1].len-1]+1==a[i+opt[now].len]) {Swapi (i,j+op
	        T[now].len,opt[now].len);
	        DFS (STEP+1,NOW+1);
	      Swapi (I,j+opt[now].len,opt[now].len); } if (A[i+opt[now].len-1]+1==a[j]&&a[i+opt[now+1].len-1]+1==a[j+opt[now].len]) {Swapi (j,i+op
	        T[now].len,opt[now].len);
	        DFS (STEP+1,NOW+1);
	      Swapi (J,i+opt[now].len,opt[now].len);
	  } return;
	}} int main () {int t,i,j;
	scanf ("%d", &n);
	for (I=1;i<=mi[n];++i) scanf ("%d", &a[i]);
	Fac[0]=1;
	for (i=1;i<=n;++i) fac[i]=fac[i-1]*i; for (i=1;i<=n;++i) {t=0;
	    for (J=1;j<=mi[n];j+=mi[i-1]) opt[i].a[++t]=j;
	    opt[i].kind=t;
	  OPT[I].LEN=MI[I-1];
	} Opt[n+1].len=mi[n];
	DFS (a);
printf ("%d\n", ans); }

T2 35 points violence is also OK, the first 20 points disorderly to make, after 15 points because is chain data, in its a line segment tree can, but exam time not consider is win under evaluation, burst stack two times. Positive solution is virtual tree + Euler path +lca, did not understand, but Zky seniors of the DFS sequence also good understanding, each processing out of the DFS sequence the most left of the treasure point and the right side of the treasure point, the distance between the output can be. Maintenance requires processing of each point in the DFS sequence in the leftmost and most right position.

T3 's 20-point violence test did not come to mind, but in fact is a simple dp,60% data need to use matrix multiplication, 100% of the data need FFT.

UPD: Summer camp once again heard the 60% solution, finally understand. DP equation comparison simple f[i][x]=f[i-1][x*ni[s[i]] 1<=i<=nums then we can apply the idea of a fast power, and find that it can be pushed from K to 2k in the time of O (m^2), the total complexity is O (logn*m^2), Code

#include <iostream>
#include <cstdio>
#include <cstring>
#define P 1004535809
using namespace std;
struct hp{
	long long f[8001];
};
HP E,ans;
int n,m,x,nums;
HP Cheng (HP a,hp B)
{
	int i,j;
	HP C;
	for (I=0;i<=m-1;++i) for (
	  j=0;j<=m-1;++j)
	    c.f[(i*j)%m]= (c.f[(i*j)%m]+ (A.f[i]*b.f[j])%P)%P;
	return c;
}
HP work (int x)
{
	hp T;
	if (x==1)
	  return e;
	T=work (X/2);
	if (x%2==0) return Cheng (t,t);
	else return Cheng (Cheng (t,t), E);
}
int main ()
{
	int i,t;
	scanf ("%d%d%d%d", &n,&m,&x,&nums);
	for (I=1;i<=nums;++i)
	  {
	    scanf ("%d", &t);
	    e.f[t]=1;
      }
    Ans=work (n);
    printf ("%lld\n", Ans.f[x]);
}

Day 2: This is a 90-minute violence, and I only get 20 points.

T1 in fact very very simple, two points plus the maximum flow can, but the test has been in the direction of the cost flow, 2h30min wasted in a variety of cranky ...

Code (PS: Do not know why starting from 0 to build a point on WA (even if the sample is not), starting from 1 AC):

#include <iostream> #include <cstdio> #include <cstring> #define MID (L+r)/2 #define INF
0x7fffffffffffffffll using namespace std;
    struct hp{int u,v;
Long long C;
}A[10000];
int e,ai[51],bi[51],n,m,next[10000],cur[200],pre[200],lev[200],gap[200],point[200]; 
Long Long l,r;
int pic[51][51];
Long Long sum=0;
    void Add (int x,int Y,long long c) {e++; next[e]=point[x]; cur[x]=point[x]=e; A[e].u=x; A[e].v=y;
    A[e].c=c; e++; Next[e]=point[y];
    Cur[y]=point[y]=e; A[e].u=y; A[e].v=x;
a[e].c=0;
    } Long long ISAP (int vs,int vt) {int u,v,i,minl; Long Long Maxf=0,aug;
    BOOL F;
    memset (pre,0,sizeof (pre));
    memset (Gap,0,sizeof (GAP));
    memset (Lev,0,sizeof (Lev)); gap[0]=vt-vs+1;
    U=vs;
        while (LEV[VS]&LT;VT) {f=false; for (V=cur[u];v!=0;v=next[v]) if (a[v].c>0&&lev[u]==lev[a[v].v]+1) {cur[u]=v; f=true; bre
        AK;}
            if (f) {pre[a[v].v]=v;
   U=A[V].V;         if (U==VT) {aug=inf;
                for (i=v;i!=0;i=pre[a[i].u]) if (aug>a[i].c) aug=a[i].c;
                Maxf+=aug;
                    for (i=v;i!=0;i=pre[a[i].u]) {A[i].c-=aug;
                  A[i^1].c+=aug;
              } U=vs;
            }} else {minl=vt; for (I=point[u];i!=0;i=next[i]) if (A[I].C&GT;0&AMP;&AMP;MINL&GT;LEV[A[I].V]) minl=lev[a[i].
            V];
            gap[lev[u]]--;
            if (gap[lev[u]]==0) break;
            lev[u]=minl+1;
            Cur[u]=point[u];
            gap[lev[u]]++;
          if (U!=vs) u=a[pre[u]].u;
}} return MAXF;
    } bool Work (long long x) {int i,j;
    memset (cur,0,sizeof (cur));
    memset (point,0,sizeof (point));
    memset (Next,0,sizeof (next));
    e=1; for (i=1;i<=m;++i) Add (1,i+1, (Long Long) (Bi[i]) *x);
    for (I=1;i<=m;++i) for (j=1;j<=n;++j) if (pic[i][j]==1) Add (i+1,m+j+1, (Long Long) (INF));
    for (i=1;i<=n;++i) Add (m+i+1,m+n+2, (Long Long) (Ai[i]) *1000000);
    if (ISAP (1,m+n+2) ==sum*1000000) return true;
else return false;
    } int main () {int i,j,minn=2100000000;
    scanf ("%d%d", &n,&m);
        for (i=1;i<=n;++i) {scanf ("%d", &ai[i]);
      Sum+=ai[i];
        } for (I=1;i<=m;++i) {scanf ("%d", &bi[i]);
      Minn=min (Minn,bi[i]);
    } for (I=1;i<=m;++i) for (j=1;j<=n;++j) scanf ("%d", &pic[i][j]); l=1;
    R= (Long Long) (Sum/minn) *1000000;
        while (L<r) {if (Work (mid)) R=mid;
      else l=mid+1;
} printf ("%0.6f\n", l/(1000000*1.0)); }

T2 's violence is divided into 50 points, and the linear sieve method +dfs the power of each prime number over and over, thus processing the constraint number of each. But when the exam is not thoughtful enough, even 20 points of violence are written mutilated ... The positive solution is part and + Mo's inversion, still not understand.

T3 violence divided 40 points, but inexplicable write residual only 20 points, the positive solution seems to be line segment Tree + classification discussion, a little bit understand the feeling ....

Summary: 1, the test and the usual practice must pay attention to the combination of several different algorithms, can not only consider a simple algorithm, the difficulty of the selection of difficult to use a simple algorithm or data structure.

2, write good violence, in the discovery of a problem must be more think of why, to think of a permanent solution to the method, you can not just a sample to be changed to skip.

3, more often do some of the difficulty of the selection of the topic, and gradually familiar with the various models of transformation and modeling ideas.

4, reasonable allocation of time to do the problem, do not light in a problem on the death of Knock.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.