洛谷模拟NOIP考试反思
洛谷模拟NOIP考试反思
想法
考了这么简单的试qwq然而依然emmmmmm成绩不好
虽然本次难度应该是大于正常PJ难度的但还是很不理想,离预估分数差很多qwq
于是就有了本反思嘤嘤嘤
比赛链接
原比赛链接(已结束但仍然可提交)
题目解析反思
第一题
超简单(虽然仍然没做对)
第二题
代码扔上来qwq(虽然还是不会)
第三题
代码
第四题
毒瘤极了wodema
据说原来数据是50%那里的,但是出题人z某灵机一动加到了1000orz
于是很多人自然而然地想到了状压DP
普及组是到不了这个难度的,主要是z某他太坏了
50分做法(状压)
正解的100分正法并非毒瘤状压qwq
(有人说爆搜能骗40分?!)
讲评者
XD
TG
还是放一道TG第三题压压惊好了
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int Max_N(100050);
const int Max_M(100050);
const int Max_Q(100050);
template<typename Type>
void gi(Type &Ret)
{
Ret = 0;
char ch;
while (ch = getchar(), ch > '9' || ch < '0')
;
do
{
(Ret *= 10) += ch - '0';
}
while (ch = getchar(), ch >= '0' && ch <= '9');
}
inline int Abs(const int &x)
{
return x >= 0 ? x : -x;
}
int N, M, Q, X1[Max_N + Max_Q], Y1[Max_N + Max_Q], X2[Max_N + Max_Q], Y2[Max_N + Max_Q];
int L[Max_N + Max_Q], R[Max_N + Max_Q], D[Max_N + Max_Q], U[Max_N + Max_Q], Anc[60][Max_N];
LL T[Max_N + Max_Q], Sum[60][Max_N];
#define LEFT (segt[cur].l)
#define RIGHT (segt[cur].r)
#define MID (segt[cur].mid)
#define COV (segt[cur].Cov)
#define TAG (segt[cur].Tag)
#define LCH (cur << 1)
#define RCH ((cur << 1) | 1)
struct node
{
int l, r, mid, Cov, Tag;
};
node segt[Max_M << 2];
int C[Max_M];
void build_tree(const int &cur, const int &l, const int &r)
{
LEFT = l, RIGHT = r, MID = l + ((r - l) >> 1), COV = TAG = 0;
if (l == r)
return;
build_tree(LCH, l, MID), build_tree(RCH, MID + 1, r);
}
inline void cover(const int &cur, const int &v)
{
COV = TAG = v;
}
inline void pushdown(const int &cur)
{
if (TAG)
cover(LCH, TAG), cover(RCH, TAG), TAG = 0;
}
void cover(const int &cur, const int &l, const int &r, const int &v)
{
if (LEFT == l && RIGHT == r)
{
cover(cur, v);
return;
}
pushdown(cur);
if (r <= MID)
cover(LCH, l, r, v);
else
if (l > MID)
cover(RCH, l, r, v);
else
cover(LCH, l, MID, v), cover(RCH, MID + 1, r, v);
}
int query(const int &cur, const int &pos)
{
if (LEFT == RIGHT)
return COV;
pushdown(cur);
if (pos <= MID)
return query(LCH, pos);
else
return query(RCH, pos);
}
inline bool compL(const int &a, const int &b)
{
return min(X1[a], X2[a]) < min(X1[b], X2[b]);
}
void goL()
{
build_tree(1, 0, M), memset(C, 0, sizeof(C));
sort(L + 1, L + 1 + L[0], compL);
sort(R + 1, R + 1 + R[0], compL);
sort(D + 1, D + 1 + D[0], compL);
sort(U + 1, U + 1 + U[0], compL);
for (int l = 1, r = 1, d = 1, u = 1, a, b, p;l <= L[0];++l)
{
p = L[l];
while (r <= R[0] && X1[R[r]] <= X2[p])
{
if (R[r] <= N)
C[Y2[R[r]]] = R[r];
++r;
}
while ((d <= D[0] && X2[D[d]] <= X2[p]) || (u <= U[0] && X2[U[u]] <= X2[p]))
if ((d <= D[0]) && (u > U[0] || X2[D[d]] <= X2[U[u]]))
{
if (D[d] <= N)
cover(1, Y2[D[d]], Y1[D[d]], D[d]);
++d;
}
else
{
if (U[u] <= N)
cover(1, Y1[U[u]], Y2[U[u]], U[u]);
++u;
}
a = query(1, Y2[p]), b = C[Y2[p]];
if (p <= N)
{
if (a == 0 && b == 0)
Anc[0][p] = -1;
else
if (a && (b == 0 || X2[p] - X2[a] < X2[p] - X2[b]))
Anc[0][p] = a, Sum[0][p] = (X2[p] - X2[a]) + Abs(Y2[p] - Y2[a]);
else
Anc[0][p] = b, Sum[0][p] = X2[p] - X2[b];
}
else
{
if (a == 0 && b == 0)
X2[p] = max(0LL, X2[p] - T[p]), T[p] = 0LL;
else
if (a && (b == 0 || X2[p] - X2[a] < X2[p] - X2[b]))
if (T[p] <= X2[p] - X2[a])
X2[p] -= T[p], T[p] = 0LL;
else
{
T[p] -= X2[p] - X2[a], X2[p] = X2[a];
if (T[p] <= Abs(Y2[p] - Y2[a]))
{
if (Y2[a] <= Y2[p])
Y2[p] -= T[p];
else
Y2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(Y2[p] - Y2[a]), X2[p] = a;
}
else
if (T[p] <= Abs(X2[p] - X2[b]))
{
if (X2[b] <= X2[p])
X2[p] -= T[p];
else
X2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(X2[p] - X2[b]), X2[p] = b;
}
}
}
inline int getR(const int &x)
{
return max(X1[x], X2[x]);
}
inline bool compR(const int &a, const int &b)
{
return getR(a) > getR(b);
}
void goR()
{
build_tree(1, 0, M), memset(C, 0, sizeof(C));
sort(L + 1, L + 1 + L[0], compR);
sort(R + 1, R + 1 + R[0], compR);
sort(D + 1, D + 1 + D[0], compR);
sort(U + 1, U + 1 + U[0], compR);
for (int l = 1, r = 1, d = 1, u = 1, a, b, p;r <= R[0];++r)
{
p = R[r];
while (l <= L[0] && getR(L[l]) >= getR(p))
{
if (L[l] <= N)
C[Y2[L[l]]] = L[l];
++l;
}
while ((d <= D[0] && getR(D[d]) >= getR(p)) || (u <= U[0] && getR(U[u]) >= getR(p)))
if ((d <= D[0]) && (u > U[0] || getR(D[d]) >= getR(U[u])))
{
if (D[d] <= N)
cover(1, Y2[D[d]], Y1[D[d]], D[d]);
++d;
}
else
{
if (U[u] <= N)
cover(1, Y1[U[u]], Y2[U[u]], U[u]);
++u;
}
a = query(1, Y2[p]), b = C[Y2[p]];
if (p <= N)
{
if (a == 0 && b == 0)
Anc[0][p] = -1;
else
if (a && (b == 0 || X2[a] - X2[p] < X2[b] - X2[p]))
Anc[0][p] = a, Sum[0][p] = (X2[a] - X2[p]) + Abs(Y2[p] - Y2[a]);
else
Anc[0][p] = b, Sum[0][p] = X2[b] - X2[p];
}
else
{
if (a == 0 && b == 0)
X2[p] = min(M * 1LL, X2[p] + T[p]), T[p] = 0LL;
else
if (a && (b == 0 || X2[a] - X2[p] < X2[b] - X2[p]))
if (T[p] <= X2[a] - X2[p])
X2[p] += T[p], T[p] = 0LL;
else
{
T[p] -= X2[a] - X2[p], X2[p] = X2[a];
if (T[p] <= Abs(Y2[p] - Y2[a]))
{
if (Y2[a] <= Y2[p])
Y2[p] -= T[p];
else
Y2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(Y2[p] - Y2[a]), X2[p] = a;
}
else
if (T[p] <= Abs(X2[b] - X2[p]))
{
if (X2[b] <= X2[p])
X2[p] -= T[p];
else
X2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(X2[b] - X2[p]), X2[p] = b;
}
}
}
inline int getD(const int &x)
{
return min(Y1[x], Y2[x]);
}
inline bool compD(const int &a, const int &b)
{
return getD(a) < getD(b);
}
void goD()
{
build_tree(1, 0, M), memset(C, 0, sizeof(C));
sort(L + 1, L + 1 + L[0], compD);
sort(R + 1, R + 1 + R[0], compD);
sort(D + 1, D + 1 + D[0], compD);
sort(U + 1, U + 1 + U[0], compD);
for (int l = 1, r = 1, d = 1, u = 1, a, b, p;d <= D[0];++d)
{
p = D[d];
while (u <= U[0] && getD(U[u]) <= getD(p))
{
if (U[u] <= N)
C[X2[U[u]]] = U[u];
++u;
}
while ((l <= L[0] && getD(L[l]) <= getD(p)) || (r <= R[0] && getD(R[r]) <= getD(p)))
if ((l <= L[0]) && (r > R[0] || getD(L[l]) <= getD(R[r])))
{
if (L[l] <= N)
cover(1, X2[L[l]], X1[L[l]], L[l]);
++l;
}
else
{
if (R[r] <= N)
cover(1, X1[R[r]], X2[R[r]], R[r]);
++r;
}
a = query(1, X2[p]), b = C[X2[p]];
if (p <= N)
{
if (a == 0 && b == 0)
Anc[0][p] = -1;
else
if (a && (b == 0 || Y2[p] - Y2[a] < Y2[p] - Y2[b]))
Anc[0][p] = a, Sum[0][p] = (Y2[p] - Y2[a]) + Abs(X2[p] - X2[a]);
else
Anc[0][p] = b, Sum[0][p] = Y2[p] - Y2[b];
}
else
{
if (a == 0 && b == 0)
Y2[p] = max(0LL, Y2[p] - T[p]), T[p] = 0LL;
else
if (a && (b == 0 || Y2[p] - Y2[a] < Y2[p] - Y2[b]))
if (T[p] <= Y2[p] - Y2[a])
Y2[p] -= T[p], T[p] = 0LL;
else
{
T[p] -= Y2[p] - Y2[a], Y2[p] = Y2[a];
if (T[p] <= Abs(X2[p] - X2[a]))
{
if (X2[a] <= X2[p])
X2[p] -= T[p];
else
X2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(X2[p] - X2[a]), X2[p] = a;
}
else
if (T[p] <= Abs(Y2[p] - Y2[b]))
{
if (Y2[b] <= Y2[p])
Y2[p] -= T[p];
else
Y2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(Y2[p] - Y2[b]), X2[p] = b;
}
}
}
inline int getU(const int &x)
{
return max(Y1[x], Y2[x]);
}
inline bool compU(const int &a, const int &b)
{
return getU(a) > getU(b);
}
void goU()
{
build_tree(1, 0, M), memset(C, 0, sizeof(C));
sort(L + 1, L + 1 + L[0], compU);
sort(R + 1, R + 1 + R[0], compU);
sort(D + 1, D + 1 + D[0], compU);
sort(U + 1, U + 1 + U[0], compU);
for (int l = 1, r = 1, d = 1, u = 1, a, b, p;u <= U[0];++u)
{
p = U[u];
while (d <= D[0] && getU(D[d]) >= getU(p))
{
if (D[d] <= N)
C[X2[D[d]]] = D[d];
++d;
}
while ((l <= L[0] && getU(L[l]) >= getU(p)) || (r <= R[0] && getU(R[r]) >= getU(p)))
if ((l <= L[0]) && (r > R[0] || getU(L[l]) >= getU(R[r])))
{
if (L[l] <= N)
cover(1, X2[L[l]], X1[L[l]], L[l]);
++l;
}
else
{
if (R[r] <= N)
cover(1, X1[R[r]], X2[R[r]], R[r]);
++r;
}
a = query(1, X2[p]), b = C[X2[p]];
if (p <= N)
{
if (a == 0 && b == 0)
Anc[0][p] = -1;
else
if (a && (b == 0 || Y2[a] - Y2[p] < Y2[b] - Y2[p]))
Anc[0][p] = a, Sum[0][p] = (Y2[a] - Y2[p]) + Abs(X2[p] - X2[a]);
else
Anc[0][p] = b, Sum[0][p] = Y2[b] - Y2[p];
}
else
{
if (a == 0 && b == 0)
Y2[p] = min(M * 1LL, Y2[p] + T[p]), T[p] = 0LL;
else
if (a && (b == 0 || Y2[a] - Y2[p] < Y2[b] - Y2[p]))
if (T[p] <= Y2[a] - Y2[p])
Y2[p] += T[p], T[p] = 0LL;
else
{
T[p] -= Y2[a] - Y2[p], Y2[p] = Y2[a];
if (T[p] <= Abs(X2[p] - X2[a]))
{
if (X2[a] <= X2[p])
X2[p] -= T[p];
else
X2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(X2[p] - X2[a]), X2[p] = a;
}
else
if (T[p] <= Abs(Y2[b] - Y2[p]))
{
if (Y2[b] <= Y2[p])
Y2[p] -= T[p];
else
Y2[p] += T[p];
T[p] = 0LL;
}
else
T[p] -= Abs(Y2[b] - Y2[p]), X2[p] = b;
}
}
}
void get(const int &i, const int &u)
{
if (X2[u] < X1[u])
X2[i] = max(0LL, X2[i] - T[i]);
if (X2[u] > X1[u])
X2[i] = min(M * 1LL, X2[i] + T[i]);
if (Y2[u] < Y1[u])
Y2[i] = max(0LL, Y2[i] - T[i]);
if (Y2[u] > Y1[u])
Y2[i] = min(M * 1LL, Y2[i] + T[i]);
}
int main()
{
gi(N), gi(M);
for (int i = 1;i <= N;++i)
{
gi(X1[i]), gi(Y1[i]), gi(X2[i]), gi(Y2[i]);
if (X2[i] < X1[i])
L[++L[0]] = i;
if (X2[i] > X1[i])
R[++R[0]] = i;
if (Y2[i] < Y1[i])
D[++D[0]] = i;
if (Y2[i] > Y1[i])
U[++U[0]] = i;
}
gi(Q);
for (int i = 1;i <= Q;++i)
{
gi(X2[N + i]), gi(Y2[N + i]), X1[N + i] = X2[N + i], Y1[N + i] = Y2[N + i];
char op[5];
scanf("%s", op);
if (*op == 'L')
L[++L[0]] = N + i;
if (*op == 'R')
R[++R[0]] = N + i;
if (*op == 'D')
D[++D[0]] = N + i;
if (*op == 'U')
U[++U[0]] = N + i;
gi(T[N + i]);
}
goL(), goR(), goD(), goU();
for (int j = 1;j <= 59;++j)
for (int i = 1;i <= N;++i)
if (Anc[j - 1][i] == -1)
Anc[j][i] = -1;
else
{
Anc[j][i] = Anc[j - 1][Anc[j - 1][i]];
Sum[j][i] = Sum[j - 1][i] + Sum[j - 1][Anc[j - 1][i]];
Sum[j][i] = min(Sum[j][i], 1000000000000000LL + 1LL);
}
for (int i = N + 1, u;i <= N + Q;++i)
{
if (T[i])
{
u = X2[i];
for (int j = 59;j >= 0;--j)
if (Anc[j][u] != -1 && Sum[j][u] <= T[i])
T[i] -= Sum[j][u], u = Anc[j][u];
X2[i] = X2[u], Y2[i] = Y2[u];
if (Anc[0][u] == -1)
get(i, u);
else
{
if (X2[u] < X1[u])
if (T[i] <= X2[i] - X2[Anc[0][u]])
get(i, u);
else
T[i] -= X2[i] - X2[Anc[0][u]], X2[i] = X2[Anc[0][u]], get(i, Anc[0][u]);
if (X2[u] > X1[u])
if (T[i] <= X2[Anc[0][u]] - X2[i])
get(i, u);
else
T[i] -= X2[Anc[0][u]] - X2[i], X2[i] = X2[Anc[0][u]], get(i, Anc[0][u]);
if (Y2[u] < Y1[u])
if (T[i] <= Y2[i] - Y2[Anc[0][u]])
get(i, u);
else
T[i] -= Y2[i] - Y2[Anc[0][u]], Y2[i] = Y2[Anc[0][u]], get(i, Anc[0][u]);
if (Y2[u] > Y1[u])
if (T[i] <= Y2[Anc[0][u]] - Y2[i])
get(i, u);
else
T[i] -= Y2[Anc[0][u]] - Y2[i], Y2[i] = Y2[Anc[0][u]], get(i, Anc[0][u]);
}
}
printf("%d %d\n", X2[i], Y2[i]);
}
return 0;
洛谷模拟NOIP考试反思的更多相关文章
- 【noip】跟着洛谷刷noip题2
noip好难呀. 上一个感觉有点长了,重开一个. 36.Vigenère 密码 粘个Openjudge上的代码 #include<cstdio> #include<iostream& ...
- 洛谷 P3951 NOIP 2017 小凯的疑惑
洛谷 P3951 NOIP 2017 小凯的疑惑 题目描述 小凯手中有两种面值的金币,两种面值均为正整数且彼此互素.每种金币小凯都有 无数个.在不找零的情况下,仅凭这两种金币,有些物品他是无法准确支付 ...
- noip模拟9[斐波那契·数颜色·分组](洛谷模拟测试)
这次考试还是挺好的 毕竟第一题被我给A了,也怪这题太简单,规律一眼就看出来了,但是除了第一题,剩下的我只有30pts,还是菜 第二题不知道为啥我就直接干到树套树了,线段树套上一个权值线段树,然后我发现 ...
- 【noip】跟着洛谷刷noip题
传送门 1.铺地毯 d1t1 模拟 //Twenty #include<cstdio> #include<cstdlib> #include<iostream> # ...
- 【洛谷】NOIP提高组模拟赛Day2【动态开节点/树状数组】【双头链表模拟】
U41571 Agent2 题目背景 炎炎夏日还没有过去,Agent们没有一个想出去外面搞事情的.每当ENLIGHTENED总部组织活动时,人人都说有空,结果到了活动日,却一个接着一个咕咕咕了.只有不 ...
- [洛谷0925]NOIP模拟赛 个人公开赛 OI
P3395 路障 题目背景 此题约为NOIP提高组Day1T1难度. 题目描述 B君站在一个n*n的棋盘上.最开始,B君站在(1,1)这个点,他要走到(n,n)这个点. B君每秒可以向上下左右的某个 ...
- 洛谷CON1041 NOIP模拟赛一试
A T2-power of 2 题目描述 是一个十分特殊的式子. 例如: n=0时 =2 然而,太大了 所以,我们让对10007 取模 输入输出格式 输入格式: n 输出格式: % 10007 输入 ...
- 【洛谷】NOIP提高组模拟赛Day1【组合数学】【贪心+背包】【网络流判断是否满流以及流量方案】
U41568 Agent1 题目背景 2018年11月17日,中国香港将会迎来一场XM大战,是世界各地的ENLIGHTENED与RESISTANCE开战的地点,某地 的ENLIGHTENED总部也想派 ...
- 【比赛】洛谷夏令营NOIP模拟赛
Day1 第一题 水题 第二题 题意:一个n*m的字符矩阵从左上到右下,经过字符形成回文串的路径数.n≤500 回文串,考虑两段往中间DP. f[k][x][y]表示走了k步,左上点横坐标为x,右下点 ...
随机推荐
- [转]php中 curl模拟post发送json并接收json
本文转自:https://blog.csdn.net/pangchengyong0724/article/details/52103962 本地模拟请求服务器数据,请求数据格式为json,服务器返回数 ...
- 注册asp.net 4.0版本到IIS服务器中
在IIS服务器的运维的过程中,有时候部署asp.net网站发现未安装.net framework对应版本信息,此时就需要重新将.net framework对应的版本注册到IIS中,此处以重新注册.ne ...
- C#实现给图片加边框的方法
Bitmap bit= new Bitmap(@"" + Path);//给图片加边框 //Bitmap bit = new Bitmap(Screen.AllScreens[0] ...
- [android] 帧布局
/*******************2016年5月3日 更新**************************************/ 知乎:如何理解andriod中的View和framela ...
- IP是什么 DNS 域名与IP有什么不同
IP地址是在网络上分配给每台计算机或网络设备的32位数字标识.在Internet上,每台计算机或网络设备的IP地址是全世界唯一的.IP地址的格式是 xxx.xxx.xxx.xxx,其中xxx是 0 到 ...
- awesome python 中文版 相见恨晚!
awesome python 中文版 相见恨晚! https://www.zhihu.com/question/24590883 这篇知乎厉害了!一定要学习! 作者:知乎用户链接:https:// ...
- laravel常见异常解决
requested URL not found http://stackoverflow.com/questions/21458080/the-requested-url-projectname-us ...
- K8S RBAC
API Server 内部通过用户认证后,然后进入授权流程.对合法用户进行授权并且随后在用户访问时进行鉴权,是权限管理的重要环节. 在 kubernetes 集群中,各种操作权限是赋予角色(Role ...
- js 从一个对象中找到属性值相等的集合
getobjs: function(objs, key, value) { var result = []; for (var i in objs) { var obj = $(objs[i]); i ...
- CSS3动画属性:动画(animation)
一:动画(animation)的参数详解 由于上面用到了animation动画,这里详细介绍下这个animation的参数. 简介 CSS动画(Animations)简单说就是在一段固定的动画时间内暗 ...