hdu 4041 Eliminate Witches!
来源:互联网 发布:比价网站源码整站程序 编辑:程序博客网 时间:2024/04/29 13:24
用栈去模拟
弹栈出栈就做完了
当时还没转c
用p写的
program aaa;var sl,n,m,i,j,k,tb,tc,x:longint; a:array[1..60000] of string; b,c,t:array[1..1000000] of longint; s,st:ansistring; flag:boolean;beginreadln(k);for x:=1 to k do begin fillchar(t,sizeof(t),0); fillchar(c,sizeof(c),0); fillchar(b,sizeof(b),0); readln(s); sl:=length(s); while s[sl]=' ' do dec(sl); i:=1;st:='';m:=0; n:=0;tb:=0;tc:=0; while i<=sl do begin while (s[i]<>'(') and (s[i]<>')') and (s[i]<>',') and(i<=sl) do begin flag:=false; st:=st+s[i]; i:=i+1; end; if (st<>'') then begin n:=n+1;a[n]:=st;tb:=tb+1;b[tb]:=n;m:=m+1;t[m]:=n; st:=''; end; if s[i]='(' then begin tc:=tc+1;c[tc]:=tb; end; if s[i]=')' then begin tb:=c[tc]; m:=m+1; t[m]:=b[tb]; tc:=tc-1; end; if s[i]=',' then begin m:=m+1; t[m]:=b[c[tc]]; end; inc(i); end; writeln(n); for i:=1 to n do writeln(a[i]); for i:=1 to m-1 do writeln(t[i],' ',t[i+1]); writeln; end; end.
- hdu 4041 Eliminate Witches!
- HDU 4041 Eliminate Witches!
- HDU 4041 Eliminate Witches! --模拟
- HDU 4041 Eliminate Witches! 树的遍历
- HDU 4041 Eliminate Witches! (栈的模拟)
- hdu 4041 Eliminate Witches! 栈和队列
- HDU 4041 Eliminate Witches!(模拟)
- hdu 4041 Eliminate Witches!(栈模拟)
- hdu 4041 Eliminate Witches! (栈的模拟)
- HDU-4041-Eliminate Witches! (11年北京网络赛!!)
- HDU ACM 4041 Eliminate Witches! 队列和栈模拟DFS
- HDU 4041 Eliminate Witches! (ACM ICPC 2011北京赛区网络赛)
- hdu 4041 Eliminate Witches!(模拟,栈在树中的应用)
- HDU 4043 Eliminate Witches! (求概率推公式 + 大数)
- [hdu4041]Eliminate Witches!
- Eliminate Witches! [2011 北京网络赛]
- Eliminate Witches!2011年北京网络赛
- 2011 Asia Beijing Regional Online Contest-1002 hdu4041 Eliminate Witches!
- 子集算法
- windows ghost系统下载
- 国际化动态文件和其他标签的实例应用
- JDBC回顾
- Silverlight4.0中移动一个元素动画的后台代码
- hdu 4041 Eliminate Witches!
- 如何限制asp.net中上传文件的大小的代码
- 黑客常用端口
- bootm内核的启动
- 单例模式(饿汉式与懒汉式)
- 国际化动态文件和其他标签的实例应用
- 端口详解
- phpDocumentor 及相关资源
- 实现Javawb分页技术