比赛 20140713上午练习 评测结果 AWAWWWWWAA
题目名称 调试LED灯 最终得分 40
用户昵称 甘罗 运行时间 1.587 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2014-07-13 10:19:48
显示代码纯文本
  1. program zht;
  2. var
  3. l,i,j,n,zs:longint;
  4. z:array[1..33] of integer;
  5. a:ansistring;
  6. begin
  7. assign(input,'testled.in');
  8. assign(output,'testled.out');
  9. reset(input);
  10. rewrite(output);
  11. readln(l);
  12. readln(a);
  13. for i:=1 to l do
  14. z[i]:=ord(a[i])-48;
  15. readln(n);
  16. readln(a);
  17. for i:=1 to n do
  18. begin
  19. if a[i]='a' then begin for j:=1 to l do z[j]:=1;continue;end;
  20. if a[i]='b' then begin for j:=1 to l do z[j]:=0;continue;end;
  21. if a[i]='c' then begin for j:=1 to l do if z[j]=1 then z[j]:=0 else z[j]:=1;continue;end;
  22. if a[i]='1' then begin for j:=l downto 1 do if j mod 2=1 then if z[l-j+1]=1 then z[l-j+1]:=0 else z[l-j+1]:=1;continue;end;
  23. if a[i]='2' then begin for j:=l downto 1 do if j mod 2=1 then if z[l-j+1]=1 then z[l-j+1]:=0 else z[l-j+1]:=1;continue;end;
  24. for j:=1 to ord(a[i])-48 do
  25. z[j]:=0;
  26. for j:=l downto l-(ord(a[i])-48)+1 do
  27. z[j]:=1;
  28. end;
  29. for i:=1 to l do
  30. begin
  31. write(z[i]);
  32. if z[i]=1 then zs:=zs+1;
  33. end;
  34. writeln;
  35. writeln(zs);
  36. close(input);
  37. close(output)
  38. end.