⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac1271.pas

📁 这是在网络上搜集到的在东京大学的ACM上面解决的一些题目的源码
💻 PAS
字号:
program tju1271;
const
  maxl=255;
var
  s:array[0..maxl]of char;
  f:array[1..maxl,1..maxl]of byte;
  l,i,j,k,t,x:byte;
begin
  repeat
    l:=0;
    while not eoln do begin
      read(s[l+1]);
      if (s[l]='(') and (s[l+1]=')') or (s[l]='[') and (s[l+1]=']') then dec(l) else inc(l);
    end;
    readln;
    if l=0 then begin writeln(0);continue;end;

    for i:=1 to l do f[i,i]:=1;
    for k:=1 to l-1 do
      for i:=1 to l-k do begin
        j:=i+k;
        if (s[i]='(') and (s[j]=')') or (s[i]='[') and (s[j]=']') then f[i,j]:=f[i+1,j-1] else f[i,j]:=255;
        for x:=i to j-1 do begin
          t:=f[i,x]+f[x+1,j];if t<f[i,j] then f[i,j]:=t;
        end;
      end;
    writeln(f[1,l]);
  until eof;//Caution! Empty string exists in input!
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -