3
14
2016
0

[坑]PA2014 Final

推了君彼彼后感觉精神有点恍惚,做点PA final提提神

诶以前居然做过两题_(:зゝ∠)_

现在做了几题:  2/6

$3.16$ $qiancl:$我已经方了


bzoj3722 这题是专门来体现的我$naive$的,很显然的$n^2$暴力就行了_(:зゝ∠)_,没错,我$wa$辣么多发的原因是我输出写错了TAT

#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 1010
int i,j,k,m,n,x,c[N],y,cnt,last[N],v[N],tmp,ans[N];
struct edge{int to,next;}e[N<<1];
void insert(int u,int v){e[++cnt]=(edge){v,last[u]},last[u]=cnt;}
#define nc() getchar()
inline int read(){
	int x=0,f=1;char ch=nc();for(;(ch<'0'||ch>'9')&&(ch!='-');ch=nc());
	if(ch=='-')ch=nc(),f=-1;for(;ch<='9'&&ch>='0';x=x*10+ch-48,ch=nc());return f*x;
}
int dfs(int x){
	if(c[x]<=0)return v[x];int sum=0;
	for(int i=last[x];i;i=e[i].next)sum+=dfs(e[i].to);
	if(sum>0)return 1;if(sum<0)return -1;return 0;
}
int main(){
	for(n=read(),i=1;i<=n;++i){
		for(c[i]=read(),j=1;j<=c[i];++j)y=read(),insert(i,y);
		if(c[i]==-2)v[i]=1;if(c[i]==-1)v[i]=-1;if(c[i]==0)v[i]=0;
		if(c[i]>0)v[i]=0x7f7f7f7f;
	}
	if(dfs(1)==-1)return puts("NIE"),0;
	for(i=1;i<=n;++i)if(v[i]==0){v[i]=1;if(dfs(1))ans[++tmp]=i;v[i]=0;}
	for(printf("TAK %d\n",tmp),i=1;i<=tmp;++i)printf(i!=tmp?"%d ":"%d",ans[i]);
}

bzoj3723 thinking...


bzoj3724 thinking...


bzoj3725 画风和前两题完全不同_(:зゝ∠)_,记录一下连续两种颜色的距离就行了

#include<cstdio>
#include<cstring>
char s[1000100],last;int n,l,pre,i;
int main(){
	for(gets(s+1),n=strlen(s+1),l=n,last='*',pre=i=1;i<=n;++i)if(s[i]!='*'){
		if(s[i]!=last){if(last!='*'&&i-pre<=l)l=i-pre;last=s[i];}pre=i;
	}printf("%d\n",n-l+1);
}

 

updating...

Category: bzoj | Tags: | Read Count: 744

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com