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