这一把打得还算过得去。。。

最大问题在于A题细节被卡了好久。。。连续被hack两次。。。

B题是个规律题。。。C题也是一个细节题。。。D由于不明原因标程错了被删掉了。。。E是个线段树套矩阵。。。

考试的时候过了ABC三个。。。

Problem A:

这题纯细节,只要看最后两个数就可以了。(注意n=1的情况以及最后一个数是0或者15的情况)

代码如下:

 var n,i:longint;
a:array[..] of longint;
begin
readln(n);
fillchar(a,sizeof(a),);
for i:= to n do
read(a[i]);
readln;
if (a[n]=) then writeln('UP')
else if (a[n]=) then writeln('DOWN')else
if (n=) then writeln('-1')
else if (a[n]<a[n-]) or (a[n]=) then writeln('DOWN')
else writeln('UP');
end.

Problem B:

这题是个规律题。。。(或者说贪心)

先考虑010101的情况,并且假装(嗯,就是假装)不能进行染色,然后跑出最大值,

另一种情况一样处理,最后两个最大值较小的一个就是答案。

代码如下:

 uses math;
var n,i,j,ans,ans1,ans2:longint;
a:array[..] of longint;
x:char;
begin
readln(n);
fillchar(a,sizeof(a),);
for i:= to n do
begin
read(x);
if (x='r') then a[i]:=;
end;
ans1:=;
ans2:=;
for i:= to n do
begin
if (i mod =) and (a[i]=) then inc(ans1);
if (i mod =) and (a[i]=) then inc(ans2);
end;
ans:=max(ans1,ans2);
ans1:=;
ans2:=;
for i:= to n do
begin
if (i mod =) and (a[i]=) then inc(ans1);
if (i mod =) and (a[i]=) then inc(ans2);
end;
ans:=min(ans,max(ans1,ans2));
writeln(ans);
end.

Problem C:

这题是一个细节题。。。

先把大于等于5的或者等于4且后面一个数字可能进位的全部分开处理出来,

然后跑贪心就可以了,注意细节。。。

(P.S.这题的pretest非常弱。。。然后比赛结束发现room一堆人过了。。。第二天看的时候只有我和另一个人过了hhh)

代码如下:

 var n,k,i,j,t,tmp,now,noww,cnt:longint;
a:array[..] of char;
flag:array[..] of longint;
begin
readln(n,t);
for i:= to n do
begin
read(a[i]);
if (a[i]='.') then cnt:=i;
end;
readln;
fillchar(flag,sizeof(flag),);
if (ord(a[n])>=+) then flag[n]:=;
for i:=n- downto tmp+ do
if (ord(a[i])>=+) then flag[i]:= else if ((flag[i+]>) and (a[i]='')) then flag[i]:=;
now:=cnt+;
while (now<=n) and (flag[now]<>) do inc(now);
if (now=n+) then
begin
j:=n;
while (j>cnt) and (a[j]='') do dec(j);
if (j=cnt) then j:=cnt-;
for i:= to j do
write(a[i]);
writeln;
end
else
begin
noww:=;
while (noww<=t) do
begin
if (flag[now-]=) then flag[now-]:=;
now:=now-;
if (flag[now]<>) then break;
inc(noww);
end;
if (now=cnt) then
begin
j:=cnt-;
while (j>=) do
begin
if (a[j]='') then
begin
a[j]:='';
dec(j);
end
else
begin
a[j]:=chr(ord(a[j])+);
break;
end;
end;
if (j=) then write('');
for i:= to cnt- do
write(a[i]);
writeln;
end
else
begin
j:=now;
while (j>=) do
begin
if (a[j]='') then
begin
a[j]:='';
dec(j);
if (j=cnt) then j:=cnt-;
end
else
begin
a[j]:=chr(ord(a[j])+);
break;
end;
end;
if (j=) then write('');
for i:= to cnt- do
write(a[i]);
j:=now;
while (j>=cnt+) and (a[j]='') do dec(j);
if (j>=cnt+) then
begin
write('.');
for i:=cnt+ to j do
write(a[i]);
end;
writeln;
end;
end;
end.

Problem E:

这题是一个经典线段树,和模版题不同的是这题需要将原先的数字全部替换成矩阵。

中间用到一系列的快速幂,Fibonacci数列等运算。。。

然后卡卡常就能过了。。。

注意线段树调用的时候参数越少越好。。。(感谢cyand神犇QAQQQ)

代码如下:

 type arr=array[..,..] of int64;
nodetype=record
sum,cover:arr;
flag:boolean;
lx,rx:longint;
end;
const modp=;
fff:arr=((,),(,));
one:arr=((,),(,));
onee:arr=((,),(,));
oneee:arr=((,),(,));
var t:array[..] of nodetype;
a:array[..] of longint;
i,j,n,m,op,x,y,z:longint;
xx:arr;
x1,y1:int64;
function plus(a,b:arr):arr;
var ans:arr;
i,j:longint;
begin
for i:= to do
begin
ans[i,]:=(a[i,]+b[i,]) mod modp;
ans[i,]:=(a[i,]+b[i,]) mod modp;
end;
exit(ans);
end;
function time(a,b:arr):arr;
var ans:arr;
i,j,k:longint;
begin
for i:= to do
for j:= to do
ans[i,j]:=(a[i,]*b[,j]+a[i,]*b[,j]) mod modp;
exit(ans);
end;
function try1(i:longint):arr;
var ans,now:arr;
left:longint;
begin
ans:=one;
now:=oneee;
left:=i;
while (left>) do
begin
if (left mod =) then ans:=time(ans,now);
left:=left div ;
now:=time(now,now);
end;
exit(ans);
end;
procedure build(node,lx,rx:longint);
var mid:longint;
begin
if (lx=rx) then
begin
t[node].sum:=time(fff,try1(a[lx]-));
t[node].cover:=one;
t[node].lx:=lx;
t[node].rx:=rx;
end
else
begin
mid:=(lx+rx) div ;
build(node*,lx,mid);
build(node*+,mid+,rx);
t[node].sum:=plus(t[node*].sum,t[node*+].sum);
t[node].cover:=one;
t[node].lx:=lx;
t[node].rx:=rx;
end;
end;
procedure pushdown(node:longint);
begin
if not(t[node].flag) then exit;
t[node*].cover:=time(t[node*].cover,t[node].cover);
t[node*+].cover:=time(t[node*+].cover,t[node].cover);
t[node*].sum:=time(t[node*].sum,t[node].cover);
t[node*+].sum:=time(t[node*+].sum,t[node].cover);
t[node*].flag:=true;
t[node*+].flag:=true;
t[node].cover:=one;
t[node].flag:=false;
end;
procedure updata(node:longint);
var mid:longint;
begin
if (t[node].lx>y) or (t[node].rx<x) then exit;
if (t[node].lx>=x) and (t[node].rx<=y) then
begin
t[node].cover:=time(t[node].cover,xx);
t[node].sum:=time(t[node].sum,xx);
t[node].flag:=true;
exit;
end;
pushdown(node);
mid:=(t[node].lx+t[node].rx) div ;
updata(node*);
updata(node*+);
t[node].sum:=plus(t[node*].sum,t[node*+].sum);
end;
function query(node:longint):arr;
var mid:longint;
begin
if (t[node].lx>y) or (t[node].rx<x) then exit(onee);
if (t[node].lx>=x) and (t[node].rx<=y) then exit(t[node].sum);
pushdown(node);
mid:=(t[node].lx+t[node].rx) div ;
exit(plus(query(node*),query(node*+)));
end;
begin
readln(n,m);
fillchar(t,sizeof(t),);
for i:= to n do
read(a[i]);
readln;
build(,,n);
for i:= to m do
begin
read(op);
if (op=) then
begin
readln(x,y,z);
xx:=try1(z);
updata();
end
else
begin
readln(x,y);
writeln(query()[,]);
end;
end;
end.

完结撒花!

codeforces round373(div.2) 题解的更多相关文章

  1. codeforces round375(div.2)题解

    首先吐槽一下这套题...为什么EF全是图论QAQ 过了ABCD四个题...F的并查集死磕了好久... 不过似乎rank还算乐观...(因为ABC都是一次过的QAQ) Problem A: 啥都不想说Q ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  4. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  5. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  6. Educational Codeforces Round 64 (Rated for Div. 2)题解

    Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...

  7. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  8. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  9. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

随机推荐

  1. servlet层调用biz业务层出现浏览器 500错误,解决方法 dao数据访问层 数据库Util工具类都可能出错 通过新建一个测试类复制代码逐步测试查找出最终出错原因

    package com.swift.jztk.servlet; import java.io.IOException; import javax.servlet.ServletException; i ...

  2. 32-2题:LeetCode102. Binary Tree Level Order Traversal二叉树层次遍历/分行从上到下打印二叉树

    题目 给定一个二叉树,返回其按层次遍历的节点值. (即逐层地,从左到右访问所有节点). 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 ...

  3. Mysql 查询出某列字段 被包含于 条件数据中

    我们通常是使用  某条件  是否包含于 某列中   ,简单点 就是:select * from 表名 where  字段名 like '%条件数据%'; 现在说下   某列 被包含于 条件数据中 接下 ...

  4. arduino 语音音箱 :语音控制、MP3播放、报时、回复温湿度情况

    arduino 语音音箱 :语音控制.MP3播放.报时.回复温湿度情况 效果图 线路图 包装后的效果 功能 需要材料 arduino板 MP3播放模块及喇叭 时钟模块 温湿度模块 语音识别模块 面包板 ...

  5. nginx下根据指定路由重定向

    前言: 最近在搭建vue后台,后端接口是PHP写的,线上构建好之后,需要请求其他域名下的接口,开发环境已经使用proxytable解决了接口问题,为了开发和生成的代码一致, 编译后的代码,放在ngin ...

  6. Centos 6版本Device eth0 does not seem to be present,delaying initialization.故障处理

    1.1  故障现象 2019年06月14日晚上,公司项目组说有台业务服务器连接不上,比较着急,我通过vpn拨入的方式远程登录到管理控制台查看发现网卡没有获取到IP地址,我尝试重启来重新启动,重启的时候 ...

  7. yii2 RUL的生成

    通常情况下,会使用 yii\helpers\Url 使用Url类来生成想要的URL地址(链接) Url提供的方法大都是静态方法,不需要对类进行实例化 1.1 最常用的 Url::to() 1.2. b ...

  8. Android四大基本组件介绍及生命周期

    Android四大基本组件分别是Activity,Service服务,Content Provider内容提供者,BroadcastReceiver广播接收器. 一.了解四大基本组件 Activity ...

  9. pandas知识点(基本功能)

    1.重新索引 如果reindex会根据新索引重新排序,不存在的则引入缺省: In [3]: obj = Series([4.5,7.2,-5.3,3.6], index=["d", ...

  10. 江西理工大学编程俱乐部 2328 Star

    : Star 时间限制: C/C++ s Java/Python s 内存限制: MB 答案正确: 提交: 题目描述 31世纪,人类世界的科技已经发展到了空前的高度,星际移民,星际旅游早已经不再是问题 ...