这周写过好多东西,虽然还没有完全弄明白线段树,但是progress还是有的!
不过有时候真的很想哭,因为自己的梦想连别人看看韩剧、无所事事还要分量轻,实在不明白政治课的Teamwork意义何在,花两分钟百度文库找了个PPT和论文扔给我就交差,你也不先看看这些专业术语你看不看得懂!!这周五开始我不上QQ了,为的就是不要有人以为我在线就说明我很空闲然后扔一坨事情给我做!(好吧这个博客不是用来吐槽生活的,回正轨)
上周六回家瞄了一眼Codeforces,发现15分钟后有一场比赛,不过我等级不够只能参加Round #233 div 2。半小时内把A和B给做了。然后…然后…C还没搞定,Codeforces就跪了,而且是长跪不起。(最后的结果是整个服务器倒退到三周前的备份,于是我还重新注册了个账号,#233 div 2的题目貌似也不见了?!)
A题 浏览器翻页界面的模拟
program cf__A;
var n,p,k,h,r,now:integer;
begin
readln(n,p,k);
h:=p-k;
if h< then h:=;
r:=p+k;
if r>n then r:=n;
if h> then write('<<');
for now:=h to r do
begin
if now= then
if now=p then write('(',p,')') else write(now)
else if now=p then write(' (',p,')') else write(' ',now);
end;
if r<n then write(' >>');
end.
CF_233_A
B题 按要求塞球,不过找找规律就知道其实是二进制转十进制…
program cf__B;
var s:array[..] of integer;
n,i:longint;
str:string;
two,ans:int64;
function check:boolean;
var i:integer;
begin
for i:= to n do
if s[i]= then exit(false);
exit(true);
end; begin
readln(n);
readln(str);
for i:= to n do
if str[i]='R' then s[i]:= else s[i]:=;
two:=;ans:=;
for i:= to n do
begin
if s[i]= then ans:=ans+two;
two:=two*;
end;
writeln(ans);
end.
CF_233_B
这场比赛的编号是#233,冥冥中注定了当晚的悲剧…
还有昨天上课码的mrzx,昨晚精神特别好,而且题目简单易懂,所以一个半小时4题~~\(≧▽≦)/~
mr442 潜望镜 模拟即可 话说注意坐标和m、n的关系,我就因为这个搞反调了20min
program mr442;
const dy:array[..] of integer=(,,,-);
dx:array[..] of integer=(-,,,);
var m,n,i,j,t:integer;
a:array[..,..] of char;
procedure solve(x,y,direct:integer);
begin
repeat
if a[x,y]='*' then
begin
x:=x+dx[direct];
y:=y+dy[direct];
end;
if a[x,y]='/' then
begin
if direct= then direct:= else
if direct= then direct:= else
if direct= then direct:= else
if direct= then direct:=;
x:=x+dx[direct];y:=y+dy[direct];
end;
if a[x,y]='\' then
begin
if direct= then direct:= else
if direct= then direct:= else
if direct= then direct:= else
if direct= then direct:=;
x:=x+dx[direct];y:=y+dy[direct];
end;
until not (a[x,y] in ['/','*','\']);
if x= then writeln(y);
if x=n+ then writeln(m+y);
if y= then writeln(*m+x);
if y=m+ then writeln(*m+n+x);
end; begin
assign(input,'mr442.in4');reset(input);
assign(output,'mr442.ou4');rewrite(output);
readln(n,m);
t:=n;n:=m;m:=t;
for i:= to n do
begin
for j:= to m do
read(a[i,j]);
readln;
end;
for i:= to m do solve(,i,);
for i:= to m do solve(n,i,);
for i:= to n do solve(i,,);
for i:= to n do solve(i,m,);
close(input);close(output);
end.
潜望镜
mr443 Anna取数 看上去难道是博弈论?我勒个擦最后是打表…
program mr443;
var f:array[..] of boolean;
n,i,t,min,max:longint; procedure solve(x:longint);
var t:integer;
begin
min:=;max:=;
while x> do
begin
t:=x mod ;
if t>max then max:=t;
if (t<min) and (t<>) then min:=t;
x:=x div ;
end;
end; procedure process;
var i:longint;
begin
for i:= to do f[i]:=true;
for i:= to do
begin
solve(i);
f[i]:=not (f[i-max] and f[i-min]);
end;
end; begin
assign(input,'mr443.in4');reset(input);
assign(output,'mr443.ou4');rewrite(output);
fillchar(f,sizeof(f),false);
process;
readln(n);
for i:= to n do
begin
readln(t);
if f[t]=true then writeln('YES') else writeln('NO');
end;
close(input);close(output);
end.
Anna取数
mr444 筷子 有点逗的题目,我都想到排序了怎么会没想到动归呢!话说看到什么差的平方和最小脑子偏到逆序对去了- =
program mr444;
var n,k,i,j:integer;
f:array[..,..] of integer;
ll:array[..] of integer;
function min(x,y:integer):integer;
begin
if x<y then exit(x) else exit(y);
end; procedure qsort(l,r:integer);
var mid,i,j,temp:integer;
begin
mid:=ll[(l+r) div ];
i:=l;j:=r;
repeat
while ll[i]<mid do inc(i);
while ll[j]>mid do dec(j);
if i<=j then
begin
temp:=ll[i];ll[i]:=ll[j];ll[j]:=temp;
inc(i);dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end; begin
assign(input,'mr444.in0');reset(input);
assign(output,'mr444.ou0');rewrite(output);
readln(n,k);
if n<*(k+) then
begin
writeln('-1');
close(input);close(output);
halt;
end;
for i:= to n do
read(ll[i]);
qsort(,n);
k:=k+;
for i:= to n do
for j:= to min(i div ,k) do
begin
f[i,j]:=f[i-,j-]+sqr(ll[i]-ll[i-]);
if (j*<=i-) and (f[i,j]>f[i-,j]) then
f[i,j]:=f[i-,j];
end;
writeln(f[n,k]);
close(input);close(output);
end.
筷子
mr445 饲料槽 这个倒是被我一眼看出动归了,手推了一下还是一维的!话说后来翻了翻貌似在usaco精选里也有这个?我是按区间右端排序的,上课讲的是从后往前推的,其实没太大差别。
program mr445;
var f:array[..] of longint;
ql,qr:array[..] of longint;
b,n,i,t:longint;
procedure qsort(l,r:integer);
var mid,i,j,temp:longint;
begin
i:=l;j:=r;mid:=qr[(i+j) div ];
repeat
while qr[i]<mid do inc(i);
while qr[j]>mid do dec(j);
if i<=j then
begin
temp:=qr[i];qr[i]:=qr[j];qr[j]:=temp;
temp:=ql[i];ql[i]:=ql[j];ql[j]:=temp;
inc(i);dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end; begin
assign(input,'mr445.in5');reset(input);
assign(output,'mr445.ou5');rewrite(output);
fillchar(f,sizeof(f),$);
f[]:=;
readln(b);
n:=;
for i:= to b do
begin
readln(ql[i],qr[i]);
if qr[i]>n then n:=qr[i];
end;
qsort(,b);
t:=;
for i:= to n do
begin
f[i]:=f[i-];
while qr[t]=i do
begin
if f[ql[t]-]+i-ql[t]+>f[i] then
f[i]:=f[ql[t]-]+i-ql[t]+;
inc(t);
end;
end;
writeln(f[n]);
close(input);close(output);
end.
饲料槽