???CF652C???Foe Pairs??????????????????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了???CF652C???Foe Pairs??????????????????相关的知识,希望对你有一定的参考价值。
?????????res log ?????? air ?????? ?????? int ?????? cti
???????????????1-n??????????????????m???????????????????????????????????????????????????????????? (1?????n,?m?????3??105)
???????????????????????????????????????????????????
f[i]???????????????i????????????????????????????????????????????????
?????????=??????-????????????
1 var f,c:array[1..310000]of int64; 2 n,m,x,y,t:int64; 3 i:longint; 4 ans:int64; 5 6 function min(x,y:int64):int64; 7 begin 8 if x<y then exit(x); 9 exit(y); 10 end; 11 12 begin 13 //assign(input,???cf652C.in???); reset(input); 14 // assign(output,???cf652C.out???); rewrite(output); 15 read(n,m); 16 for i:=1 to n do 17 begin 18 read(x); 19 c[x]:=i; f[i]:=n+1; 20 end; 21 ans:=n*(n+1) div 2; 22 for i:=1 to m do 23 begin 24 read(x,y); 25 if c[x]>c[y] then begin t:=x; x:=y; y:=t; end; 26 f[c[x]]:=min(f[c[x]],c[y]); 27 end; 28 for i:=n-1 downto 1 do f[i]:=min(f[i],f[i+1]); 29 for i:=1 to n-1 do ans:=ans-(n-f[i]+1); 30 writeln(ans); 31 // close(input); 32 // close(output); 33 end.
以上是关于???CF652C???Foe Pairs??????????????????的主要内容,如果未能解决你的问题,请参考以下文章