- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Noip 2003 提高组 解题报告题一??? 神经网络
分析:??? 这一题有很多种方法,数据也较弱。我考虑到其中的层次关系,用类似于广搜的方法,但是注意到每个结点不仅仅是由当前head节点扩展,而是当前队列全部节点。
源程序:program network1;const maxn=100;var c,u:array[1..maxn]of longint; //c,状态数组;u,阈值数组??? w:array[1..maxn,1..maxn]of longint; //表示是否连通(有向图)??? anstp,head,tail,n,i,j,p,k,x,y:longint;??? q:array[1..10000]of record dep,num:longint; end; //队列记录两个变量(层次与号码)??? ct:array[1..maxn]of boolean; //判重数组??? ans:array[1..maxn]of longint; //答案,记得排序,故先用数组暂存??? tag:boolean; //判断是否输出NULL
procedure qsort(s,t:longint); //快速排序var i,j,d,x:longint;begin????? i:=s; j:=t; x:=ans[(s+t)shr 1];????? repeat?????? while ans[i]x do inc(i);?????? while ans[j]x do dec(j);?????? if i=j??????? then begin d:=ans[i]; ans[i]:=ans[j]; ans[j]:=d; inc(i); dec(j); end;????? until ij;????? if sj then qsort(s,j); if it then qsort(i,t);end;
begin????? assign(input,network.in); reset(input); assign(output,network.out); rewrite(output);
?????? {init}?????? readln(n,p);?????? for i:=1 to n do readln(c[i],u[i]);?????? fillchar(w,sizeof(w),0); fillchar(ct,sizeof(ct),false);?????? for i:=1 to p do begin readln(x,y,k); w[x,y]:=k; w[y,x]:=k; end;???????????? {main}?????? head:=0; tail:=0;?????? for i:=1 to n do??????? if c[i]0// 对首层的操作,可以传递兴奋则进队???????? then????????? begin?????????? ct[i]:=true; inc(tail); q[tail].dep:=1; q[tail].num:=i;????????? end;?????? for i:=1 to n do if c[i]=0 then c[i]:=-u[i]; //先确定起始值?????? repeat??????? x:=head;??????? repeat???????? inc(x);???????? if c[q[x].num]=0 then continue; //若兴奋性=0,则不会向下传递,枚举下一个???????? for i:=1 to n do????????? if not ct[i] and (w[q[x].num,i]0) //没有入队,存在有向边连接?????????? then c[i]:=c[i]+c[q[x].num]*w[q[x].num,i];??????? until x=tail;?? //下一层不仅仅取决于上一层的某一个元素,它来源于上一层的全部元素。??????? x:=tail;? //恢复尾指针??????? repeat???????? inc(head);???????? for i:=1 to n do????????? if not ct[i] and (w[i,q[head].num]0)?????????? then begin inc(tail); ct[i]:=true; q[tail].num:=i; q[tail].dep:=q[head].dep+1; end;?????????? //拓展队列,注意无论是
文档评论(0)