2784: 【提高】小 X 与煎饼达人(flip)

var
a,f:array[1..10000000] of longint;
b,i,j,n,s,x,y:longint;
begin

read(b,n);
for i:=1 to n do
a[i]:=0;
for i:=1 to n do
begin
readln(x,y);
a[x]:=1-a[x];
a[y+1]:=1-a[y+1];
end;
for i:=1 to b do
begin
if a[i]=1
then s:=s+1;
f[i]:=s mod 2;
end;
s:=0;
for i:=1 to b do
if f[i]=1
then s:=s+1;
writeln(s);

end.

转载于:https://www.cnblogs.com/Steven-Skywalker/p/7083430.html

你可能感兴趣的:(2784: 【提高】小 X 与煎饼达人(flip))