| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么Run Time Error?官方数据都过了...请各位来看看,我调了4个小时program p1128;
const
inf='';
ouf='';
type
str=string;
var
bool:array['A'..'Z']of boolean;
a:array[0..200,0..200]of char;
b:array['A'..'Z']of record
x,y,w,z:longint;
end;
line:array['A'..'Z']of longint;
map:array['A'..'Z','A'..'Z']of longint;
s:str;
n,m,i,j,k,l,top,total:longint;
procedure pre;
var
i,j:longint;
ch,ch2:char;
begin
for i:=1 to n do
for j:=1 to m do
if a[i,j] in ['A'..'Z'] then
begin
if (b[a[i,j]].x=0)or(b[a[i,j]].x>i) then b[a[i,j]].x:=i;
if (b[a[i,j]].y=0)or(b[a[i,j]].y>j) then b[a[i,j]].y:=j;
if (b[a[i,j]].w=0)or(b[a[i,j]].w<i) then b[a[i,j]].w:=i;
if (b[a[i,j]].z=0)or(b[a[i,j]].z<j) then b[a[i,j]].z:=j;
end;
for ch:='A' to 'Z' do
if not((b[ch].x=0)and(b[ch].y=0)and(b[ch].w=0)and(b[ch].z=0)) then
begin
for i:=b[ch].x to b[ch].w do
begin
if a[i,b[ch].y]<>ch then map[ch,a[i,b[ch].y]]:=1;
if a[i,b[ch].z]<>ch then map[ch,a[i,b[ch].z]]:=1;
end;
for i:=b[ch].y to b[ch].z do
begin
if a[b[ch].x,i]<>ch then map[ch,a[b[ch].x,i]]:=1;
if a[b[ch].w,i]<>ch then map[ch,a[b[ch].w,i]]:=1;
end;
end;
for ch:='A' to 'Z' do
for ch2:='A' to 'Z' do
if map[ch2,ch]<>0 then inc(line[ch]);
end;
procedure make(i:longint);
var
top:longint;
ch,ch2:char;
begin
for ch:='A' to 'Z' do
if (line[ch]=0)and(bool[ch]=false) then
begin
top:=0;
for ch2:='A' to 'Z' do
if map[ch,ch2]<>0 then
begin
inc(top);
dec(line[ch2]);
map[ch,ch2]:=-1;
end;
s:=s+ch;
bool[ch]:=true;
if i=total then
writeln(s)
else make(i+1);
bool[ch]:=false;
delete(s,length(s),1);
for ch2:='A' to 'Z' do
if map[ch,ch2]=-1 then
begin
inc(line[ch2]);
map[ch,ch2]:=1;
end;
end;
end;
procedure pre2;
var
ch:char;
begin
for ch:='A' to 'Z' do
if bool[ch] then line[ch]:=0
else line[ch]:=-1;
end;
begin
assign(input,inf);assign(output,ouf);
reset(input);rewrite(output);
readln(n);
readln(m);
total:=0;
s:='';
top:=0;
fillchar(bool,sizeof(bool),false);
fillchar(b,sizeof(b),0);
fillchar(map,sizeof(map),0);
for i:=1 to n do
begin
for j:=1 to m do
begin
read(a[i,j]);
if (bool[a[i,j]]=false)and(a[i,j] in ['A'..'Z']) then
begin
bool[a[i,j]]:=true;
total:=total+1;
end;
end;
readln;
end;
pre2;
fillchar(bool,sizeof(bool),false);
pre;
make(1);
close(input);close(output);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator