存程序

P2787 语文1(chin1)- 理理思维

@[张智洋](/space/show?uid=1252) 事实上,你可以私信附件发给自己
by 1124828077ccj @ 2016-09-14 22:05:17


~~看我是不是很机智~~
by 1124828077ccj @ 2016-09-14 22:05:56


666
by 张智洋 @ 2016-09-19 22:41:02


然而私信存不下 ```cpp program aaa; type point=record c:array[1..26] of longint; cover:longint; end; var n,m,i,k,x,y,o,tmp,j,j2:longint; pos1:char; s:array[0..50000] of char; t:array[0..200000] of point; procedure build(p,l,r:longint); var m,j:longint; begin t[p].cover:=0; if l=r then begin t[p].c[ord(s[l])-64]:=1; exit; end; m:=(l+r) shr 1; build(p*2,l,m); build(P*2+1,m+1,r); for j:=1 to 26 do t[p].c[j]:=t[p*2].c[j]+t[p*2+1].c[j]; end; procedure change(p,l,r:longint;var px,py,po:longint); var mid:longint; begin if t[p].cover<>0 then begin fillchar(t[p].c,sizeof(t[p].c),0); t[p].c[t[p].cover]:=r-l+1; t[2*p].cover:=t[p].cover; t[2*p+1].cover:=t[p].cover; end; if (l>=px) and (r<=py) then begin t[p].cover:=po; exit; end; mid:=(l+r) shr 1; if px<=mid then change(p*2,l,mid,px,py,po); if py>mid then change(p*2+1,mid+1,r,px,py,po); end; function answer(p,l,r:longint;var px,py,po:longint):longint; var mid,xs,xi:longint; begin if t[p].cover<>0 then begin for xi:=1 to 26 do t[p].c[xi]:=0; t[p].c[t[p].cover]:=r-l+1; t[2*p].cover:=t[p].cover; t[2*p+1].cover:=t[p].cover; t[p].cover:=0; end; if l=r then exit(t[p].c[po]); mid:=(l+r) shr 1; if py<=mid then exit(answer(p*2,l,mid,px,py,po)); if px>mid then exit(answer(P*2+1,mid+1,r,px,py,po)); xs:=mid+1; if (px<=mid) and (py>mid) then exit(answer(p*2,l,mid,px,mid,po)+answer(P*2+1,mid+1,r,xs,py,po)); for xi:=1 to 26 do t[p].c[xi]:=t[p*2].c[xi]+t[p*2+1].c[xi]; end; procedure sort(p,l,r:longint;var px,py:longint); var begin end; begin readln(n,m); for i:=1 to n do begin read(s[i]); if (s[i]<='z') and (s[i]>='a') then s[i]:=chr(ord(s[i])-32); end; build(1,1,n); for i:=1 to m do begin read(o); if o=1 then begin read(x,y,pos1); while pos1=' ' do read(pos1); readln; tmp:=ord(pos1)-64; writeln(answer(1,1,n,x,y,tmp)); end; if o=2 then begin read(x,y,pos1); while pos1=' ' do read(pos1); readln; tmp:=ord(pos1)-64; change(1,1,n,x,y,tmp); end; if o=3 then begin readln(x,y); sort(1,1,n,x,y); end; end; end. ```
by 张智洋 @ 2016-09-19 22:42:40


事实是,最机智的方式是交一次
by owogon @ 2017-04-26 11:57:36


+1
by 斯德哥尔摩 @ 2017-10-19 15:46:37


为什么不试试神奇的云剪贴板呢
by dreagonm @ 2018-08-29 11:23:33


|