题面:
思路:
蚂蚁问题,转头可以忽略不计。模拟。
注意L从0开始计算。
代码:
var t,n,len,i:longint; a:array[0..100005] of longint; ch,rrr:char; procedure sort(l,r: longint); var i,j,x,y: longint; begin i:=l; j:=r; x:=a[(l+r) div 2]; repeat while a[i]j) then begin y:=a[i]; a[i]:=a[j]; a[j]:=y; inc(i); j:=j-1; end; until i>j; if l len then a[i]:=len-(a[i]-len); end else a[i]:=a[i]-t; end; if ch='D' then begin if a[i]+t>len then begin a[i]:=len-(t-(len-a[i])); if a[i]<0 then a[i]:=a[i]*(-1); end else a[i]:=a[i]+t; end; end;sort(1,n);for i:=1 to n do write(a[i],' ');close(input);close(output);end.