CSDN,有幸遇见 ——我的三周年创作纪念日

CSDN,有幸遇见 ——我的三周年创作纪念日_第1张图片

一生二,二生三,三生万物

三年,与 CSDN 的相遇相识相知——

前两年都没写,一是没纪念的概念,二是纪念日这天每年总是清明节。
还有就是不知道有勋章((

Meet 遇见

那年,我六年级,已加入了一年半的信息学竞赛。
是一次撞见,我发现了这个能指导我不会做的题目的网站。

是童心的好奇,从此让我打开了对 CSDN 的无尽探索,
一个又一个地寻找着键盘上的字母,我织出了那稚嫩懵懂的第一篇 blog ——《Go to the CSDN》。


Gain 收获

随着打字速度的加快和心智的逐渐完善,我不知不觉地习惯使用 CSDN 写 blog,虽然一共只写了 71 篇,但可以不吝啬地说,都是用心敲出来的(虽然很多内容多但点赞很少)。

只是一些小数据,但当然也有记录的必要。
CSDN,有幸遇见 ——我的三周年创作纪念日_第2张图片

尽管这仅有的 143 次点赞中有十多次是自己点的,但也有许许多多各行各业的强者的支持,尤其有两个是 CSDN学习 给予的,备受鼓舞。

在这里郑重感谢所有评论、点赞、收藏、关注的支持啊!

未来是一种憧憬呢。


Life 日常

还不能说创作已经是我生活的一部分了,但它一定已经成为了我生命中的一部分。
创作像是一种总结,是自己与思想的再一次碰撞。创作也是一种乐趣,尤其是收到支持时的莫大鼓舞,我的生命离不开创作。

去年第一次参加的 CSDN 竞赛,进入前十,得到了 CSDN 帆布包的馈赠,以前也在其他网站上参加过类似比赛,但像 CSDN 这样信守承诺的举办方并不多,可见“成就一亿人的社区”并非浪得虚名。“细节决定成败。” 这一点,CSDN 成功了,当之无愧。


Achievement 成就

提示:你过去写得最好的一段代码是什么? 请用代码块贴出来

倒还没感觉写过什么特别突出的代码,那就贴一份 目前唯一一道不看题解就做出来的黑题 吧。

靠模拟退火调参数调出来的,为此还在CSDN写了一篇模拟退火算法的 blog
话说写的这篇 blog 目前还是我写的文章中访问量最高的…

第一次 AC 提交时间:2022-11-18 20:48:07

#include
#include
#include
using namespace std;
const double T0=1e5,T1=1e-6,k=0.9;
const int L=230;
int T,m;
struct qh{
    double x,y;
}a[5001],c;
double sqr(double x){return x*x;}
double f(double x,double y){
    double res=1e9;
    for(int i=1;i<=m;i++) res=min(res,sqrt(sqr(x-a[i].x)+sqr(y-a[i].y)));
    return res;
}
double Rand(double x){return 1.0*rand()/RAND_MAX*x;}
int main(){
    scanf("%lf%lf%d",&c.x,&c.y,&m);
    for(int i=1;i<=m;i++) scanf("%lf%lf",&a[i].x,&a[i].y);
    double t=T0,x=0,y=0;
    while (t>T1){
        for(int i=1;i<=L;i++){
            double xx=-1,yy=-1;
            while (xx<0||xx>c.x) xx=x+(Rand(2*c.x)-c.x)*4.0*(t/T0);
            while (yy<0||yy>c.y) yy=y+(Rand(2*c.y)-c.y)*4.0*(t/T0);
            if(f(xx,yy)>f(x,y)) x=xx,y=yy;
            // printf("%.2f %.2f %.2f %.2f\n",x,y,xx,yy);
        }
        t*=k;
    }
    printf("%.9f",f(x,y));
    return 0;
}
/*
start coding:19:55
finish debuging:20:48
*/

顺带贴一手正解代码。

#include 
#include 
#include 
#include 
using std::sort;
using std::pair;
using std::min;
typedef pair<int, int> pad;

/*------------------------------Computational geometry------------------------------*/

const double pi =acos(-1), eps =1e-7;

struct vect{
	double x, y;
	vect(){}
	vect(double xx, double yy):x(xx), y(yy){}
	vect operator + (vect v){ return vect(x+v.x, y+v.y); }
	vect operator - (vect v){ return vect(x-v.x, y-v.y); }
	vect operator * (double mu){ return vect(mu*x, mu*y); }
	double operator / (vect v){ return x*v.y-y*v.x; }/*叉积*/
};

struct line{
	vect u, v;
	double angle;
	line(){}
	line(vect uu, vect vv):u(uu), v(vv){ angle =atan2(vv.y-uu.y, vv.x-uu.x); }
};

inline short gtr(double a, double b){ return (a-b > eps); }

inline bool eq(double a, double b){ return (a-b < eps && a-b > -eps); }

inline bool onright(line f, vect w){ return (gtr((w-f.u)/(f.v-f.u), 0)); }

/*求交点*/
vect getIntersection(line f, line g){
	double w =((g.u-f.u)/(f.u-f.v))/((f.u-f.v)/(g.u-g.v));
	return g.u+(g.u-g.v)*w;
}

int cmp(line A, line B){
	if(eq(A.angle, B.angle)) return onright(B, A.u);/*有向直线最左的在最后面,会被保留*/
	else return (gtr(B.angle, A.angle));
}

/*求左侧交*/
inline pad getHPI(line ls[], int totl, line hull[]){
	sort(ls, ls+totl, cmp);
	int l =0, r =0;
	for(int i =0; i < totl; ++i){
		while(i < totl-1 && eq(ls[i].angle, ls[i+1].angle)) ++i;
		while(r-l > 1 && onright(ls[i], getIntersection(hull[r-1], hull[r-2]))) --r;
		if(eq(ls[i].angle-hull[r-1].angle, pi)) return pad(0, 0);/*判方向相反的平行*/
		hull[r++] =ls[i];
	}
	while(r-l > 1){
        if(onright(hull[r-1], getIntersection(hull[l], hull[l+1]))) ++l;
        else if(onright(hull[l], getIntersection(hull[r-1], hull[r-2]))) --r;
        else break;/*已经没有更新了*/
    }
	if(r-l < 3) return pad(0, 0);
	else return pad(l, r);
}

inline double dist(vect x, vect y){ return sqrt((y.x-x.x)*(y.x-x.x)+(y.y-x.y)*(y.y-x.y)); }

/*中垂线左包含 x*/
inline line getmidline(vect x, vect y){
	vect mid =vect((x.x+y.x)/2, (x.y+y.y)/2), v2 =vect((y-x).y, -(y-x).x)/*顺时针方向,与 (y-x) 垂直的向量*/;
	line ret(mid+v2, mid);
	return ret;
}

/*------------------------------Main------------------------------*/

const int MAXN =1000100, MAXN2 =1100;

inline void addbound(line ls[], int &totl, int w, int h){
	ls[totl++] =line(vect(w, h), vect(0, h));
	ls[totl++] =line(vect(0, h), vect(0, 0));
	ls[totl++] =line(vect(0, 0), vect(w, 0));
	ls[totl++] =line(vect(w, 0), vect(w, h));
}

inline double getFarthest(line hull[], int toth, vect p){
	hull[toth++] =hull[0];
	double ret =0;
	for(int i =0; i < toth-1; ++i){
		double res =dist(p, getIntersection(hull[i], hull[i+1]));
		if(gtr(res, ret)) ret =res;
	}
	return ret;
}

line ls[MAXN], hull[MAXN];

inline int read(){
	int x =0; bool f =0; char c =getchar();
	while(c < '0' || c > '9') (c == '-') ? f =1, c =getchar() : c =getchar();
	while(c >= '0' && c <= '9') x = (x<<3) + (x<<1) + (48^c), c =getchar();
	return (f) ? -x : x;
}

vect point[MAXN2];

int main(){
	int w =read(), h =read(), n =read();
	int totp =0;
	for(int i =0; i < n; ++i){
		int x =read(), y =read();
		/*反正总复杂度 n 方这里就暴力判重了(*/
		bool f =1;
		for(int j =0; j < totp; ++j) if(point[j].x == x && point[j].y == y) f =0;
		if(f) point[totp++] =vect(x, y);
	}
	double ans =0;
	for(int i =0; i < totp; ++i){
		int totl =0;
		for(int j =0; j < totp; ++j){
			if(j == i) continue;
			ls[totl++] =getmidline(point[i], point[j]);
		}
		addbound(ls, totl, w, h);
		pad H =getHPI(ls, totl, hull);
		double res =getFarthest(hull+H.first, H.second-H.first, point[i]);
		if(gtr(res, ans)) ans =res;
	}
	printf("%.10lf", ans);
}

来源:IOI 2006 国家集训队论文「王栋 ——浅谈平面 voronoi 图的构造及应用」。


Phantasy 憧憬

还是希望能保持在 CSDN 不规律性更新吧,既然有缘相遇,何不一同随行?
不过可惜一个铁粉都还没有额…

Encourage 激励

努力学习,追求卓越。

前途是光明的,道路是艰难的。

前行不往回顾,勇进不忘调整,跋涉不忘反思。


放个套话:你的支持是我创作的最大动力!

5000字了啊

这个就不删了

Tips

  1. 您发布的文章将会展示至 里程碑专区 ,您也可以在 专区 内查看其他创作者的纪念日文章
  2. 优质的纪念文章将会获得神秘打赏哦

你可能感兴趣的:(总结与反思,随笔,c++,算法,人工智能,深度学习,学习方法)