人,通常都是在那些鸡毛蒜皮的小事上才会理智(摘)

人们往往在小事上表现得更为理智,如购物时精挑细选;而在重大决定面前,比如选择居住城市或恋爱对象时,则可能更加冲动。本文通过一个个人故事探讨了这种行为模式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

人,通常都是在那些鸡毛蒜皮的小事上才会理智,比如说买件衣服,你能够花上一整天的功夫,从价钱到款式到颜色,什么都能比较个半天,结果最后还没买。可是在那些决定性的事情上,却往往不理智,头脑一热,决定就下来了。当年我决定留北京,为什么呢?书太多了。至于恋爱,那就更简单了,一见钟情!
#include<bits/stdc++.h> #define ll long long using namespace std; static const int N = 2e5+5; static inline ll rd() { ll x = 0; char d = getchar_unlocked(); while (d < '0' || d > '9')d = getchar_unlocked(); while (d >= '0' && d <= '9') { x = (x << 3) + (x << 1) + (d ^ 48); d = getchar_unlocked(); } return x; } static inline void wr(ll x) { static ll len; static char ch[20]; if (x == 0) { putchar_unlocked('0'); putchar_unlocked(' '); return; } while (x) { ch[len++] = x % 10 ^ 48; x /= 10; } while (len)putchar_unlocked(ch[--len]); putchar_unlocked(' '); } //------------------------------------------------ struct node { ll x, y, id; node() {}; node(ll a, ll b): x(a), y(b) {}; } e; static vector<node> v1, v2, v3, v4; static inline bool p1(const node &a, const node &b) { if (a.x + a.y != b.x + b.y) return a.x + a.y < b.x + b.y; if (a.x != b.x) return a.x < b.x; return a.y < b.y; } static inline bool p2(const node &a, const node &b) { if (a.x - a.y != b.x - b.y) return a.x - a.y < b.x - b.y; if (a.x != b.x) return a.x < b.x; return a.y < b.y; } static inline bool p3(const node &a, const node &b) { if (-a.x + a.y != -b.x + b.y) return -a.x + a.y < -b.x + b.y; if (a.x != b.x) return a.x < b.x; return a.y < b.y; } static inline bool p4(const node &a, const node &b) { if (-(a.x + a.y) != -(b.x + b.y)) return -(a.x + a.y) < -(b.x + b.y); if (a.x != b.x) return a.x < b.x; return a.y < b.y; } struct edge { ll u, v, w; edge() {}; edge(ll a, ll b, ll c): u(a), v(b), w(c) {}; bool operator <(const edge& oth)const { return w < oth.w; } }; static inline ll get(const node &a, const node &b) { return abs(a.x - b.x) + abs(a.y - b.y); } vector<edge> v; vector<pair<int, int>> ans; static int Set[N]; static inline int f(int x) { return Set[x] == x ? x : Set[x] = f(Set[x]); } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); static ll n, sum = 0; n = rd(); v1.reserve(n); v2.reserve(n); v3.reserve(n); v4.reserve(n); v.reserve(4 * n); for (int i = 1; i <= n; i++) { e.x = rd(), e.y = rd(), e.id = i; v1.emplace_back(e); v2.emplace_back(e); v3.emplace_back(e); v4.emplace_back(e); Set[i] = i; } //四向排序 sort(v1.begin(), v1.end(), p1); sort(v2.begin(), v2.end(), p2); sort(v3.begin(), v3.end(), p3); sort(v4.begin(), v4.end(), p4); //生成边 for (int i = 1; i < n; i++) { v.emplace_back(v1[i - 1].id, v1[i].id, get(v1[i - 1], v1[i])); v.emplace_back(v2[i - 1].id, v2[i].id, get(v2[i - 1], v2[i])); v.emplace_back(v3[i - 1].id, v3[i].id, get(v3[i - 1], v3[i])); v.emplace_back(v4[i - 1].id, v4[i].id, get(v4[i - 1], v4[i])); } sort(v.begin(), v.end()); //kruskal int Sz = v.size(), rx = 0, ry = 0, cnt = 0; for (int i = 0; i < Sz; i++) { rx = f(v[i].u), ry = f(v[i].v); if(rx != ry) { sum += v[i].w; Set[rx] = ry; cnt++; ans.emplace_back(v[i].u, v[i].v); if(cnt == n - 1)break; } } wr(sum); for(int i = 0; i<cnt; i++) { putchar_unlocked('\n'); wr(ans[i].first), wr(ans[i].second); } return 0; }还有那些问题?鸡毛蒜皮就不用了
08-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值