73 条题解
-
0myc427 LV 10 @ 2009-11-08 12:37:45
有勇气做这么恶心的题目。。我都佩服自己。。我也佩服你。。。
一个上午都搭进去了了。。。。深刻地体会“始终说真话或者始终说假话”。。。
没说话就是可以当成说真话也可以当成说假话。。。。
代码我写丑了,158行。。。。。。。特晕。。
这题考的不是程序。。是寂寞。。。深深的寂寞。。。
-
02009-11-06 22:01:05@
好!我服了!这么X的题!
'输入由若干行组成,第一行有二个整数,M(1≤M≤20)、N(1≤N≤M)和P(1≤P≤100)'
"二个整数"!明明是3个!"往后有P行,每行开始是某个同学的名宇,紧跟着一个冒号和一个空格,"
样例里冒号后面没有空格,但是数据里全有空格!!!!!!见到了这道题,我已经没有什么可说的了!!!!!!!!!!!!!!!!!!
程序见下面的人............ -
02009-11-03 21:10:11@
99大顺
-
02009-11-03 21:04:57@
一道见了就恶心的题!
-
02009-11-02 17:42:10@
官方数据怎么都过不了,,上vijos碰运气结果ac了。。
期望今年一定不要有这种题目,,god。。。 -
02009-10-31 13:28:01@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msvar
flag,already : boolean;
m,n,k,x,c1,f1,t1,total,guilty,g,d,i : integer;
name : array[1..20]of string;
c,f,t : array[1..100]of integer;
h : array[1..20]of integer;
s : string;function find_name(st:string):integer;
var
i:integer;
begin
find_name:=0;
for i:=1 to m do if name[i]=st then exit(i);
end;function find_day(st:string):integer;
begin
if st='Monday.' then exit(1) else
if st='Tuesday.'then exit(2) else
if st='Wednesday.'then exit(3) else
if st='Thursday.'then exit(4) else
if st='Friday.'then exit(5) else
if st='Saturday.'then exit(6)else
if st='Sunday.'then exit(7)else
exit(0);
end;procedure work;
var
i,max,min,is:integer;
begin
fillchar(h,sizeof(h),0);
max:=m;min:=0;
for i:=1 to total do
begin
case c[i] of
1:if t[i]=g then is:=1 else is:=-1;
2:if t[i]=g then is:=-1 else is:=1;
3:if t[i]=d then is:=1 else is:=-1;
end;
if is+h[f[i]]=0 then exit;
if h[f[i]]=0 then if is=1 then dec(max) else inc(min);
if (maxn) then exit;
h[f[i]]:=is;
end;
if already then begin
writeln('Cannot Determine');
halt;
end;
flag:=true;
guilty:=g;
already:=true;
end;begin
readln(m,n,k);
for i:=1 to m do readln(name[i]);
for i:=1 to k do begin
t1:=0;
readln(s);
x:=pos(':',s);
if x=0 then continue;
f1:=find_name(copy(s,1,x-1));
if f1=0 then continue;
delete(s,1,x+1);
if s='I am guilty.' then begin c1:=1;t1:=f1;end else
if s='I am not guilty.' then begin c1:=2;t1:=f1;end else
if copy(s,length(s)-10,11)=' is guilty.' then
begin c1:=1;t1:=find_name(copy(s,1,length(s)-11));end else
if copy(s,length(s)-14,15)=' is not guilty.' then
begin c1:=2;t1:=find_name(copy(s,1,length(s)-15));end else
if copy(s,1,9)='Today is ' then
begin c1:=3;t1:=find_day(copy(s,10,length(s)-9));end;
if t1=0 then continue;
inc(total);f[total]:=f1;t[total]:=t1;c[total]:=c1;
end;for g:=1 to m do begin
flag:=false;
for d:=1 to 7 do begin
work;
if flag then break;
end;
end;
if guilty0 then writeln(name[guilty]) else writeln('Impossible');
end. -
02009-10-31 13:23:23@
猥琐的题目
program p1106;
var name:array[1..20] of string;
e:array[1..20,1..2,1..20] of integer;
check,data:array[1..20] of integer;
ans,m,n,p:longint;
guilty,s1,s0,na:string;procedure print1;
var j:longint;
begin
writeln('Impossible');
halt;
end;procedure init;
var i,j,k,mid:longint;
begin
ans:=0; guilty:='';
readln(m,n,p);
for i:=1 to m do readln(name[i]);fillchar(e,sizeof(e),0);
fillchar(check,sizeof(check),0);
fillchar(data,sizeof(data),0);
for i:=1 to p do
begin
s1:='';
readln(s1);
mid:=pos(':',s1);
if mid>0 then
begin
na:=copy(s1,1,mid-1);
delete(s1,1,mid+1);
for j:=1 to m do
if na=name[j] then
begin
if s1='I am guilty.' then
begin
if e[j,1,j]=-1 then print1;
e[j,1,j]:=1;
end
else
if s1='I am not guilty.' then
begin
if e[j,1,j]=1 then print1;
e[j,1,j]:=-1;
end
else
if copy(s1,length(s1)-10,11)=' is guilty.' then
begin
s0:=copy(s1,1,length(s1)-11);
for k:=1 to m do
if s0=name[k] then
begin
if e[j,1,k]=-1 then print1;
e[j,1,k]:=1;
// break;
end;
end
else
if copy(s1,length(s1)-14,15)=' is not guilty.' then
begin
s0:=copy(s1,1,length(s1)-15);
for k:=1 to m do
if s0=name[k] then
begin
if e[j,1,k]=1 then print1;
e[j,1,k]:=-1;
//break;
end;
end
else
if copy(s1,1,9)='Today is ' then
begin
s0:=copy(s1,10,length(s1)-9);
if s0='Monday.' then e[j,2,1]:=1;
if s0='Tuesday.' then e[j,2,2]:=1;
if s0='Wednesday.'then e[j,2,3]:=1;
if s0='Thursday.' then e[j,2,4]:=1;
if s0='Friday.' then e[j,2,5]:=1;
if s0='Saturday.' then e[j,2,6]:=1;
if s0='Sunday.' then e[j,2,7]:=1;
end;
//break;
end;
end;
end;
end;procedure outit;
var j:longint;
begin
if ans=0 then print1;
if ans=1 then
begin
writeln(guilty);
halt;
end;
writeln('Cannot Determine');
halt;
end;procedure search(ip,iy:longint);
var j,k:longint;
ok:boolean;
begin
//如果搜到了一种符合的情况
if (ip=m+1)and(iy=0) then
begin
k:=0;
for j:=1 to m do
if check[j]>0 then
if name[j]guilty then
begin
inc(ans);
guilty:=name[j];
if ans>1 then outit;
exit;
end;
for j:=1 to m do if check[j]=0 then inc(k);
if k=0 then exit;
if k=1 then
for j:=1 to m do
if guiltyname[j] then
if check[j]=0 then
begin
inc(ans);
guilty:=name[j];
if ans>1 then outit;
exit;
end;
if k>1 then
begin
inc(ans,2);
outit;
exit;
end;
exit;
end;//边界条件约束
if iym then exit;//如果剩余的人数比要说假话的人还少……
if iy+ip-1>m then exit;ok:=true;
//如果这个说真话
for j:=1 to m do
if e[ip,1,j]0 then
begin
if (e[ip,1,j]0) then ok:=false;
if (e[ip,1,j]>0)and(check[j]0 then inc(k);
if k>1 then ok:=false;//日期
for j:=1 to 7 do
if e[ip,2,j]>0 then
begin
if data[j]0 then inc(k);
if k>1 then ok:=false;//搜索下一步
if ok then search(ip+1,iy);//返回修改
for j:=1 to m do
if e[ip,1,j]0 then dec(check[j],e[ip,1,j]);
for j:=1 to 7 do
if e[ip,2,j]>0 then dec(data[j],e[ip,2,j]);ok:=true;
//如果这个人说假话
for j:=1 to m do
if e[ip,1,j]0 then
begin
if (e[ip,1,j]0) then ok:=false;
inc(check[j],-e[ip,1,j]);
end;k:=0;
for j:=1 to m do
if check[j]>0 then inc(k);
if k>1 then ok:=false;//日期
for j:=1 to 7 do
if e[ip,2,j]>0 then
begin
if data[j]>0 then ok:=false;
inc(data[j],-e[ip,2,j]);
end;k:=0;
for j:=1 to 7 do
if data[j]>0 then inc(k);
if k>1 then ok:=false;//搜索下一步
if ok then search(ip+1,iy-1);
//返回修改
for j:=1 to m do
if e[ip,1,j]0 then dec(check[j],-e[ip,1,j]);
for j:=1 to 7 do
if e[ip,2,j]>0 then dec(data[j],-e[ip,2,j]);
end;begin
init;
search(1,n);
outit;
end. -
02009-10-30 08:07:38@
太水了,这是题吗?我姐姐嫩kk
-
02009-10-29 20:27:44@
type
proof=record
who,sin,dat:integer;
use:boolean;
end;
const
psbs1:array[1..2]of string=('am guilty.','am not guilty.');
psbs2:array[1..2]of string=('is guilty.','is not guilty.');
week:array[1..7]of string=('is Monday.','is Tuesday.','is Wednesday.',
'is Thursday.','is Friday.',
'is Saturday.','is Sunday.');
var
a:array[1..100]of proof;
b:array[1..100]of proof;
nm:array[1..20]of string;
rlog:array[1..20]of boolean;
log:array[1..20]of boolean;
clog:array[1..20,1..20]of boolean;
clog2:array[1..20,1..20]of boolean;
m,n,p,find,pl:integer;PROCEDURE analyse(s:string;num:integer);
var
i,j,t:integer;
ts:string;procedure DealI(s:string);
begin
a[num].sin:=a[num].who; a[num].dat:=8;
if s=psbs1[1] then a[num].use:=true
else if s=psbs1[2] then begin
a[num].dat:=0;
a[num].use:=true;
end
else a[num].use:=false;
end;procedure DealToday(s:string);
begin
a[num].sin:=0;
if s=week[1] then begin a[num].dat:=1; a[num].use:=true; end else
if s=week[2] then begin a[num].dat:=2; a[num].use:=true; end else
if s=week[3] then begin a[num].dat:=3; a[num].use:=true; end else
if s=week[4] then begin a[num].dat:=4; a[num].use:=true; end else
if s=week[5] then begin a[num].dat:=5; a[num].use:=true; end else
if s=week[6] then begin a[num].dat:=6; a[num].use:=true; end else
if s=week[7] then begin a[num].dat:=7; a[num].use:=true; end else
a[num].use:=false;
end;
function Dealsin(s:string):boolean;
var i:integer;
begin
if s=psbs2[1] then begin a[num].dat:=8; dealsin:=true end
else if s=psbs2[2] then begin
a[num].dat:=0;
dealsin:=true;
end
else dealsin:=false;
end;begin
i:=1;
while s[i]':' do inc(i);
ts:=copy(s,1,i-1);
for i:=1 to m do if ts=nm[i] then break;
a[num].who:=i; i:=length(nm[i]);
inc(i,3); j:=i;
while s[j]' ' do inc(j);
ts:=copy(s,i,j-i);
if ts='I' then DealI(copy(s,j+1,length(s)))
else if ts='Today' then DealToday(copy(s,j+1,length(s)))
else begin
a[num].use:=false;
for t:=1 to m do
if ts=nm[t] then
begin
a[num].use:=true;
a[num].sin:=t; break;
end;
if (a[num].use)and(not(dealsin(copy(s,j+1,length(s)))))
then a[num].use:=false;
end;
end;procedure finderror;
var i,j,t:integer;
begin
t:=0;
for i:=1 to p-1 do
for j:=i+1 to p do
if(b[i].who=b[j].who)and(log[b[i].who])
and(b[i].sin=b[j].sin)and(b[i].datb[j].dat)
then begin
b[i].use:=false;
b[j].use:=false;
log[b[i].who]:=false;
inc(t,2);
end
else begin
if (clog[b[i].who,b[j].who])and(log[b[i].who])and(log[b[j].who])
and(b[i].sin=b[j].sin)and(b[i].datb[j].dat)
then begin
clog[b[i].who,b[j].who]:=false;
clog[b[j].who,b[i].who]:=false;
end;
if (b[i].sin=b[j].sin)
and(b[i].dat=b[j].dat)
then begin
clog2[b[i].who,b[j].who]:=true;
clog2[b[j].who,b[i].who]:=true;
end;
end;
for i:=1 to p do if(log[b[i].who])and(b[i].sin=0)then
begin inc(t);b[i].use:=false;end;
p:=p-t;
end;PROCEDURE init;
var
i,j:integer;
s:string;
begin
readln(m,n,p);
For i:=1 To m do readln(nm[i]);
For i:=1 to p do
Begin
readln(s);
analyse(s,i);
End;
j:=0;
for i:=1 to p do if a[i].use then begin inc(j); b[j]:=a[i]; end;
p:=j; pl:=j;
fillchar(log,sizeof(log),true);
fillchar(clog,sizeof(clog),true);
fillchar(clog2,sizeof(clog2),false);
finderror;
fillchar(rlog,sizeof(rlog),false);
find:=0;
end;function judge(v:integer):boolean;
var i:integer;
begin
judge:=true;
for i:=1 to v do
if (rlog[i])and(not clog) then begin judge:=false; exit; end;
end;function judge2:boolean;
var i,j:integer;
begin
judge2:=true;
for i:=1 to pl-1 do
for j:=i+1 to pl do
if (b[i].use)and(b[j].use)and(not rlog[b[i].who])and(not rlog[b[j].who])
and(not clog[b[i].who,b[j].who])
then exit(false);
end;function judge3:boolean;
var i,j:integer;
begin
judge3:=true;
for i:=1 to pl-1 do
for j:=i+1 to pl do
if (b[i].use)and(b[j].use)and(rlog[b[i].who] xor rlog[b[j].who])
and(clog2[b[i].who,b[j].who])
then exit(false);
end;function works:boolean;
var i,sin:integer;
bool:array[1..20]of integer;
begin
if not((judge2)and(judge3)) then exit(false);
sin:=0;
for i:=1 to m do bool[i]:=2;
for i:=1 to pl do
if b[i].use then begin
if rlog[b[i].who] then
begin
if b[i].dat=8 then begin
bool[b[i].sin]:=1;
find:=b[i].sin;
end
else bool[b[i].sin]:=0;
end
else begin
if b[i].dat=0 then begin
bool[b[i].sin]:=1;
find:=b[i].sin;
end
else bool[b[i].sin]:=0;
end;
end;
for i:=1 to m do if bool[i]=1 then begin inc(sin); find:=i; end;
if sin>1 then exit(false);
if sin=1 then exit(true)
else begin
for i:=1 to m do if bool[i]0 then begin inc(sin); find:=i; end;
if sin=1 then exit(true)
else begin find:=0; exit(false); end;
end;
end;
PROCEDURE WORK(start,stg:integer);
var i:integer;
begin
if (stg=m-n+1) then begin
if works then begin write(nm[find]); halt; end;
exit;
end;
for i:=start to n+stg do
if log[i]and(judge(i))then
begin
rlog[i]:=true;
work(i+1,stg+1);
rlog[i]:=false;
end;
end;
BEGIN
assign(input,'ph03_2.in'); reset(input);
assign(output,'ph03_2.out'); rewrite(output);
init;
if p>0 then begin
if n -
02009-10-29 12:06:34@
WS的题
纯粹教导孩子们浪费时间的………… -
02009-10-11 14:21:49@
to tylovect
......
procedure setup;
begin
assign(input,'logic.in');
assign(output,'logic.out');
rewrite(output);
reset(input);
...... -
02009-09-27 15:08:34@
真是令人郁闷的题目,一编就是150+行.....
一点不小心就会错了....不过幸好有数据在..... -
02009-09-01 23:37:10@
枚举日期和罪犯
然后对每句证词进行核对
计算出说谎人数,然后看情况输出结果要注意的地方有以下几点
1.某些的人说的话与结果无关.真的假的都可以,
只要在后面再枚举人数就好.
2.对应的某些日期和罪犯的组合会使某些人既说真话,也说假话,
因此这些日期与罪犯的组合是无效的,一旦发现直接跳过.
3.证词实质上只有3类,某某是罪犯,某某不是罪犯,今天星期几.
4.所谓多解是罪犯的多解,不是时间的多解,更不是说谎的人的组合的多解.最后请注意
样例中的数据有问题.
第一,冒号后面没空格
第二,其中有一行的句号不是标准的句号,请把所有句号自行更换,否则自己手动输入样例. -
02009-08-28 14:14:42@
可恶可恶可恶真可恶!我试了N都没对!
-
02009-08-27 11:59:37@
有说一句话的末尾无空格的么?..
-
02009-08-05 12:35:51@
囧了……
这道题我的参考书上有……
高兴ing……
把书上的源程序敲上去,70分……
挂了…… -
02009-08-04 15:40:25@
这道题关键就是处理废话(这是废话)
废话是很关键的!(这不是废话!)
然后呢~~~你想做错也难了!(还是废话)目前排名234,AC182~~~~目标冲进200,AC200
-
02009-07-23 21:59:03@
提交时怎么会冒出来一句“您提交的程序里含有非法字符串Assign”呢??
const
data:array[1..7] of string = ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
maxm=20;
maxp=100;var
cent:array[1..maxp] of
record
whosay:longint;
man:longint;
ctype:0..3;
data:longint;
end;
name:array[1..maxm] of string;
i,j,k,n,m,l,np,p:longint;
ntrue,nfalse,pt:longint;
s,s1:string;
namenum,gustname:longint;
whosay:longint;
pp:boolean;procedure insert;
var
i:longint;function findname(s:string):longint;
var i:longint;
begin
for i:= 1 to m do
if name[i] = s then exit(i);
exit(0);
end;begin
readln(s);i:= 1;
s1:= '';
while (i length(s) then exit;
namenum:= findname(s1);
if namenum = 0 then exit;
delete(s,1,i+1);
if s = 'I am guilty.' then
with cent[np+1] do
begin
whosay:= namenum;
man:= namenum;
ctype:= 1;
inc(np);
end;
if s = 'I am not guilty.' then
with cent[np+1] do
begin
whosay:= namenum;
man:= namenum;
ctype:= 2;
inc(np);
end;s1:= '';
i:= 1;
while (i length(s) then exit;
delete(s,1,i);
if s1='Today' then
begin
delete(s,1,3);
delete(s,length(s),1);
for i:= 1 to 7 do
if s = data[i] then
with cent[np+1] do
begin
whosay:= namenum;
ctype:= 3;
data;= i;
inc(np);
inc(pt);
end;
end;gustname:= findname(s1);
if gustname = 0 then exit;
if s = 'is guilty.' then
with cent[np+1] do
begin
whosay:= namenum;
man:= gustname;
ctype:= 1;
inc(np);
end;
if s = 'is not guilty.' then
with cent[np+1] do
begin
whosay:= namenum;
man:= gustname;
ctype:= 2;
inc(np);
end;
end;procedure setup;
begin
assign(input,'logic.in');
assign(output,'logic.out');
rewrite(output);
reset(input);
pt:= 0;
readln(m,n,p);
np:= 0;
for i:= 1 to m do readln(name[i]);
for i:= 1 to p do insert;
end;procedure work;
var
possibility,d,en:longint;
day,guilty,guiltyname:longint;
rec:array[1..maxm] of integer;function check:boolean;
var p:boolean;function insertture(whosay:longint):boolean;
begin
if rec[whosay] = n) and (nfalse 1 then writeln('Cannot Determine; ');
if possibility = 1 then writeln(name[guiltyname],' ');
end;begin
setup;
work;
close(input); close(output);
end. -
02009-07-10 08:43:00@
样例冒号后少了空格,还有某一行多了一个奇怪的符号……
证词的处理,要小心呀。发个数据吧。
4 1 5
KYO
IORI
CHIZURU
OROCHI
KYO: I am guilty.
IORI: I am not guilty.
CHIZURU: OROCHI is guilty.
OROCHI: Today is Monday.
OROCHI: I am guilty.OROCHI
-
02009-07-03 22:30:40@
真是幽默......
竟然写了一个过不了样例的程序还AC了......而且输入格式竟然说"第一行有二个整数,M(1≤M≤20)、N(1≤N≤M)和P(1≤P≤100)"