bzoj1238
题解:
傻逼模拟题
果断的复制了题解(还没有c++题解?)
代码:
program p2509;
type arr=array[..] of boolean;
var tot:longint;
s:array[..] of ansistring;
b:arr;
procedure init;
begin
tot:=;
while not eof do
begin
inc(tot);
readln(s[tot]);
end;
end;
procedure warn1(n:longint;c:char);
begin
writeln('Line ',n,': variable ',c,' might not have been initialized');
end;
procedure warn2(n:longint);
begin
writeln('Line ',n,': unreachable code');
end;
function judge(str:ansistring):longint;
begin
if str[]='F' then
exit()
else if str[]='E' then
exit()
else if str[]='L' then
exit()
else if str[]='N' then
exit()
else
exit();
end;
function dfs(var k:longint;var c:arr):boolean;
var d,e,c1,c2:arr;
str:ansistring;
i,j,sum:longint;
a:array[..] of longint;
b1,b2:boolean;
begin
d:=c;
while k<=tot do
begin
str:=s[k];
if judge(str)= then //赋值语句
begin
fillchar(a,sizeof(a),);
for i:= to length(str) do
if (str[i]>='A') and (str[i]<='Z') and not c[ord(str[i])-] then
inc(a[ord(str[i])-]);
for i:= to do
if a[i]> then
warn1(k,chr(i+));
c[ord(str[])-]:=true;
end
else if judge(str)= then //return语句
begin
fillchar(a,sizeof(a),);
for i:= to length(str) do
if (str[i]>='A') and (str[i]<='Z') and not c[ord(str[i])-] then
inc(a[ord(str[i])-]);
for i:= to do
if a[i]> then
warn1(k,chr(i+));
sum:=;
j:=k;
inc(k);
while k<=tot do
begin
str:=s[k];
if judge(str)= then inc(sum);
if sum= then
if (str[]='L') or (str[]='N') then
begin
for i:=j+ to k- do
if judge(s[i])<= then warn2(i);
c:=d;
exit(true);
end;
if str[]='N' then dec(sum);
inc(k);
end;
if k>tot then
for i:=j+ to tot do
if judge(s[i])<= then warn2(i);
end
else if judge(str)= then //if语句
begin
j:=;
while copy(str,j,)<>'THEN' do
inc(j);
fillchar(a,sizeof(a),);
for i:= to j- do
if (str[i]>='A') and (str[i]<='Z') and not c[ord(str[i])-] then
inc(a[ord(str[i])-]);
for i:= to do
if a[i]> then
warn1(k,chr(i+));
e:=c;
inc(k);
b1:=dfs(k,c);
c1:=c;
c:=e;
if judge(s[k])= then
begin
inc(k);
b2:=dfs(k,c);
c2:=c;
c:=e;
if b1 and not b2 then
c:=c2
else if not b1 and b2 then
c:=c1
else if not b1 and not b2 then
begin
for i:= to do
if c1[i] and c2[i] then c[i]:=true;
end;
b1:=b1 and b2;
end
else
b1:=false;
if b1 then
begin
sum:=;
j:=k;
inc(k);
while k<=tot do
begin
str:=s[k];
if judge(str)= then inc(sum);
if sum= then
if (str[]='L') or (str[]='N') then
begin
for i:=j+ to k- do
if judge(s[i])<= then warn2(i);
c:=d;
exit(true);
end;
if str[]='N' then dec(sum);
inc(k);
end;
if k>tot then
for i:=j+ to tot do
if judge(s[i])<= then warn2(i);
end;
end
else if judge(str)= then //else语句
begin
exit(false);
end
else if judge(str)= then //end if语句
begin
exit(false);
end;
inc(k);
end;
end;
procedure main;
var i,l:longint;
bool:boolean;
begin
l:=length(s[]);
fillchar(b,sizeof(b),false);
for i:= to l do
if (s[][i]>='A') and (s[][i]<='Z') then
b[ord(s[][i])-]:=true;
i:=;
bool:=dfs(i,b);
end;
begin
init;
main;
end.
bzoj1238的更多相关文章
随机推荐
- C语言之网络编程(服务器和客户端)
Linux网络编程 1. 套接字:源IP地址和目的IP地址以及源端口号和目的端口号的组合称为套接字.其用于标识客户端请求的服务器和服务. 常用的TCP/IP协议的3种套接字类型如下所示. (1)流套接 ...
- windows下vue开发环境的搭建
一 介绍: vue.js是什么? Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的渐进式框架.与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计.Vue 的核心库 ...
- cyberduck的SSH登录
1.通过配置SSH秘钥. 2.不点匿名(不要点匿名),如果非要填一个名字的话,你写root就行. 3.书签.
- 《HTTP 权威指南》笔记:第十三章 摘要认证体制
前言 基本认证存在缺陷,摘要认证为了解决基本认知的一些缺陷,进行了进一步的完善,更加安全. 流程 摘要认证的特点是:永远不会以明文方式在网络上发送密码原理:通过发送一个「指纹」或者「密码的摘要」来验证 ...
- .NET的关于人脸识别引擎分享(C#)
https://www.cnblogs.com/RainbowInTheSky/p/10247921.html
- 关于Mysql 查询所有表的实时记录用于对比2个MySQL 库的数据是否异步
Xu言: 今天,为了研究一个MySQL主从同步开机后报错 问题,如下图 故障原因分析: 经过分析,可能是主从服务器开机顺序导致.(有待下次断电再次测试) 主从错误提示:日志读取错误的问题.解决方法:更 ...
- JS过渡和变形效果演示(举例:鼠标滑过图片放大) --JS案例
1.代码: <!DOCTYPE html><html><head> <meta charset="utf-8"> <title ...
- LeetCode--409--最长回文串
问题描述: 给定一个包含大写字母和小写字母的字符串,找到通过这些字母构造成的最长的回文串. 在构造过程中,请注意区分大小写.比如 "Aa" 不能当做一个回文字符串. 注意: 假设字 ...
- 关于Android 主题的那些事
最近遇到了一个问题,主题的ActionBar的Title 颜色是黑色的 但是我的主界面由于用的是CoordinateLayot所以是白色的 整个黑色的就很难看 所以也想要把ActionBar 的Tit ...
- Windows 上安装 Scala
在安装 Scala 之前需要先安装 Java 环境,具体安装的详细方法就不在这里描述了. 您可以自行搜索我们网站中的内容获得其他网站的帮助来获得如何安装 Java 环境的方法. 接下来,我们可以从 S ...