部落格遷移http://www.cnblogs.com/xzz_233/
阿新 • • 發佈:2019-02-18
傻逼題,列舉即可。
#include<cstdio> #include<cstdlib> #include<algorithm> bool k[10][10]={0}; int ans=0; void d(int a,int b,int c,int d,int e,int f){ if(k[a][b]&&k[c][d]&&k[e][f])++ans; } int main(){ int n,m,x,y; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d%d",&x,&y),k[x+3][y+3]=1; d(0,0,0,3,0,6); d(1,1,1,3,1,5); d(2,2,2,3,2,4); d(3,0,3,1,3,2); d(3,4,3,5,3,6); d(4,2,4,3,4,4); d(5,1,5,3,5,5); d(6,0,6,3,6,6); d(0,0,3,0,6,0); d(1,1,3,1,5,1); d(2,2,3,2,4,2); d(0,3,1,3,2,3); d(4,3,5,3,6,3); d(2,4,3,4,4,4); d(1,5,3,5,5,5); d(0,6,3,6,6,6); printf("%d",ans); return 0; }
依題意模擬+KMP即可。
#include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> const int maxn=1000010; int w[maxn],nxt[maxn]; char s[maxn],t[maxn]; int main(){ int n,a,b,L,R; scanf("%d%d%d%d%d",&n,&a,&b,&L,&R); w[0]=b; for(int i=1;i<=n;i++)w[i]=(w[i-1]+1)%n; for(int i=0;i<n;i++) if(w[i]&1) if(w[i]>R||w[i]<L)s[i]='C'; else s[i]='T'; else if(w[i]>R||w[i]<L)s[i]='G'; else s[i]='A'; scanf("%s",t+1); int len=strlen(t+1); nxt[0]=nxt[1]=0; for(int i=2; i<=len; i++) { int p=nxt[i-1]; while(p&&t[i]!=t[p+1])p=nxt[p]; if(t[i]==t[p+1])nxt[i]=p+1; else nxt[i]=0; } int i=0,j=1,ans=0; while(i<n) if(s[i]==t[j]){ i++,j++; if(j>len)++ans; } else if(j!=1)j=nxt[j-1]+1; else ++i; printf("%d %s\n",ans,s); return 0; }
都沒做。%%%毛爺爺
!!!!!!!!!!
這次巨菜(網好卡啊)