-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.xml
134 lines (64 loc) · 99.7 KB
/
search.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title></title>
<link href="/2020/05/03/changelog/"/>
<url>/2020/05/03/changelog/</url>
<content type="html"><![CDATA[<h1><span id="000-2020-05-02">0.0.0 (2020-05-02)</span></h1><h3><span id="bug-fixes">Bug Fixes</span></h3><ul><li><strong>changelog:</strong> add title for change log (<a href="https://github.com/xy83918/albert-blog/commit/f3d943bb865d9da02fe02a0661a15f4fb4b2d2e7" target="_blank" rel="noopener">f3d943b</a>)</li></ul><h3><span id="features">Features</span></h3><ul><li>test (<a href="https://github.com/xy83918/albert-blog/commit/e3918ea7013d8b6bae95d3f9b173dbd5b36878c4" target="_blank" rel="noopener">e3918ea</a>)</li><li>添加自动成Change Log的功能 (<a href="https://github.com/xy83918/albert-blog/commit/846f9b9610817d27619f7e0ad0913875e3ce9e3d" target="_blank" rel="noopener">846f9b9</a>)</li></ul>]]></content>
</entry>
<entry>
<title>如何培养受欢迎的孩子--2.触发孩子社交主动性的三个方法</title>
<link href="/2020/04/28/hong-fa-hai-zi-she-jiao-zhu-dong-xing-de-san-ge-fang-fa/"/>
<url>/2020/04/28/hong-fa-hai-zi-she-jiao-zhu-dong-xing-de-san-ge-fang-fa/</url>
<content type="html"><![CDATA[<h1><span id="如何培养受欢迎的孩子2触发孩子社交主动性的三个方法">如何培养受欢迎的孩子–2.触发孩子社交主动性的三个方法</span></h1><p>上一讲我们讲了拥有独立人格对于社交的重要性,并教给你三个培养孩子内在独立人格的方法。这一讲,我们来分别谈谈内向性格和外向性格的孩子应该如何主动社交和得体社交。</p><p>大多数人可能认为性格内向的孩子在社交上因为缺乏主动,可能会存在很大问题。</p><h2><span id="问题内向孩子怎样触发社交主动性">问题内向孩子,怎样触发社交主动性?</span></h2><p>可能你自己是内向的人,不大喜欢和别人主动交往,但是又希望孩子和自己不一样,可以更加开朗外向。也可能你自己比较外向,所以怎么也搞不懂家里为啥会有一个这么内向的孩子。</p><p>别担心,首先我想告诉你的是,内向孩子也有自己独特的社交优势。</p><p>哈佛大学的Randy Buckner研究发现:内向的人脑前额叶皮质里面的灰色物质更大更厚,而这个区域是与抽象思维和做决定相关的,所以内向的人一般会坐在角落里面思考周全以后才做决定。</p><p>而外向的人正好相反,他们更活在当下,经常会在还没完全思考清楚的情况下就去冒险。</p><p>也就是说,内向的孩子并不是不喜欢跟周围的人互动。只不过面对外界刺激,他们比外向的孩子更稳重、谨慎,社交中的“反射弧”更长。这是一件坏事吗?当然不是。</p><p>很多专家学者在内向的人有自己的优势上面已经达成了共识,那就是性格内向的人和他人的工作关系更融洽、友谊更长久,与人交往时注意力更加集中,也更有责任感和创造力。</p><p>所以你看,性格内向的孩子也有自己的社交优势,关键看你能否找到合适的方式去激发它。</p><p>如果孩子性格内向,你应该怎么做?</p><p>通过言传身教给孩子做榜样,把你是如何参加社交活动的自然而然地展示给他们看,让孩子在学习和模仿中慢慢变得开朗。</p><p>如果你觉得自己也不擅长主动社交,那我教你一个方法,那就是把社交活动纳入到家庭待办事项清单里。</p><p>比如定期邀请朋友全家一起吃饭或郊游,或者和三五好友一起出去玩。让主动社交从可做可不做的事,变成每隔一两周必须去做的事,赋予它一些规律性和仪式感。就像逛街、看电影一样,让它成为家庭曰常活动的一部分。</p><p>内向的孩子大都比较敏感,带孩子参加社交活动时,一定要让他们有安全感,让孩子知道两点:</p><ol><li><p>你就在身边,有任何问题或困难可以随时向你求助;</p></li><li><p>如果他感觉不舒服,可以提前退场或者到一个安静的角落做自己喜欢的事。</p></li></ol><p>触发内向孩子的社交主动性应该从家庭内部开始做起,从家长的影响和鼓励开始,再邀请周围的人参与,帮孩子慢慢打开社交圈。</p><h2><span id="问题二外向孩子怎样设立社交边界">问题二:外向孩子,怎样设立社交边界?</span></h2><p>外向的孩子热情、健谈、精力旺盛,他们本身需要从和他人的交往中获得能量和满足感,这样的孩子也容易获得家长和社会环境的认同。</p><p>但是不是他们在社交上就没有问题了呢?当然不是,外向孩子很容易以自我为中心,过分关注自我表现,有时会人来疯,有时会让人感到热情过度,甚至会惹人反感。</p><p>外向孩子的家长要注意两点:</p><p>第一:在家立规矩</p><p>孩子基本的礼貌和教养一定要在家从小培养,你要教会他基本的礼貌和礼仪;</p><p>第二:出门划界限</p><p>跟孩子约定,注意观察所在环境和周围人的表现,关注别人的感受。一旦孩子有热情过度或反应过激的言行,家长有权力立刻制止他们,甚至是带他们离开现场。</p><p>下面我要教给你三个方法,你可以通过平常和孩子一起练习,帮助孩子掌握社交主动权,并且做到得体地社交。不管是内向还是外向的孩子,这些方法都很管用。</p><h2><span id="方法一传球游戏">方法一:传球游戏</span></h2><p>教给慢热型的内向孩子如何不冷场,自来熟的外向型孩子如何不夸夸其谈招人烦,传球游戏就是一个好方法。</p><p>我平时在家里是这么跟孩子玩的:</p><p>我们一般面对面站着,相隔两米左右,我手里拿着一个网球。</p><p>我先提_个问题,比如:“你喜欢哈利•波特的书吗?”然后我把球扔给他。</p><p>如果孩子只是简单地回答:“喜欢”,那么球就只能停在他手里,不能再传给我。</p><p>但是如果他说:“喜欢,因为这本书很有趣,我喜欢哈利波特和伏地魔斗争的故事”,那么他就可以把球再传给我。</p><p>通过上面的例子,想必你也发现了这个游戏的核心在于,一方提出的问题,另一方的回答必须深入、具体,能给提问者一些新的由头来提出更多的问题,让谈话可以继续下去,球才能来回传递。缺乏内容的对话,或者不着边际的闲聊都不能把球传递下去。</p><p>这个游戏一共有四个要点:</p><p>要点一,小孩子一般很快就能掌握游戏规则,但刚开始玩的时候,也容易卡壳,不知道该怎么接话,这时你要注意启发他。</p><p>比如,还是上面的场景。我接着问,”你最喜欢书中哪些人物?”孩子回答:”哈利波特和赫敏。”我会说:”这样的话,我就没法问出下一个问题,球又不能传给我啦……说说你为什么喜欢哈利波特和赫敏吧?”孩子就会认真想想,然后回答:”我喜欢哈利波特,因为他很勇敢。我喜欢赫敏是因为她聪明机智,又漂亮。那么,你最喜欢谁昵?”看,这样回答就很赞了。</p><p>要点二,你要使用一些话术,不断鼓励孩子把对话进行下去。</p><p>比如“真棒,我喜欢你的回答。”或者“这真是一个好的开始,这个话题真有意思。”或者“太好了,我们进行了10分钟的传球游戏了,都没停过。”</p><p>要点三,你可以进一步鼓励孩子开启新的话题。</p><p>比如,“妈妈,你今天过得开心吗?”“爸爸,为什么我们很久都没去动物园了?”通过这样的问答,一家人交换对过去发生的事、家庭未来计划等的看法,很有点“真心话大冒险”的意思,非常有趣。</p><p>要点四,你要寻找恰当的时机,让孩子明白传球游戏在生活中的意义。</p><p>等到孩子比较熟练地掌握了传球游戏,我会在他们状态不错的时候,提示以前发生过的和朋友或其他成年人的对话场景。</p><p>比如有一次我跟老大说:“记得今天下午张阿姨邀请你去她家和她儿子小明玩,在吃饭的时候,她问你玩得开心不开心?她是想跟你开始一个对话。但你只是说:开心。你觉得这样的球能扔回给她吗?”</p><p>这样,孩子就明白我的意思了,“球”——也就是话题,停在了他的手中,游戏就没法进行下去了。然后我们就开始讨论他应该怎么回答,才能把“球”再传出去。</p><h2><span id="方法二赞美游戏">方法二:赞美游戏</span></h2><p>内向的孩子观察能力强,善于分析,我们不妨利用这个优势,让孩子主动寻找他人的亮点,并加以赞美。</p><p>外向型的孩子容易更多地关注自己,这个游戏可以让他们学习观察别人,关注别人,分享自己的赞美给他人。可以作为家人,分享自己的赞美给他人。可以作为家庭会议中一个常规环节,每周都可以练习。</p><p>我们家一般是在周末的晚餐后做这个游戏。到了吃甜点的时间,全家坐在餐桌前,每个人都要说出挨着你的下一位在这_周内值得表扬的事情。</p><p>比如从我的小儿子亚当开始,他要告诉大家他从哥哥亚力身上发现的亮点,他说:“哥哥在听说我要做手术的时候,很关心我,跑过来安慰我,说可怜的亚当,</p><p>不要害怕,我们都会一直陪在你身边。”</p><p>哥哥听了很高兴,拍了拍亚当的肩膀,然后看了看坐在旁边的我,说:“妈妈很善于启发别人,她的学生这周跟她说因为上了妈妈的课,改变了自己的生活。”</p><p>我说:“亚力,原来妈妈和爸爸说话的时候,你都注意听了,谢谢你赞美我。这周我注意到爸爸每天晚上都给我们打电话,</p><p>我觉得他出差那么辛苦,还想着每天和你们睡前聊天,值得表扬。”</p><p>轮到先生了,他看着亚当说:“亚当上一周承诺他会收拾玩具房,这周他果然做得不错。承诺过的事情就负责做好,赞一个。</p><p>你看,这样的赞美游戏除了鼓励孩子发现家人身上的优点,还让家庭气氛更融洽、更活跃了。</p><p>其实,除了关注家庭成员,你还可以让孩子注意观察周围人或者同学的优点。</p><p>我有时会在孩子吃完早餐上学之前,给他们留一个挑战作业。要求他们当天去观察别人做得好的地方,并真诚地赞美一个同学或者老师。</p><p>这种游戏似的挑战,孩子们很喜欢。因为经常赞美别人,他们也时常会得到他人的正面回应。回家后,他们还会兴高采烈地汇报给我听,说自己是如何完成挑战的。</p><p>赞美他人的训练除了让孩子学会关注他人的优势,见贤思齐外,还让他们具备了一个社交优势,就是赢得别人的好感。因为任何人都希望自己被关注,善意地关注他人,就会臝得对方的好感。</p><h2><span id="方法三邀请其他孩子来自己家玩">方法三:邀请其他孩子来自己家玩</span></h2><p>通过邀请其他孩子来自己家玩,占据主场优势,内向孩子会更主动积极,外向孩子也不容易失礼。</p><p>内向的孩子更善于一对一交往,你可以每一周或每两周让孩子约一个要好的小朋友到家里来玩。外向的孩子你就可以同时邀请几个小朋友一起来玩。</p><p>因为是在自己家,内向孩子对环境更熟悉,会更积极、放松,外向孩子则会把注意力放在跟别的小朋友互动上,而不是因为对环境好奇、兴奋而翻箱倒柜,上蹿下跳的。</p><p>你可以跟孩子一起提前准备好要玩的游戏,比如一般男孩子喜欢枪战,搭乐高,或者到户外玩球;女孩子喜欢玩过家家,做手工,画画等等。</p><p>小主人要为客人提供几个不同的选项,充分的准备会让内向的孩子觉得更踏实,也能从对活动的掌控中获得更多的乐趣和自信。</p><p>对外向孩子来说,准备好要玩的游戏,也能提前给他们建立规则和边界意识,防止游戏过程中注意力不集中或者有不合适的举止行为发生。</p><p>在这个过程中,家长最好不要干预孩子之间的游戏。因为孩子是主人,他需要对如何跟客人互动,如何照顾好客人的需要负起责任。哪怕结果是他们各玩各的,你也不必担心。</p><p>等到活动结束后,送走了客人,你再跟孩子做个“采访”,让他讲一讲今天为什么玩得很开心或者不太开心,下一次打算邀请什么样的小伙伴。你还可以跟孩子讨论小客人身上有哪些亮点或特长,有什么可以学习的地方。</p><p>需要提醒你的是,内向的孩子容易在与人交往中感到刺激过度,需要通过独处来恢复精力,所以每次游戏的持续时间不要太长,通常一个小时之内比较好。社交活动也不要安排得太频繁,最多一周一次。让孩子有足够的时间在家里休息,给自己充电。</p><p>而对外向的孩子,你要特别注意他们是否能够尽到地主之谊,关注和照顾到小客人的需要。</p><h2><span id="小结">小结</span></h2><p>今天我们讲了内、外向孩子在社交习惯上的区别。</p><p>我们还分享了触发孩子社交主动性和得体社交的三个方法,分别是:<br>通过传球游戏练习一对一的对话;<br>通过赞美游戏寻找别人身上的亮点;<br>通过邀请小伙伴到家里玩,来掌握社交主动权。</p><p>小作业:</p><p>请你回家和孩子一起玩传球对话的游戏。<br>你选择了什么样的话题?<br>过程中遇到了什么样的问题?<br>孩子和你最多能进行几个来回的对话呢?</p>]]></content>
<categories>
<category> 亲子教育 </category>
<category> 如何培养受欢迎的孩子 </category>
</categories>
<tags>
<tag> 亲子教育 </tag>
<tag> 如何培养受欢迎的孩子 </tag>
</tags>
</entry>
<entry>
<title>如何培养受欢迎的孩子--1.人格独立是真正受欢迎的根基</title>
<link href="/2020/04/28/ren-ge-du-li-shi-zhen-zheng-shou-huan-ying-de-gen-ji/"/>
<url>/2020/04/28/ren-ge-du-li-shi-zhen-zheng-shou-huan-ying-de-gen-ji/</url>
<content type="html"><![CDATA[<h1><span id="如何培养受欢迎的孩子人格独立是真正受欢迎的根基">如何培养受欢迎的孩子–人格独立是真正受欢迎的根基?</span></h1><p>第一讲,我要帮你树立一个观点,人格独立才是受欢迎的前提。</p><p>这一讲里,我就重点和你说说怎么在人格独立的基础上。用三个办法培养孩子的受欢迎能力。这三个办法分别是:</p><ol><li><p>优势游戏法</p></li><li><p>理性反馈法</p></li><li><p>15秒钟积极转念法</p></li></ol><p>如果你的孩子上过或者正在上幼儿园,是不是每个幼儿园都有这样两种孩子。</p><p>一种孩子,比较强势,喜欢发号施令,在班里说_不二;</p><p>另外一种孩子,每说一句话都要看看别人的反应,他们希望别人喜欢自己,不喜欢和任何人发生冲突。</p><p>这两种孩子看上去人缘都很好,但这不是我要说的真正受欢迎的孩子。</p><p>这两种孩子,前一种孩子,长大后,可能因为强势的性格和霸道的作风,变得并不讨人喜欢;而后一种孩子长大后,很可能会成为别人眼中的老好人,一味迎合别人,最终会失去自己。</p><p>什么是人格独立呢?</p><p>我来给你讲一个我自己经历过的故事。</p><p>我刚进哈佛商学院时,前三周是基础课,各种课程和班级都是随机安排的,这就给了大家一个互相认识的好机会。</p><p>跟不同国籍、背景的同学交流,我最大的感受是,真正受欢迎的人,在人际交往中体现出的真诚、自信,不是以外界反馈、别人评价为基础的,而是骨子里对自己有什么优势、哪里有短板认识得很清楚。</p><p>这种特质就是人格独立。</p><p>可以说,人格独立是受欢迎的基础。只有当一个人实现了人格独立,他的自信才能内化成一种个人魅力,不会随着外部环境和评价的变化而变化。</p><p>缺乏独立人格,也正是霸王型或讨好型孩子,长大以后不能持续受欢迎的真正原因。</p><h3><span id="独立人格三要素">独立人格三要素</span></h3><p>拥有独立人格,有这样三个要素:自我认知,接受反馈的能力和抵抗挫折的能力。</p><ol><li>自我认知:</li></ol><p>这是指能够清楚地知道自己是谁,对自己兴趣和能力的边界有清晰的认知。</p><ol start="2"><li>接受反馈的能力:</li></ol><p>反馈就有正面和负面。如何看待这些反馈,尤其是负面反馈,是独立人格的重要表现。</p><p>如果一被夸奖就高兴,一被否定就不开心,这样的孩子长大后,很容易成为以自我为中心的”霸王型”,或是完全没有主见的”讨好型”。</p><ol start="3"><li>抵抗挫折的能力:</li></ol><p>它是独立人格形成的重要保障。抵抗挫折的能力是指孩子在遇到挫折的时候,能正视困难,不轻易否定自己,可以像不倒翁一样,跌倒了再爬起来。</p><p>针对这三个要素,接下来,我和你重点说说培养孩子独立人格的二个方法。</p><h3><span id="方法一优势链成就箱">方法一:优势链+成就箱</span></h3><p>家长的认知和孩子的优势之间,是有偏差的。有时你觉得孩子喜欢唱歌跳舞,其实他们只是想要讨好你。你认为孩子弹琴有天赋,他们只是为了通过考级而不得不完成任务。</p><p>所以,我给你的建议是,与其一厢情愿地帮孩子开发兴趣和潜力,不如用游戏的方式鼓励孩子去发现、确认自己的优势,并从中犹得乐趣。</p><p>在这里,我给你推荐两个简单的小游戏,一个是优势链,一个是成就箱。</p><ol><li>优势链</li></ol><p>首先,你要让孩子把自己的优势写在彩色的纸条上,把纸条粘成一个圈,然后把所有的优势一个套一个地串起来,做成孩子的”优势链”。</p><p>从戴在手腕上的”手链”,到挂在脖子上的”项链”。优势链越长,越能玩出更多的花样。除了在上面写字,还可以画画、涂色等。</p><p>这个游戏隔一段时间就可以做一次。每制作一条优势链,就可以把之前做的拿出来比较一下,看看新增了哪些优势。然后放在一起,让孩子通过链条的长短、花样等,看到自己不同阶段的成长。</p><p>孩子写下自己的优势时,你可以在旁边引导,”会画画……嗯,没错,你上次画的那条美人鱼真的很漂亮。””吃饭很快……为什么你觉得吃饭快是个优势呢?说来听听吧…..</p><p>像这样,一边念出孩子写下的优势,一边跟他讨论、回忆具体细节,你会逐渐发现孩子真正的兴趣和潜力在哪里。这个游戏的过程,不但帮孩子认识到自己的优势,还帮助他表达、确认了自己的优势。</p><ol start="2"><li>成就箱</li></ol><p>从读小学起,我就让两个孩子做了自己的成就箱,拿普通的装纸巾的盒子就可以。他们把学习、生活中取得的任何成绩或进步,都写成纸条放进去。</p><p>比如,”我在学校帮助小朋友找到教室”,”我记得收拾自己的碗筷”,”我今天问了老师一个不懂的问题”等等,都可以成为小纸条的内容。</p><p>等到成就箱被装满,我会跟孩子一起,先把纸条掏出来,大声读出上面的字,然后跟孩子一起回忆纸条上发生的事情,再把纸条分类。</p><p>比如,帮助别人的放一堆,学习进步的放一堆。这样就很容易看出哪些事情做得比较好,哪些还有待加强。</p><p>慢慢的,你就会发现,这些看起来小小的“成就纸条”,推动着孩子不断进步和提高。随着成就箱一点点被填满,孩子的自信会一点点增长,对随时随地发挥优势也会更加乐此不疲。</p><h3><span id="方法二学会理性反馈">方法二:学会理性反馈</span></h3><p>主要有两点,一是,如何面对正面反懐,二是,如何面对负面反馈。</p><p>听到别人夸奖自己时,咱们中国人往往会谦虚一下:”哪里哪里?我还差得远呢。”可是,这样的教育方式,不利于孩子培养自己的自信,也不真诚。</p><ol><li>怎样教孩子面对别人的称赞呢?</li></ol><p>我的做法是,鼓励孩子在听到夸奖时,除了说”谢谢!”还要尽量多说一些细节。比如”谢谢!我真的很努力!”或者说:”谢谢!这次比赛我真的很重视,每天都练习,得到了好结果,我也很高兴。”</p><p>这样的回答,既显示出孩子的自信,也能引发孩子继续思考,对方这么说是出于礼貌,还是真的觉得自己做得好。</p><ol start="2"><li>怎样教孩子面对负面、消极反馈?</li></ol><p>同样的道理,当孩子听到来自他人的负面、消极的反馈时,你也要注意引导他们回忆当时的场景,思考为什么会有这样的评价。然后跟孩子讨论,而不是盲目地维护或教育孩子。</p><p>当孩子还原出整个过程,得出了自己的结论,你再顺着他的思路告诉孩子,不要因为别人说了自己不好的地方,就否定自己。</p><p>用学习的心态问问自己:别人为什么会这样说?如果是真正的错误或者缺点,那就需要改正。如果是出于误解、妒忌或者只是因为对方情绪不好,脱口而出的话,那</p><p>从理性分析的角度出发,认真客观地对待自己的优势和缺点,任何负面的经历都可以转化成正面积极的学习的过程,孩子也会更加自信。</p><h3><span id="方法三15秒积极转念法">方法三:15秒积极转念法</span></h3><p>孩子在家或者学校都难免遇到困难和挫折,有可能是同学的孤立,学习上的难题,也可能是遭遇到失败和恐惧。我来给你讲讲用15秒钟积极转念法怎么做。</p><p>这个方法可以分成三步:</p><p>第一步,是当孩子经历负面情绪时,我会鼓励他_边深呼吸,一边在心里默默数15秒,利用这段时间来让自己冷静降温;</p><p>第二步,再用15秒,尽情地把负面情绪表达出来。比如”我不喜欢某某,他让我难堪弟弟真讨厌,他烦死了”;”数学作业太难了,让我心烦。”</p><p>第三步,我会引导孩子在头脑中想象一个他喜欢的画面,画面可以是阳光、海水、沙滩,或者全家一起骑自行车、玩游戏等等。</p><p>如果孩子不愿意配合,他会说:”我还在生气,根本想不出什么美好的事情!”所以,你要注意,做这个练习,平时就需要有意识地引导孩子去积累一些美好记忆。</p><p>比如,我家老大常说,小时候有一次我们在餐馆的尽情逗笑,是他最美好的记忆。后来,在他生气或者沮丧要转念的时候,我就提醒他赶快在脑子里换频道,播放这个美好的记忆画面。</p><p>这个过程刚开始有点难,但我不断坚持帮他回忆当时的一些画面场景。慢慢的,他平静下来,最后顺利地从坏情绪中抽离出来。</p><h3><span id="本讲小结">—♦本讲小结♦—</span></h3><p>你首先知道了孩子的独立人格是受欢迎的基础,如果没有独立人格,孩子长大后很容易迷失自己,不再受欢迎。</p><p>你又收获了培养独立人格的三个方法:</p><p>方法一,你可以通过优势链和成就箱两个小游戏帮孩子找到优势;</p><p>方法二,教孩子理性看待反馈,尤其是负面反馈。</p><p>方法三,可以用15秒积极转念法帮助孩子提高抵抗挫折的能力。</p><p>小作业:</p><p>用我教你的方法,帮助孩子一起做一个优势链。在制作的过程中,孩子是什么样的反应,你有什么心得和体会,请写在留言区里,和我互动。期待看到你的留言。</p>]]></content>
<categories>
<category> 亲子教育 </category>
<category> 如何培养受欢迎的孩子 </category>
</categories>
<tags>
<tag> 亲子教育 </tag>
<tag> 如何培养受欢迎的孩子 </tag>
</tags>
</entry>
<entry>
<title>如何培养受欢迎的孩子--0.哈佛喜欢什么样的孩子</title>
<link href="/2020/04/28/ha-fo-xi-huan-shi-me-yang-de-hai-zi/"/>
<url>/2020/04/28/ha-fo-xi-huan-shi-me-yang-de-hai-zi/</url>
<content type="html"><![CDATA[<h1><span id="如何培养受欢迎的孩子0哈佛喜欢什么样的孩子">如何培养受欢迎的孩子–0.哈佛喜欢什么样的孩子?</span></h1><p>最近学习《如何培养受欢迎的孩子》总结一下心得</p><h2><span id="一个孩子受欢迎有多重要">一个孩子受欢迎有多重要?</span></h2><p>先来分享一个我的经历:<br>哈佛大学每年都会通过面试录取高中毕业生,面试官一般都是哈佛校友。作为校友,从2009年开始,我每年都会花时间承担这个义务。<br>你可能会好奇,世界顶尖学府面试挑人,到底都看什么?其实没那么复杂。<br>哈佛面试官衡量学生的标准只有三个:学习成绩、课外活动和Character。Character<br>这个词对应汉语有点复杂,它包含了人格、品性、价值观、性格等等。<br>在Character这一项里,专门有一道题,面试官要给每一个学生打分,题目是:<br>“这个学生是不是一个容易相处的室友?”</p><h3><span id="哈佛挑学生不光看学习成绩还考察一个人能不能跟别人融洽相处">哈佛挑学生,不光看学习成绩,还考察一个人能不能跟别人融洽相处。</span></h3><p>这条选人标准在我的经历中也得到了印证。我从小在国内长大,身边环绕的净是学霸,现在人到中年,回过头来再看当年的同学,最成功的不一定是当年学习最拔尖的,而是最善于和别人相处的。<br>从哈佛商学院毕业以后,已经在美国生活了18年。我在美国的大型企业、创业公司和投资基金都做过髙管,后来又创建了自己的咨询公司。<br>在20多年的职场生涯中,我和政府很多的高层领导、大公司的CEO、基金合伙人都打过交道。职场经验告诉我,不论在中国还是在美国,大家眼中的成功人士,其实都是善于沟通的社交高手,拥有优质的可调动的社会关系。<br>在美国,我找工作、谈合作、找投资,第一反应都会先想想,有没有可以求助的哈佛校友。而我自己,也常常接到校友的求助,伸出援手。强大的校友人脉体系,恰恰是哈佛商学院的竞争力所在。<br>而这种人脉网络的搭建,在哈佛商学院体系中无处不在。上学的时候有学习小组、兴趣俱乐部,毕业后有向校友开放的庞大数据库,大家也经常做服务校友的志愿工作,互相支持,而且每五年都有一个返校聚会,对我们来说就像过节一样。<br>这些年,我也开始给成年人开设人脉课。接触到大量的案例后,我发现,很多人总是羡慕别人人脉广,自己却无从抓起。<br>其实,我越来越觉得,人脉固然是成年以后的事,但一个人有没有受欢迎的能力,这事根本得从小时候练习。<br>我有两个儿子,既然从哈佛商学院学了这套人脉搭建法,我干脆把这套办法,用在了自己家儿子身上。<br>当然,我不是像教授在课堂上那么教,而是把学校里学的这套办法,转化成家庭游戏,在娱乐中培养他们的社交能力。你别说,还真管用。我的两个孩子,哥哥和弟弟互相友爱,他们在学校里也很自信,有同理心,有很多朋友。<br>现在,很多家长非常重视孩子的教育,在提高孩子学习成绩和鼓励他们参加课外兴趣班上不遗余力,投入巨大,但孩子社交能力的培养却没有得到应有的重视,我觉得非常可惜。<br>事实上,有不少学霸型的孩子,到了大学或进入职场后,因为不懂团队合作,不会跟别人打交道而被同学、同事孤立,严重的还会引发一些心理问题。<br>我认为,比在成年后针对社交问题去纠偏更重要的,是在一个人的童年时期就培养出受欢迎的能力。<br>现实问题是,今天中国的80、90后已经开始当家长了。<br>比如你,很可能自己就是独生子女,从小既缺兄弟姊妹的陪伴和竞争,住在城市的单元楼里,一起玩的孩子也不多,长辈又过分关怀,社交能力往往是”缺失的一环”。当了爹妈,怎么教孩子社交,也有点抓瞎。<br>常有别的父母问我,都说性格是天生的,我本身性格内向,孩子也这样,怎么推都推不动,后天能改进吗?<br>答条是肯定的。<br>性格内向的孩子并不是,不喜欢跟周围的人互动,只不过面对外界刺激,他们比外向的孩子更谨慎,社交中的”反射弧”更长。而这,其实也是他们自己的社交优势,这样的孩子也因此常给人踏实、靠谱的印象。<br>一个人的受欢迎度不是天生的,而是可以通过后天学习和训练获得的。你需要用符合孩子个性的方式,尝试跟孩子一起改变,不断激发他的社交主动性。<br>在接下来的课程里,我会教给你一些具体的方法。<br>我的这门课里,会把这些经验和实践,倾嚢而出。跟你分享,如何培养孩子受欢迎的能力。<br>这里说的受欢迎,不是指那种因为形象出众或学习成绩好,而在学校或社会中受到优待;也不是缩手缩脚,每说一句话都要看别人反应的”讨好型”的孩子。<br>而是建立在人格独立基础上,真诚、自信、得体地和人交往,并因此受到周围人的喜爰,得到他们的肯定和赞赏。<br>一个受欢迎的孩子,内在具有稳定、正向的自我评价系统,知道自己是谁,自己的优势、短板在哪里,不会为了迎合外界,或者讨好他人,而去委屈自己。<br>最终表现出来的外在行为,就是懂得在不同场合大方得体地展现自己,在社交活动中既自信又谦逊,具有稳定、持续的人格魅力。<br>一个受欢迎的孩子,无论到什么环境里都容易交到朋友,这些朋友中有孩子,也有大人。<br>大家都喜欢和他一起玩,喜欢和他说话,遇到问题时也会马上问问他的意见或者请他一起帮忙。这对他们成年后积累社会人脉资源有直接影响。<br>受欢迎的孩子,自信、阳光、擅长沟通、同理心强,又喜欢帮助别人。他们像发光体一样,吸引着别人,在心理和生理上也更加健康,看待世界更加正面,有着更多的正能量。<br>而且,受欢迎的孩子长大做了父母以后,很有可能会把这种潜质遗传给自己的孩子。</p><p>要培养孩子受欢迎的能力,总的原则是”由内到外”,”由近及远”。</p><ol><li>“由内到外”:<br>家长应该从培养孩子内在的独立人格做起,激发孩子的内在主动性,帮助他们完全打开自己,既能和同龄人友好相处,也能赢得身边大人的真心喜爱。</li><li>“由近及远”:<br>先在家庭内部创造平等沟通、爱和信任的氛围,跟家人建立良好互动后,再逐渐扩大社交半径,教给孩子和周围人一对一沟通的方法,和陌生人得体交流的能力,实现从家人到陌生人的融洽沟通。</li></ol><p>基于这个原则,我会在这门课程中,分六讲教给你一些具体的方法。</p><p>帮助你内在培养孩子的独立人格,外在解决他们和家里人、周围人以及陌生人交往中的实际问题,成为真正受欢迎的孩子。<br>第一讲,受欢迎的内在根基 ———— 人格独立。教你用优势游戏、理性反馈法和积极转念法三个方法,构建孩子内在的支持系统。<br>第二讲,分别针对内向型和外向型的孩子,教你用传球游戏、赞美游戏和邀请小伙伴到家里玩,来激发他们内在的社交主动性,建立得体社交的分寸感。<br>第三讲,教给你帮助孩子打开自我的三种场景,让孩子更好地融入陌生环境。<br>第四讲,教孩子怎么和同龄人融洽相处。<br>第五讲,教给你一些话术和训练方法,帮助孩子提高跟家里人、周围人,以及陌生人的平等、深入对话的能力,在获得成年人喜爱的同时,保护好自己。<br>第六讲,根据性别的不同,结合男孩和女孩不同的特质和需要,教你培养受欢迎的男孩和女孩。<br>特别期待你能带着问题来跟我一块学习。孩子就像一张白纸,父母在他们身上画出的最初印记,会深深地影响着他们的一生。你的学习,将促成他们的改变。</p>]]></content>
<categories>
<category> 亲子教育 </category>
<category> 如何培养受欢迎的孩子 </category>
</categories>
<tags>
<tag> 亲子教育 </tag>
<tag> 如何培养受欢迎的孩子 </tag>
</tags>
</entry>
<entry>
<title>十大经典排序算法整理汇总(附代码)</title>
<link href="/2020/02/16/sort-algorithms/"/>
<url>/2020/02/16/sort-algorithms/</url>
<content type="html"><![CDATA[<blockquote><p>关注公众号【算法码上来】,每日算法干货马上就来!</p></blockquote><p><img src="/medias/contact.jpg" alt></p><h2><span id="前言">前言</span></h2><p>本文整理并总结了十大经典的排序算法(冒泡排序、选择排序、插入排序、快速排序、归并排序、希尔排序、计数排序、基数排序、桶排序、堆排序)的时间复杂度、空间复杂度等性质。</p><p><strong>本文并不会详细讲解每种排序算法的原理</strong>,网上有很多很好的教程,大家可以自己去搜了看。</p><p>最后我还亲自手写了十种排序算法的 c++ 代码,大家可以用来通过 <a href="https://leetcode-cn.com/problems/sort-an-array/" title="LeetCode 912. 排序数组" target="_blank" rel="noopener">LeetCode 912. 排序数组</a> 这道题。</p><h2><span id="性质汇总">性质汇总</span></h2><blockquote><p>如果发现表中有错误,请留言告知。</p></blockquote><table><thead><tr><th>算法</th><th>最好</th><th>最坏</th><th>平均</th><th>空间</th><th align="center">稳定性</th><th align="center">是否基于比较</th></tr></thead><tbody><tr><td>冒泡排序</td><td>$O(n)$</td><td>$O(n^2)$</td><td>$O(n^2)$</td><td>$O(1)$</td><td align="center">$\checkmark$</td><td align="center">$\checkmark$</td></tr><tr><td>选择排序</td><td>$O(n^2)$</td><td>$O(n^2)$</td><td>$O(n^2)$</td><td>$O(1)$</td><td align="center">$\times$</td><td align="center">$\checkmark$</td></tr><tr><td>插入排序</td><td>$O(n)$</td><td>$O(n^2)$</td><td>$O(n^2)$</td><td>$O(1)$</td><td align="center">$\checkmark$</td><td align="center">$\checkmark$</td></tr><tr><td>快速排序</td><td>$O(n\log n)$</td><td>$O(n^2)$</td><td>$O(n\log n)$</td><td>$O(\log n)$~$O(n)$</td><td align="center">$\times$</td><td align="center">$\checkmark$</td></tr><tr><td>归并排序</td><td>$O(n\log n)$</td><td>$O(n\log n)$</td><td>$O(n\log n)$</td><td>$O(n)$</td><td align="center">$\checkmark$</td><td align="center">$\checkmark$</td></tr><tr><td>希尔排序</td><td>$O(n^{1.3})$</td><td>$O(n^2)$</td><td>$O(n\log n)$~$O(n^2)$</td><td>$O(1)$</td><td align="center">$\times$</td><td align="center">$\checkmark$</td></tr><tr><td>计数排序</td><td>$O(n+k)$</td><td>$O(n+k)$</td><td>$O(n+k)$</td><td>$O(n+k)$</td><td align="center">$\checkmark$</td><td align="center">$\times$</td></tr><tr><td>基数排序</td><td>$O(nk)$</td><td>$O(nk)$</td><td>$O(nk)$</td><td>$O(n+k)$</td><td align="center">$\checkmark$</td><td align="center">$\times$</td></tr><tr><td>桶排序</td><td>$O(n)$</td><td>$O(n)$</td><td>$O(n)$</td><td>$O(n+m)$</td><td align="center">$\checkmark$</td><td align="center">$\times$</td></tr><tr><td>堆排序</td><td>$O(n\log n)$</td><td>$O(n\log n)$</td><td>$O(n\log n)$</td><td>$O(1)$</td><td align="center">$\times$</td><td align="center">$\checkmark$</td></tr></tbody></table><blockquote><p>如果表格显示有问题的话,还可以直接看下面的汇总图:</p></blockquote><p><img src="1.png" alt="十大经典排序算法性质汇总"></p><h3><span id="维基百科">维基百科</span></h3><p>我觉得还是英文维基百科讲的比较详细、严谨。如果大家看的比较累的话,可以自己百度搜索相应的教程。</p><p><strong>冒泡排序</strong><br><a href="https://en.wikipedia.org/wiki/Bubble_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Bubble_sort</a></p><p><strong>选择排序</strong><br><a href="https://en.wikipedia.org/wiki/Selection_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Selection_sort</a></p><p><strong>插入排序</strong><br><a href="https://en.wikipedia.org/wiki/Insertion_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Insertion_sort</a></p><p><strong>快速排序</strong><br><a href="https://en.wikipedia.org/wiki/Quicksort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Quicksort</a></p><p><strong>归并排序</strong><br><a href="https://en.wikipedia.org/wiki/Merge_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Merge_sort</a></p><p><strong>希尔排序</strong><br><a href="https://en.wikipedia.org/wiki/Shellsort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Shellsort</a></p><p><strong>计数排序</strong><br><a href="https://en.wikipedia.org/wiki/Counting_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Counting_sort</a></p><p><strong>基数排序</strong><br><a href="https://en.wikipedia.org/wiki/Radix_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Radix_sort</a></p><p><strong>桶排序</strong><br><a href="https://en.wikipedia.org/wiki/Bucket_sort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Bucket_sort</a></p><p><strong>堆排序</strong><br><a href="https://en.wikipedia.org/wiki/Heapsort" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Heapsort</a></p><h2><span id="代码实现">代码实现</span></h2><p>所有的排序算法接口都是相同的,也就是 <code>vector<int> xxxSort(vector<int>& nums)</code> 。只需要你传入一个 <code>vector<int></code> 类型的数组,就能返回排序后的结果。</p><p>运行下来可以发现,桶排序速度是比较快的。而冒泡排序、选择排序和插入排序因为时间复杂度太高无法通过本题,基数排序因为无法处理负数也不能通过本题。</p><pre class="line-numbers language-cpp"><code class="language-cpp"><span class="token keyword">class</span> <span class="token class-name">Solution</span> <span class="token punctuation">{</span><span class="token keyword">public</span><span class="token operator">:</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">sortArray</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token function">quickSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 冒泡排序(超时)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">bubbleSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> n<span class="token number">-2</span><span class="token punctuation">;</span> j <span class="token operator">>=</span> i<span class="token punctuation">;</span> <span class="token operator">--</span>j<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span> <span class="token operator">></span> nums<span class="token punctuation">[</span>j<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>j<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 选择排序(超时)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">selectSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> idx <span class="token operator">=</span> i<span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> i<span class="token punctuation">;</span> j <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>j<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span> <span class="token operator"><</span> nums<span class="token punctuation">[</span>idx<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> idx <span class="token operator">=</span> j<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>idx<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 插入排序(超时)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">insertSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> i<span class="token punctuation">;</span> j <span class="token operator">></span> <span class="token number">0</span> <span class="token operator">&&</span> nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span> <span class="token operator"><</span> nums<span class="token punctuation">[</span>j<span class="token number">-1</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token operator">--</span>j<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>j<span class="token number">-1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 快速排序(24 ms)</span> <span class="token keyword">void</span> <span class="token function">qSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">,</span> <span class="token keyword">int</span> l<span class="token punctuation">,</span> <span class="token keyword">int</span> r<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>l <span class="token operator">>=</span> r<span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token keyword">int</span> m <span class="token operator">=</span> l<span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> l<span class="token punctuation">;</span> i <span class="token operator"><</span> r<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator"><</span> nums<span class="token punctuation">[</span>r<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>m<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>m<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>r<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token function">qSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> l<span class="token punctuation">,</span> m<span class="token number">-1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token function">qSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> m<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">,</span> r<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">quickSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token function">qSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> n<span class="token number">-1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 归并排序(192 ms)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">mSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">,</span> <span class="token keyword">int</span> l<span class="token punctuation">,</span> <span class="token keyword">int</span> r<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>l <span class="token operator">>=</span> r<span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token punctuation">{</span>nums<span class="token punctuation">[</span>l<span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token keyword">int</span> m <span class="token operator">=</span> l<span class="token operator">+</span><span class="token punctuation">(</span>r<span class="token operator">-</span>l<span class="token punctuation">)</span><span class="token operator">/</span><span class="token number">2</span><span class="token punctuation">;</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> lnums <span class="token operator">=</span> <span class="token function">mSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> l<span class="token punctuation">,</span> m<span class="token punctuation">)</span><span class="token punctuation">;</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> rnums <span class="token operator">=</span> <span class="token function">mSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> m<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">,</span> r<span class="token punctuation">)</span><span class="token punctuation">;</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> res<span class="token punctuation">;</span> <span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>i <span class="token operator"><=</span> m<span class="token operator">-</span>l <span class="token operator">&&</span> j <span class="token operator"><=</span> r<span class="token operator">-</span>m<span class="token number">-1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>lnums<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator"><</span> rnums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>lnums<span class="token punctuation">[</span>i<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>rnums<span class="token punctuation">[</span>j<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>i <span class="token operator"><=</span> m<span class="token operator">-</span>l<span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>lnums<span class="token punctuation">[</span>i<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>j <span class="token operator"><=</span> r<span class="token operator">-</span>m<span class="token number">-1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>rnums<span class="token punctuation">[</span>j<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> res<span class="token punctuation">;</span> <span class="token punctuation">}</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">mergeSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> nums <span class="token operator">=</span> <span class="token function">mSort</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> n<span class="token number">-1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 归并排序 + 非递归(80 ms)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">mergeSortNR</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> len <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> len <span class="token operator"><</span> n<span class="token punctuation">;</span> len <span class="token operator"><<=</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> l <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> l <span class="token operator"><</span> n<span class="token operator">-</span>len<span class="token punctuation">;</span> l <span class="token operator">+</span><span class="token operator">=</span> <span class="token number">2</span><span class="token operator">*</span>len<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> m <span class="token operator">=</span> l<span class="token operator">+</span>len<span class="token number">-1</span><span class="token punctuation">;</span> <span class="token keyword">int</span> r <span class="token operator">=</span> <span class="token function">min</span><span class="token punctuation">(</span>n<span class="token number">-1</span><span class="token punctuation">,</span> l<span class="token operator">+</span><span class="token number">2</span><span class="token operator">*</span>len<span class="token number">-1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> res<span class="token punctuation">;</span> <span class="token keyword">int</span> i <span class="token operator">=</span> l<span class="token punctuation">,</span> j <span class="token operator">=</span> m<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>i <span class="token operator"><=</span> m <span class="token operator">&&</span> j <span class="token operator"><=</span> r<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator"><</span> nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>i <span class="token operator"><=</span> m<span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>j <span class="token operator"><=</span> r<span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token operator">++</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> l<span class="token punctuation">;</span> i <span class="token operator"><=</span> r<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> res<span class="token punctuation">[</span>i<span class="token operator">-</span>l<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 希尔排序(40 ms)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">shellSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> gap <span class="token operator">=</span> n<span class="token operator">/</span><span class="token number">2</span><span class="token punctuation">;</span> gap <span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">;</span> gap <span class="token operator">/</span><span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> gap<span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> i<span class="token punctuation">;</span> j<span class="token operator">-</span>gap <span class="token operator">>=</span> <span class="token number">0</span> <span class="token operator">&&</span> nums<span class="token punctuation">[</span>j<span class="token operator">-</span>gap<span class="token punctuation">]</span> <span class="token operator">></span> nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">;</span> j <span class="token operator">-</span><span class="token operator">=</span> gap<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>j<span class="token operator">-</span>gap<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 计数排序(32 ms)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">countSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>n<span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token keyword">int</span> minv <span class="token operator">=</span> <span class="token operator">*</span><span class="token function">min_element</span><span class="token punctuation">(</span>nums<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> nums<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> maxv <span class="token operator">=</span> <span class="token operator">*</span><span class="token function">max_element</span><span class="token punctuation">(</span>nums<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> nums<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> m <span class="token operator">=</span> maxv<span class="token operator">-</span>minv<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">count</span><span class="token punctuation">(</span>m<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> count<span class="token punctuation">[</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token operator">-</span>minv<span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> res<span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> m<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> j <span class="token operator"><</span> count<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token operator">++</span>j<span class="token punctuation">)</span> <span class="token punctuation">{</span> res<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>i<span class="token operator">+</span>minv<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> res<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 基数排序(不适用于负数)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">radixSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> maxv <span class="token operator">=</span> <span class="token operator">*</span><span class="token function">max_element</span><span class="token punctuation">(</span>nums<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> nums<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> maxd <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>maxv <span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> maxv <span class="token operator">/</span><span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span> maxd<span class="token operator">++</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">count</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">rank</span><span class="token punctuation">(</span>n<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> base <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>maxd <span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> count<span class="token punctuation">.</span><span class="token function">assign</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> count<span class="token punctuation">[</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token operator">/</span>base<span class="token punctuation">)</span><span class="token operator">%</span><span class="token number">10</span><span class="token punctuation">]</span><span class="token operator">++</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> i <span class="token operator"><</span> <span class="token number">10</span><span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> count<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">+</span><span class="token operator">=</span> count<span class="token punctuation">[</span>i<span class="token number">-1</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> n<span class="token number">-1</span><span class="token punctuation">;</span> i <span class="token operator">>=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token operator">--</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> rank<span class="token punctuation">[</span><span class="token operator">--</span>count<span class="token punctuation">[</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token operator">/</span>base<span class="token punctuation">)</span><span class="token operator">%</span><span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">=</span> nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> rank<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> maxd<span class="token operator">--</span><span class="token punctuation">;</span> base <span class="token operator">*</span><span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 桶排序 (20 ms)</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">bucketSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> maxv <span class="token operator">=</span> <span class="token operator">*</span><span class="token function">max_element</span><span class="token punctuation">(</span>nums<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> nums<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> minv <span class="token operator">=</span> <span class="token operator">*</span><span class="token function">min_element</span><span class="token punctuation">(</span>nums<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> nums<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">int</span> bs <span class="token operator">=</span> <span class="token number">1000</span><span class="token punctuation">;</span> <span class="token keyword">int</span> m <span class="token operator">=</span> <span class="token punctuation">(</span>maxv<span class="token operator">-</span>minv<span class="token punctuation">)</span><span class="token operator">/</span>bs<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span> vector<span class="token operator"><</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token operator">></span> <span class="token function">bucket</span><span class="token punctuation">(</span>m<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> n<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> bucket<span class="token punctuation">[</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token operator">-</span>minv<span class="token punctuation">)</span><span class="token operator">/</span>bs<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">int</span> idx <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> m<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> sz <span class="token operator">=</span> bucket<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> bucket<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token function">quickSort</span><span class="token punctuation">(</span>bucket<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> j <span class="token operator"><</span> sz<span class="token punctuation">;</span> <span class="token operator">++</span>j<span class="token punctuation">)</span> <span class="token punctuation">{</span> nums<span class="token punctuation">[</span>idx<span class="token operator">++</span><span class="token punctuation">]</span> <span class="token operator">=</span> bucket<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true">// 堆排序(32 ms)</span> <span class="token keyword">void</span> <span class="token function">adjust</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">,</span> <span class="token keyword">int</span> p<span class="token punctuation">,</span> <span class="token keyword">int</span> s<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token operator">*</span>p<span class="token operator">+</span><span class="token number">1</span> <span class="token operator"><</span> s<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> c1 <span class="token operator">=</span> <span class="token number">2</span><span class="token operator">*</span>p<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">;</span> <span class="token keyword">int</span> c2 <span class="token operator">=</span> <span class="token number">2</span><span class="token operator">*</span>p<span class="token operator">+</span><span class="token number">2</span><span class="token punctuation">;</span> <span class="token keyword">int</span> c <span class="token operator">=</span> <span class="token punctuation">(</span>c2<span class="token operator"><</span>s <span class="token operator">&&</span> nums<span class="token punctuation">[</span>c2<span class="token punctuation">]</span><span class="token operator">></span>nums<span class="token punctuation">[</span>c1<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">?</span> c2 <span class="token operator">:</span> c1<span class="token punctuation">;</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>c<span class="token punctuation">]</span> <span class="token operator">></span> nums<span class="token punctuation">[</span>p<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span>c<span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>p<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">else</span> <span class="token keyword">break</span><span class="token punctuation">;</span> p <span class="token operator">=</span> c<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span> <span class="token function">heapSort</span><span class="token punctuation">(</span>vector<span class="token operator"><</span><span class="token keyword">int</span><span class="token operator">></span><span class="token operator">&</span> nums<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">int</span> n <span class="token operator">=</span> nums<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> n<span class="token operator">/</span><span class="token number">2</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span> i <span class="token operator">>=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token operator">--</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">adjust</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> n<span class="token number">-1</span><span class="token punctuation">;</span> i <span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token operator">--</span>i<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">swap</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span> nums<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token function">adjust</span><span class="token punctuation">(</span>nums<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">return</span> nums<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token punctuation">;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>]]></content>
<categories>
<category> 编程算法 </category>
</categories>
<tags>
<tag> leetcode </tag>
<tag> 算法 </tag>
</tags>
</entry>
</search>