达成成就,一天更3篇总结。

又是一个暴力场

别问我为什么开局 \(5\) 分钟就问老师为什么 \(T3\) 没有提交的窗口。

开题读题,一路自闭到 \(T3\) ,发现 \(T3\) 可打暴力,所以一波暴力打上去,开始只有 \(30pts\)

然后转向 \(T2\) ,发现也有部分分数可以打,所以就开始打这个题目的暴力。

瞄准 \(20pts\) 部分分数,然后疯狂开始打。

打完之后也不能放弃啊,所以开始回去开 \(T1\),然后开始自闭。

给的样例手摸都出不来。。。。

自闭\(*2\)

突然思路开始涌现,发现可以把坐标系分成 \(1000\) * \(1000\),然后开始一个一个点枚举,这样的话就能骗过\(Special\;Judge\)

然后开始打。。。

然后样例都调不出来。。。

自闭\(*3\)

但是经过我的奋战,\(T1\) 终于出来了样例。。。

然后转向 \(T3\),感觉数组好像开的有点小,但是部分分数似乎也够,但还好我开打了一些。又赚了 \(20pts\)

不扯淡了

T1:

首先考虑的应该是二分做法。

然后如果打对就可以得到 \(80pts\)

然而只有土哥打对了。。。。

战神看出了正解最小生成树,然而 \(Kruskal\) 爆炸了。。。

然而还是极其强大。。。

正解就是最小生成树,然后 \(Kruskal\) 也可以过。

就是每个点连边,然后和上下边界连边。

#include<bits/stdc++.h>
using std::cout; using std::endl;
#define debug cout<<"debug"<<endl
//#define int long long
namespace xin_io
{
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
#define scanf eat1 = scanf
#define freopen eat2 = freopen
int eat1; FILE *eat2; char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
template<class type>inline type get()
{
type s = 0,f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io; static const int maxn = 1e6+10,inf = 0x7f7f7f,mod = (1<<30);
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
typedef long long ll;
namespace xin
{
const double eps = 1e-8;
int n,m,k;
class xin_data{public:int x,y;}d[maxn];
inline double getdis(double x1,double y1,double x2,double y2)
{return std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}
inline bool equal(double x,double y)
{
if(abs(x - y) <= eps) return true;
return false;
}
int x[maxn],y[maxn];
double dis[maxn];
bool vis[maxn];
double ans = -inf * 1.0;
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
n = get<signed>(); m = get<signed>(); k = get<signed>();
try(i,1,k) x[i] = get<signed>(),y[i] = get<signed>(),dis[i] = (double)(m - y[i]);
dis[k+1] = m; dis[0] = inf * 1.0;
while(true)
{
register int temp = 0;
try(i,1,k+1)if(!vis[i] and dis[i] < dis[temp]) temp = i;
vis[temp] = true;
ans = std::max(ans,dis[temp]);
if(temp == k + 1) break;
try(i,1,k) dis[i] = std::min(dis[i],getdis(x[i],y[i],x[temp],y[temp]));
dis[k+1] = std::min(dis[k+1],y[temp] * 1.0);
}
printf("%0.9lf\n",ans/2.0);
return 0;
}
}
signed main() {return xin::main();}

T2:

要找一个极长上升序列。

然后线段树优化。。。。

老猥琐了。。

自己研究吧。。。

#include<bits/stdc++.h>
using std::cout; using std::endl;
#define debug cout<<"debug"<<endl
//#define int long long
namespace xin_io
{
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
#define scanf eat1 = scanf
#define freopen eat2 = freopen
int eat1; FILE *eat2; char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
template<class type>inline type get()
{
type s = 0,f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io; static const int maxn = 1e6+10,inf = 0x7f7f7f7f,mod = (1<<30);
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
typedef long long ll;
namespace xin
{
int p[maxn],c[maxn];
int n;
int f[maxn];
int maxx = 0;
class xin_segment
{
private:
#define ls(fa) (fa << 1)
#define rs(fa) (fa << 1 | 1)
inline void up(int fa,int l,int r,int x)
{
register int mid = l + r >> 1;
t[fa].mf = find(ls(fa),l,mid,l,mid,t[rs(fa)].mx);
t[fa].f = std::min(t[ls(fa)].f,t[rs(fa)].f);
t[fa].mx = std::max(t[ls(fa)].mx,t[rs(fa)].mx);
// cout<<"t[fa].mx = "<<t[fa].mx<<endl;
}
public:
class xin_tree{public:int mx,mf,f;}t[maxn];
int find(int fa,int l,int r,int ql,int qr,int p)
{
if(t[fa].mx < p) return inf;
if(l == r) {maxx = std::max(maxx,t[fa].mx); return t[fa].f;}
register int mid = l + r >> 1;
if(l == ql and r == qr)
{
if(t[rs(fa)].mx < p) return find(ls(fa),l,mid,ql,mid,p); maxx = std::max(maxx,t[fa].mx); //cout<<"maxx = "<<maxx<<endl;
return std::min(t[fa].mf,find(rs(fa),mid+1,r,mid+1,qr,p));
}
if(qr <= mid) return find(ls(fa),l,mid,ql,qr,p);
else if(ql > mid) return find(rs(fa),mid+1,r,ql,qr,p);
else {maxx = 0; register int temp = find(rs(fa),mid+1,r,mid+1,qr,p);return std::min(temp,find(ls(fa),l,mid,ql,mid,maxx));}
}
void insert(int fa,int l,int r,int x,int p)
{
if(x > r or x < l) return ;
if(l == r) {t[fa].f = f[p]; t[fa].mx = p; return;}
register int mid = l + r >> 1;
insert(ls(fa),l,mid,x,p); insert(rs(fa),mid+1,r,x,p);
up(fa,l,r,x);
}
}t;
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
n = get<signed>();
try(i,1,n) p[i] = get<signed>();
try(i,1,n) c[i] = get<signed>();
try(i,1,(n<<2)) t.t[i].f = t.t[i].mf = inf;
for(register int i=1;i<=(n<<2);i<<=1) t.t[i].f = t.t[i].mf = 0;
try(i,1,n)
{
f[i] = t.find(1,0,n,0,p[i] - 1,0) + c[i];
t.insert(1,0,n,p[i],i);
}
register int ans = inf,temp = 0;
throw(i,n,1) if(temp < p[i]) temp = p[i],ans = std::min(ans,f[i]);
cout<<ans<<endl;
return 0;
}
}
signed main() {return xin::main();}

T3:

咱们把式子变换一下

然后发现:

\[\frac {c_u-c_v}{dis_{v,u}}=\frac {c_u-c_v}{d_v-d_u}=-\frac {c_v-c_u} {d_v-d_u}
\]

然后就是一个斜率式子。

然后维护凸包,找到斜率最大的。

采用倍增的方法,然后飞快。

防止黑心出题人

#include<bits/stdc++.h>
using std::cout; using std::endl;
#define debug cout<<"debug"<<endl
//#define int long long
namespace xin_io
{
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
#define scanf eat1 = scanf
#define freopen eat2 = freopen
int eat1; FILE *eat2; char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
template<class type>inline type get()
{
type s = 0,f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io; static const int maxn = 1e6+10,inf = 0x7f7f7f,mod = (1<<30);
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
typedef long long ll;
namespace xin
{
class xin_edge{public:int next,ver;}edge[maxn];
int d[maxn],fa[maxn][31],ans[maxn],c[maxn],n;
int head[maxn],zhi = 0;
inline void add(int x,int y) {edge[++zhi].ver = y; edge[zhi].next = head[x]; head[x] = zhi;}
inline double getk(int x,int y) {return (double)(c[x] - c[y]) / (double)(d[y] - d[x]);}
void dfs(int x)
{
register int now = fa[x][0];
throw(i,30,0)
{
if(fa[now][i] <= 1) continue;
if(getk(x,fa[now][i]) >= getk(x,fa[fa[now][i]][0])) now = fa[fa[now][i]][0]; //just jump to the best
}
if(now > 1 and getk(x,now) >= getk(x,fa[now][0])) now = fa[now][0];
ans[x] = now; fa[x][0] = now; //this method is not totally the same as before,f[x][0] is its best answer but not his father
try(i,1,30) fa[x][i] = fa[fa[x][i-1]][i-1];
for(register int i=head[x];i;i=edge[i].next)
{
register int y = edge[i].ver;
d[y] = d[x] + 1; dfs(y);
}
}
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
n = get<signed>();
try(i,1,n) c[i] = get<signed>();
try(i,2,n)
{
fa[i][0] = get<signed>();
add(fa[i][0],i);
}
d[1] = 1;
dfs(1);
try(i,2,n) printf("%.10lf\n",getk(i,ans[i]));
return 0;
}
}
signed main() {return xin::main();}

[考试总结]noip模拟16的更多相关文章

  1. 2021.7.15考试总结[NOIP模拟16]

    ZJ模拟D2就是NB.. T1 Star Way To Heaven 谁能想到这竟是个最小生成树呢?(T1挂分100的高人JYF就在我身边 把上边界和下边界看成一个点和星星跑最小生成树,从上边界开始跑 ...

  2. 7.15考试总结(NOIP模拟16)[Star Way To Heaven·God Knows·Lost My Music]

    败者死于绝望,胜者死于渴望. 前言 一看这个题就来者不善,对于第一题第一眼以为是一个大模拟,没想到是最小生成树. 对于第二题,先是看到了状压可以搞到的 20pts 然后对着暴力一顿猛调后来发现是题面理 ...

  3. 6.17考试总结(NOIP模拟8)[星际旅行·砍树·超级树·求和]

    6.17考试总结(NOIP模拟8) 背景 考得不咋样,有一个非常遗憾的地方:最后一题少取膜了,\(100pts->40pts\),改了这么多年的错还是头一回看见以下的情景... T1星际旅行 前 ...

  4. 5.23考试总结(NOIP模拟2)

    5.23考试总结(NOIP模拟2) 洛谷题单 看第一题第一眼,不好打呀;看第一题样例又一眼,诶,我直接一手小阶乘走人 然后就急忙去干T2T3了 后来考完一看,只有\(T1\)骗到了\(15pts\)[ ...

  5. 5.22考试总结(NOIP模拟1)

    5.22考试总结(NOIP模拟1) 改题记录 T1 序列 题解 暴力思路很好想,分数也很好想\(QAQ\) (反正我只拿了5pts) 正解的话: 先用欧拉筛把1-n的素数筛出来 void get_Pr ...

  6. 2021.9.17考试总结[NOIP模拟55]

    有的考试表面上自称NOIP模拟,背地里却是绍兴一中NOI模拟 吓得我直接文件打错 T1 Skip 设状态$f_i$为最后一次选$i$在$i$时的最优解.有$f_i=max_{j<i}[f_j+a ...

  7. [考试总结]noip模拟23

    因为考试过多,所以学校的博客就暂时咕掉了,放到家里来写 不过话说,vscode的markdown编辑器还是真的很好用 先把 \(noip\) 模拟 \(23\) 的总结写了吧.. 俗话说:" ...

  8. 2021.7.29考试总结[NOIP模拟27]

    T1 牛半仙的妹子图 做法挺多的,可以最小生成树或者最短路,复杂度O(cq),c是颜色数. 我考场上想到了原来做过的一道题影子,就用了并查集,把边权排序后一个个插入,记录权值的前缀和,复杂度mlogm ...

  9. 2021.8.16考试总结[NOIP模拟41]

    T1 你相信引力吗 肯定是单调栈维护.但存在重复值,还是个环,不好搞. 发现取区间时不会越过最大值,因此以最大值为断点将环断为序列.在栈里维护当前栈中有多少个与当前元素相等的元素,小分类讨论一下. 最 ...

随机推荐

  1. 手把手教你彻底理解MySQL的explain关键字

    数据库是程序员必备的一项基本技能,基本每次面试必问.对于刚出校门的程序员,你只要学会如何使用就行了,但越往后工作越发现,仅仅会写sql语句是万万不行的.写出的sql,如果性能不好,达不到要求,可能会阻 ...

  2. linux安装后配置

    1.1 系统设置(自测用,公司不需要) 1.1.1 Selinux系统安全保护 Security-Enhanced Linux – 美国NSA国家安全局主导开发,一套增强Linux系统安 全的强制访问 ...

  3. 【NX二次开发】PMI线性标注

    PMI线性标注,二次开发的难点在于控制尺寸的位置,多花点儿时间都能搞出来,想走捷径最下面就是源码. 只需要摆好工作坐标,然后指定你要标注尺寸的两个点,就可以很方便得利用这个封装函数做出你想要的PMI. ...

  4. jQuery04

    jQuery内容总结: 1.既然是一个js库,使用之前就要引入js库,是一个.js文件,版本是1.8.3: 2.写一个jQuery页面加载函数(注意与js页面加载函数的区别): $(function( ...

  5. Winform中用户自定义控件中外部设置子控件属性的方法

    假设我们新建立一个用户自定义控件,由一个lable1和pictureBox1组成 此时我们在外部调用该控件,然后想动态改变lable1的值,我们该怎么办? 假设实例化的用户控件名为UserContro ...

  6. ZooKeeper分布式锁的实现

    ZooKeeper分布式锁的实现. 在分布式的情况下,sychornized 和 Lock 已经不能满足我们的要求了,那么就需要使用第三方的锁了,这里我们就使用 ZooKeeper 来实现一个分布式锁 ...

  7. .net core 使用webservice

    开发环境在vs2017,2015 暂时没有试过 1.在扩展更新中添加Microsoft WCF Web Service Reference Provider 2.在core项目中添加链接的服务 3.键 ...

  8. Unity3D学习笔记2——绘制一个带纹理的面

    目录 1. 概述 2. 详论 2.1. 网格(Mesh) 2.1.1. 顶点 2.1.2. 顶点索引 2.2. 材质(Material) 2.2.1. 创建材质 2.2.2. 使用材质 2.3. 光照 ...

  9. 8、负载均衡HAproxy部署

    8.1.基本环境说明: 服务器名(centos7) ip地址 安装软件 slave-node1 172.16.1.91 haproxy1.8.15,tomcat8.5.37(8080.8081实例), ...

  10. 9、mysql的备份与恢复

    mysql中 /*! ....*/ 不是注释,mysql为了保持兼容,它把一些特有的仅在mysql上用的语句放在/*!....*/中, 这样这些语句如果在其他数据库中是不会被执行,但在mysql中它会 ...