Add files using upload-large-folder tool
Browse files- home/.vscode-server/data/User/History/-ae16f50/BxQg.jsonl +331 -0
- home/.vscode-server/data/User/History/-ae16f50/entries.json +1 -0
- home/.vscode-server/data/User/History/10fe5520/9IQR.hpp +21 -0
- home/.vscode-server/data/User/History/10fe5520/entries.json +1 -0
- home/.vscode-server/data/User/History/10fe5520/zt7s.hpp +22 -0
- home/.vscode-server/data/User/History/179d5b64/2r2j.hpp +124 -0
- home/.vscode-server/data/User/History/179d5b64/3dDe.hpp +127 -0
- home/.vscode-server/data/User/History/179d5b64/FICo.hpp +171 -0
- home/.vscode-server/data/User/History/179d5b64/YVXf.hpp +110 -0
- home/.vscode-server/data/User/History/179d5b64/omgD.hpp +107 -0
- home/.vscode-server/data/User/History/179d5b64/wK2H.hpp +125 -0
- home/.vscode-server/data/User/History/37fcd955/05vn.py +75 -0
- home/.vscode-server/data/User/History/37fcd955/3xeB.py +75 -0
- home/.vscode-server/data/User/History/37fcd955/V4pm.py +88 -0
- home/.vscode-server/data/User/History/37fcd955/XcDC.py +90 -0
- home/.vscode-server/data/User/History/37fcd955/ZpQF.py +123 -0
- home/.vscode-server/data/User/History/37fcd955/entries.json +1 -0
- home/.vscode-server/data/User/History/37fcd955/iinr.py +89 -0
- home/.vscode-server/data/User/History/37fcd955/vyXH.py +91 -0
- home/.vscode-server/data/User/History/37fcd955/xK08.py +73 -0
home/.vscode-server/data/User/History/-ae16f50/BxQg.jsonl
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"text": "山上是安倍的通心粉。"}
|
| 2 |
+
{"text": "夫人不想要生孩子,食人族酋长只好把小孩蒸熟再端给她。"}
|
| 3 |
+
{"text": "小孩怎么住院了?爹打损伤。"}
|
| 4 |
+
{"text": "腌制河南人就可以得到海南人。"}
|
| 5 |
+
{"text": "残疾运动员的教练会不会看着普通运动员想:要是他残疾就好了。"}
|
| 6 |
+
{"text": "“大黄蜂何在!”擎天柱大喝一声。;“核载五人。”大黄蜂回答。"}
|
| 7 |
+
{"text": "小明假装发烧成功请假,又叫体温计。"}
|
| 8 |
+
{"text": "由于第三者插足,原来的洗脚盆明显不够大了。"}
|
| 9 |
+
{"text": "和老婆结婚三年了还是不给我看内脏这正常吗?"}
|
| 10 |
+
{"text": "作为一个成人,我也算半个成功人士。"}
|
| 11 |
+
{"text": "白天累了一天,我熬了一碗夜给白天补补。"}
|
| 12 |
+
{"text": "“听说了吗,你成了年度十大优秀聋哑人了。”;“……”;“你为什么不说话?”"}
|
| 13 |
+
{"text": "牛郎织女暴饮暴食,制造了一大批扁鹊。"}
|
| 14 |
+
{"text": "“工作被nature接收了!”小明把论文撕碎扔进海里。"}
|
| 15 |
+
{"text": "建议大家别活太老,越老越容易死。"}
|
| 16 |
+
{"text": "抱歉以尸体的形式参加这场葬礼。"}
|
| 17 |
+
{"text": "变态杀手将杀害数人碎尸再拼起来,重组家庭的悲剧何时能停止。"}
|
| 18 |
+
{"text": "中国人:把东西烧给祖宗;欧洲人:烧女巫;欧洲人祖宗:哎哟我操"}
|
| 19 |
+
{"text": "毕业照也叫师生人面像。"}
|
| 20 |
+
{"text": "征服日本让我国多块好省。"}
|
| 21 |
+
{"text": "把肉从烤串上拿下来,发现肉上都是小孔,是不是老板注射东西了?"}
|
| 22 |
+
{"text": "大师说我有业障原来是有就业障碍。"}
|
| 23 |
+
{"text": "比祖宗功绩算是一种牌位赛。"}
|
| 24 |
+
{"text": "“先帝称之曰能。”诸葛亮指着一头熊,嘲笑阿斗的父亲是文盲。"}
|
| 25 |
+
{"text": "环保组织抗议杀手组织用人工合成毒药不健康要求换成天然毒药。"}
|
| 26 |
+
{"text": "“好准啊,算命先生说你是我命中的人。”女子一枪就击毙了前来相亲的男子。"}
|
| 27 |
+
{"text": "为什么那些多米诺骨牌的视频都这么火啊,不都明显摆拍的吗?"}
|
| 28 |
+
{"text": "“好大儿!”北京人在床上夸赞对象。"}
|
| 29 |
+
{"text": "苟子有言:哥们你打错字了。"}
|
| 30 |
+
{"text": "“大家都说成年之后要学会自己做主”,小明给医生解释自己手掌的钉子。"}
|
| 31 |
+
{"text": "黑夜给了我黑色的奴隶,我却用他去采摘棉花。"}
|
| 32 |
+
{"text": "“三秒内捡起来还能吃”赵云慌忙捡起阿斗。"}
|
| 33 |
+
{"text": "仓颉造的最后一个字是反。"}
|
| 34 |
+
{"text": "辛弃疾花了好阵子功夫,结果写出的竟是破阵子。"}
|
| 35 |
+
{"text": "即将推理的王警官突然变卦,将凶器变成了吉器。"}
|
| 36 |
+
{"text": "当你在家角落发现零碎的钱后,其实在暗地里你家已经繁殖了一堆的钱。"}
|
| 37 |
+
{"text": "为什么不能把小偷变成合法职业?然后再要求考资格证,故意不让过不就天下无贼了吗?"}
|
| 38 |
+
{"text": "原子弹下无冤魂,广岛长崎连年被评为日本0闹鬼事件城市。"}
|
| 39 |
+
{"text": "食人族大饥荒,厨师实在受不了,跳进了锅里:“横扫饥饿,做回自己!”"}
|
| 40 |
+
{"text": "“过年,串亲戚去了。”食人族说道。"}
|
| 41 |
+
{"text": "学校出现多起跳楼事件,校长称已申请吉尼斯世界纪录。"}
|
| 42 |
+
{"text": "牛顿坐在股票树下沉思:为什么股市总是往下跌而不是往上涨呢?"}
|
| 43 |
+
{"text": "我觉得说脏话不好,所以都夸别人生儿子多屁眼。"}
|
| 44 |
+
{"text": "学音乐的人怎么那么多管弦事。"}
|
| 45 |
+
{"text": "高薪招聘实习生,不要工资者优先。"}
|
| 46 |
+
{"text": "读万卷书不如读十万卷书。"}
|
| 47 |
+
{"text": "我靠,银行卡密码还能重复的吗,太不安全了。"}
|
| 48 |
+
{"text": "闰土指着周树人对儿子说,这个老爷就是迅啦。"}
|
| 49 |
+
{"text": "品级数字越小官越大,臣已经是一品还要向皇上行礼,万岁爷您真是没品的东西。"}
|
| 50 |
+
{"text": "爱吃屎的小明对着别人屁股嘬,因为纸上得来终觉浅。"}
|
| 51 |
+
{"text": "一部分人类有胎记会不会是上帝在用标志重捕法统计人类。"}
|
| 52 |
+
{"text": "据报道,本省今年考公人数再创新高——鲁讯"}
|
| 53 |
+
{"text": "朱元璋身为皇上,为什么要发动农民起义?"}
|
| 54 |
+
{"text": "你说你的字典里根本没有做不到这三个字,那你的字典里也就根本没有做到这两个字。"}
|
| 55 |
+
{"text": "诸葛亮七擒孟获,成功勒索孟母三千。"}
|
| 56 |
+
{"text": "指虎是代表订婚还是已婚?"}
|
| 57 |
+
{"text": "小震不用跑,大震跑不了,中震可以跑,所以1949年跑掉了。"}
|
| 58 |
+
{"text": "魏军看到木牛流马后感叹真牛逼,司马懿不解:牛逼在哪儿?"}
|
| 59 |
+
{"text": "孔老夫子,您的鼻毛长出来了。;哈哈,大人真是明察丘毫。"}
|
| 60 |
+
{"text": "“早上俩条腿,中午四条腿,晚上三条腿。”食人族抱怨餐食太单调了。"}
|
| 61 |
+
{"text": "莫比乌斯环打官司败诉了,法官认为他说的都是一面之词。"}
|
| 62 |
+
{"text": "“端午节是纪念招原的”我屈打成招了。"}
|
| 63 |
+
{"text": "不孕不育的男��是不是可以应聘byt,前边有插头后边有接口,完美byt啊。"}
|
| 64 |
+
{"text": "吧主是不是同性恋啊,为什么对雷同内容敌意这么大?"}
|
| 65 |
+
{"text": "李靖看着夫人怀胎三年竟然生出一个球体,不禁叹曰:“人生几何!”"}
|
| 66 |
+
{"text": "白雪公主的结局可以概括为“亲君子,远小人”。"}
|
| 67 |
+
{"text": "单人旁的字大多与人相关,俺也一样。"}
|
| 68 |
+
{"text": "同样和男生恋爱,为什么女生不会被当成gay?"}
|
| 69 |
+
{"text": "只要人人都大度一点,世界就会变成巨大的钝角。"}
|
| 70 |
+
{"text": "震惊!一夜之间,地球上所有人的生命都少了几个小时!"}
|
| 71 |
+
{"text": "听说父母怕影响考试情绪要高考后才离婚,于是我复读了20多年。"}
|
| 72 |
+
{"text": "普通人想要更上一层楼就得多摁一层电梯。"}
|
| 73 |
+
{"text": "韩国发生严重车祸,撞得西巴烂了。"}
|
| 74 |
+
{"text": "“死去活来。”殡仪馆的工作人员解释什么时候有活儿干。"}
|
| 75 |
+
{"text": "字母艺术也可以叫smart。"}
|
| 76 |
+
{"text": "我去世的时候你一定要来当伴郎哦。"}
|
| 77 |
+
{"text": "乌鲁木齐看着平平无奇,其实藏着两个山东!"}
|
| 78 |
+
{"text": "羽翼丰满,刘备看了二弟三弟洗澡之后说。"}
|
| 79 |
+
{"text": "枪决时被打了三枪,是不是行刑人暗示我半夜三点去找他?"}
|
| 80 |
+
{"text": "大量囤积应届生冷冻起来,等未来劳动力短缺了,再放出来高价出售。"}
|
| 81 |
+
{"text": "我发现大部分吧友的父母都不在弱智吧,这说明弱智是一种隐性基因。"}
|
| 82 |
+
{"text": "据悉一圈外男性将于近日结婚,对象为一圈外女性。"}
|
| 83 |
+
{"text": "哎哟领导您亲自来劫机啊!"}
|
| 84 |
+
{"text": "我喜欢在楼梯间跟别人吵架,因为无论结果怎样,至少大家都有台阶可以下。"}
|
| 85 |
+
{"text": "世界上最甜的瓜种植于1945年的日本,因为昼夜温差大,有利于糖分积累。"}
|
| 86 |
+
{"text": "腔肠动物说话跟放屁一样。"}
|
| 87 |
+
{"text": "“C圈的各位大大都好还原”,学习了碳元素同素异形体的小明感慨道。"}
|
| 88 |
+
{"text": "为什么我天天炒菜也没见菜价上涨?"}
|
| 89 |
+
{"text": "凶手只说了一句话就让被害人窒息:“这都是为了你好。”"}
|
| 90 |
+
{"text": "升学宴上,亲朋都来沾沾喜气,我沾沾自喜。"}
|
| 91 |
+
{"text": "汽车人犯错了它妈妈会揪它的后视镜吗?"}
|
| 92 |
+
{"text": "赈灾施粥,雪中送碳水。"}
|
| 93 |
+
{"text": "毕业那年为了杀掉自己想杀的人哭着杀了全班。"}
|
| 94 |
+
{"text": "“这下忍不住了”村长派人去收拾佐助故居时说道。"}
|
| 95 |
+
{"text": "美国现状:;禁止黑人打白条;允许白条打黑人"}
|
| 96 |
+
{"text": "恐同家长互相祝福生儿子"}
|
| 97 |
+
{"text": "西西弗斯也是一种王安石"}
|
| 98 |
+
{"text": "冰岛科学家首次在境内发现蚊子,与此同时蚊子科学家首次在境外发现冰岛。"}
|
| 99 |
+
{"text": "前男友结婚,我随两百冥币,这就是我的恐怖份子。"}
|
| 100 |
+
{"text": "求求你饶我一命我家上有黄鹂深树鸣。"}
|
| 101 |
+
{"text": "《英雄》讲刺客用剑刺杀领导人的故事,而安倍晋三看过枪版。"}
|
| 102 |
+
{"text": "苏轼和儿子打篮球——东坡肘子"}
|
| 103 |
+
{"text": "有只鸟展翅时经常打到其他鸟,其他鸟纷纷指责它没有张翼德。"}
|
| 104 |
+
{"text": "眼眶,目的地。"}
|
| 105 |
+
{"text": "你们不要再造鸡蛋黄谣了,蛋黄和蛋壳之间是清白的。"}
|
| 106 |
+
{"text": "体检时大夫问我有丙肝吗?笑死,现在不给医生带吃的就不能体检了吗?"}
|
| 107 |
+
{"text": "为什么要看中医?我又不是看不起,我要看大医和超大医。"}
|
| 108 |
+
{"text": "交了个土耳其男朋友,试了一晚上我都没能握住他的寄吧。"}
|
| 109 |
+
{"text": "魔教弟子斩杀一个道士,没想到连升三级,原来是经验老道。"}
|
| 110 |
+
{"text": "山东HR招人喜欢。"}
|
| 111 |
+
{"text": "唯物主义者点外卖会用神券吗?"}
|
| 112 |
+
{"text": "向医生确认了100遍后,小明终于确信自己没有强迫症。"}
|
| 113 |
+
{"text": "乐色,短视频的三种类型。"}
|
| 114 |
+
{"text": "入编很难吗?一摸电线不就接入国家电网了。"}
|
| 115 |
+
{"text": "校旗升到一半升旗绳坏了,校长只好暴毙以符合校规。"}
|
| 116 |
+
{"text": "东风不与周郎便,铜雀春深锁二乔。;缩写:英雄难过,美人关。"}
|
| 117 |
+
{"text": "世贸大厦当机立断。"}
|
| 118 |
+
{"text": "王高飞吃三鹿——来头不小"}
|
| 119 |
+
{"text": "以前我从不拉黑人,后来经济形势不好,就不拒载了。"}
|
| 120 |
+
{"text": "在成都,我的屁眼是我的优势,且我的优势还一直在扩大。"}
|
| 121 |
+
{"text": "如果我白天内卷晚上熬夜,那我其实是窗帘。"}
|
| 122 |
+
{"text": "考古专家挖出宋朝古墓,遗憾的是墓主已经因抢救无效死亡。"}
|
| 123 |
+
{"text": "冷知识:意大利同时比梵蒂冈更靠东靠西靠南靠北。"}
|
| 124 |
+
{"text": "鼓手拼命把乐队的大家拧成一股绳,被以故意杀人和侮辱尸体罪逮捕。"}
|
| 125 |
+
{"text": "环,坏得一笔。"}
|
| 126 |
+
{"text": "海鲜过敏竟成绝症?小鲨鱼父母痛诉无良医生。"}
|
| 127 |
+
{"text": "谁把我在停尸房的尸体开走了?"}
|
| 128 |
+
{"text": "“这下好了”往往是指这下坏了。"}
|
| 129 |
+
{"text": "“此子���非池中之物!”水族馆馆长指着水池里莫名出现的小朋友说道。"}
|
| 130 |
+
{"text": "我有一个3L和4L的杯子,通过勾股定理就能得到5L的水。"}
|
| 131 |
+
{"text": "我把公司行政打了,竟然是行政拘留。"}
|
| 132 |
+
{"text": "太阳让那么多行星围着它转,应该称得上是海王星。"}
|
| 133 |
+
{"text": "怎样区分大写的L和小写的i?"}
|
| 134 |
+
{"text": "王警官看着倒地的相声演员疑惑道:“这是现挂吗?”"}
|
| 135 |
+
{"text": "小象一夜未归,大象妈妈开始想象。"}
|
| 136 |
+
{"text": "“对不起,但是只有死人才能保守秘密。” 我向每晚听我唠叨的太平间尸体们道歉。"}
|
| 137 |
+
{"text": "群里有当皇帝的朋友注意了,结婚前记得找律师把天下注册成婚前财产。"}
|
| 138 |
+
{"text": "师傅你怎么请神上身的?;神的下半身没通过审核。"}
|
| 139 |
+
{"text": "我光着身子站在街上被围观,他人笑我太疯颠,我笑他人看不穿。"}
|
| 140 |
+
{"text": "大男孩到日本旅游,感叹道:“小时候还爆过你呢。”"}
|
| 141 |
+
{"text": "湖北,省流:长江。"}
|
| 142 |
+
{"text": "一个考试高分技巧:填写正确答案。"}
|
| 143 |
+
{"text": "面对着炸弹威胁,王警官沉着冷静,说:“要不起。”"}
|
| 144 |
+
{"text": "里根号不就是 厘 么?"}
|
| 145 |
+
{"text": "小知识:离开过自己视线的氰化物不要随便吃。"}
|
| 146 |
+
{"text": "小明是个性张扬的人,我就相反,我是个性压抑的人。"}
|
| 147 |
+
{"text": "为什么鲁迅要说“横眉冷对千夫指”?我看这两个词也不对仗啊。"}
|
| 148 |
+
{"text": "扫黄,报复性消费。"}
|
| 149 |
+
{"text": "(有难)¹=(支援)⁸"}
|
| 150 |
+
{"text": "“你当我傻吗!你已经第十次用爸爸去世的理由请假了!”猫猫班主任怒骂小猫。"}
|
| 151 |
+
{"text": "为什么飞机场有打火机捐献箱,是不是捐给穷困孩子吸烟用的?"}
|
| 152 |
+
{"text": "路易十六被送上断头台时会说什么?资本你赢了。"}
|
| 153 |
+
{"text": "我见到喜欢的人:人生若只如初见。;我见到讨厌的人:见人若只如初生。"}
|
| 154 |
+
{"text": "好事不出门,坏事传千里,你儿子整天不出门,这是个好事啊。"}
|
| 155 |
+
{"text": "“你把我当日本人整!”我拿着斋藤飞鸟的照片对整容医生说。"}
|
| 156 |
+
{"text": "清华北大明明是国内第一的名校,为什么从来没有出过高考状元。"}
|
| 157 |
+
{"text": "厕所里不是本来就有屎吗?大家为什么要自己带?"}
|
| 158 |
+
{"text": "琥珀没有礼貌,因为它是树脂滴下形成的。"}
|
| 159 |
+
{"text": "吾有一计可解人口老龄化,凡生育孩子的子女高考加二十分。"}
|
| 160 |
+
{"text": "麦当劳每天卖这么多派是不是也是一种派出所?"}
|
| 161 |
+
{"text": "苍蝇的同事结婚,问妻子该随什么礼。;“随便吧。”"}
|
| 162 |
+
{"text": "老天爷赏善罚恶,总是朝恶人发怒,朝善人吃牛肉火锅。"}
|
| 163 |
+
{"text": "女人守住贞洁被称为贞洁烈女,男人守住贞洁应该称为门洁烈夫。"}
|
| 164 |
+
{"text": "把曹植装进棺材需要几步?八步"}
|
| 165 |
+
{"text": "“兄弟,你好香。”;“你也是。”;这段对话使用了互闻的手法。"}
|
| 166 |
+
{"text": "健康状态不好的人身体这几处会说话,首先就是嘴巴。"}
|
| 167 |
+
{"text": "你感冒了怎么不吃药,成天靠你那个B细胞。"}
|
| 168 |
+
{"text": "夕阳下我跳进大海,浪漫过头了。"}
|
| 169 |
+
{"text": "“太原神了!”小明到山西旅游后赞叹道。"}
|
| 170 |
+
{"text": "山东女程序员编的软件能放在电脑桌面上吗?"}
|
| 171 |
+
{"text": "论文导师问我写这段是什么意思,我说不可以解释笑话。"}
|
| 172 |
+
{"text": "看到鲁提辖三拳打死镇关西,读者惊呼:“此是古**!”"}
|
| 173 |
+
{"text": "中国牛排第二,这么说不违反广告法。那第一呢?第一是老鼠啊。"}
|
| 174 |
+
{"text": "“我最大的心愿就是倾听人民群众的呼声。”夜间入室盗窃的小偷说道。"}
|
| 175 |
+
{"text": "“早”我对蝙蝠夫妇说。;“苗”他俩回应道。"}
|
| 176 |
+
{"text": "既然丁克的意思是一辈子都不要小孩,所以丁克是一种谥号,只有死后才能追封。"}
|
| 177 |
+
{"text": "曹丕称帝,把皇帝赶到船上看看船下沉了多少。"}
|
| 178 |
+
{"text": "为了证明自己比皇帝厉害,魏忠贤下令编纂《皇帝不及太监集》。"}
|
| 179 |
+
{"text": "我比你大一届,也算是你的先考。"}
|
| 180 |
+
{"text": "人工增雨是人工降雨。"}
|
| 181 |
+
{"text": "云就是喜欢跟风。"}
|
| 182 |
+
{"text": "怎么还没到地库?你这个忘摁负一的家伙!"}
|
| 183 |
+
{"text": "养老院夏令营:别让你家老头输在终点线。"}
|
| 184 |
+
{"text": "我在评论区发几把,结果几把被吧务吞了。"}
|
| 185 |
+
{"text": "只有凶手知道犯罪手法和藏尸地点,所以只要让凶手当警长就能百分百破案了。"}
|
| 186 |
+
{"text": "德国孩子做ct,发现身体里有父母埋下的油纸包装的备用器官。"}
|
| 187 |
+
{"text": "从行政区划和商品价格两个方面来说,超市就是省。"}
|
| 188 |
+
{"text": "见到有人溺水,我向水里面倒浓硫酸,利用吸水性把水吸走救人。"}
|
| 189 |
+
{"text": "小三一脚踹开酒店房门发现夫妻俩在床上鬼混。"}
|
| 190 |
+
{"text": "蚊子这么小都进不去蚊帐,你们是怎么进去的?"}
|
| 191 |
+
{"text": "现在兵来将挡,那将来怎么办?"}
|
| 192 |
+
{"text": "古代天子只用四匹马,凭什么商鞅能用五匹?"}
|
| 193 |
+
{"text": "冷知识:从商朝到战国仅仅经过两周。"}
|
| 194 |
+
{"text": "如果物理学真的不存在了,那高考分数就会变成650分。"}
|
| 195 |
+
{"text": "王警官到达犯罪现场勘察过后宣布这是1室2厅。"}
|
| 196 |
+
{"text": "子在厂里曰:“厚。”"}
|
| 197 |
+
{"text": "火车那么吵,卧轨的人是怎么睡得着的?"}
|
| 198 |
+
{"text": "绑匪要求支付宝转账一千万才释放人质,经过谈判,终于同意通过微信转账。"}
|
| 199 |
+
{"text": "䪭,念ruǎn,只有一个读音,是一个多音字。"}
|
| 200 |
+
{"text": "给狗狗喂药总是被吐出来怎么办?专家建议:用象牙把药包起来。"}
|
| 201 |
+
{"text": "包容是最伟大的品质,不接受任何反驳。"}
|
| 202 |
+
{"text": "很多算命摊子上为什么会写着“不准不收费”?强制收费吗?"}
|
| 203 |
+
{"text": "牛是前半生,土是后半生。"}
|
| 204 |
+
{"text": "“我怎么没马眼啊?”瞎几把说。"}
|
| 205 |
+
{"text": "强势老婆要求儿子性别随她我该怎么办?"}
|
| 206 |
+
{"text": "你已登上瞎子排行榜前十名,快来看看吧!"}
|
| 207 |
+
{"text": "如果让全世界所有的麦当劳员工手拉手站成一行,那你就只能自己动手做麻辣鸡腿堡了。"}
|
| 208 |
+
{"text": "项羽困死在垓下的时候为什么不睡觉?"}
|
| 209 |
+
{"text": "亲亲很抱歉手术失败了,这边给您申请补偿5元您看可以吗?"}
|
| 210 |
+
{"text": "六个字概括上班路:出发点是好的。"}
|
| 211 |
+
{"text": "水能导电,为什么不直接用长江输电?"}
|
| 212 |
+
{"text": "我不小心把碗打碎了,被盘问道:“你把我兄弟怎么了?”"}
|
| 213 |
+
{"text": "接下来是本次葬礼的扔捧花环节。"}
|
| 214 |
+
{"text": "王警官在案发现场仔细调查了四周环境,荣获警局二月最佳全勤奖。"}
|
| 215 |
+
{"text": "又不缺胳膊少腿的,路易十六怎么不去上班?"}
|
| 216 |
+
{"text": "写“回”字,不小心把里边那个口写外边了。"}
|
| 217 |
+
{"text": "斩首的时候刽子手没按规定操作导致犯人死亡。"}
|
| 218 |
+
{"text": "十万块钱是什么概念呢?我不吃不喝的话,一个月才三十天。"}
|
| 219 |
+
{"text": "燕窝那么贵,燕子是怎么挣出那么多钱的?"}
|
| 220 |
+
{"text": "公司冰箱有股尸臭,同事纷纷否认称不是自己的尸体。"}
|
| 221 |
+
{"text": "警惕:吃饱后自杀可能会要了你的命!"}
|
| 222 |
+
{"text": "都说光阴似箭,我这几年确实也过得像矢一样。"}
|
| 223 |
+
{"text": "“如果被绑架了你就眨眨眼!”,人质一边点头一边眨眼被贷款了20w。"}
|
| 224 |
+
{"text": "去接亲的新郎被堵在门口,连答五十道题之后才发现误入数学补习班。"}
|
| 225 |
+
{"text": "小明对老师说自己的目标是当红巨星,不料被识破太阳的身份。"}
|
| 226 |
+
{"text": "贞子征婚,要求男方心里有鬼。"}
|
| 227 |
+
{"text": "葬礼这么严肃的地方,照片里的人还好意思笑。"}
|
| 228 |
+
{"text": "涂了剧毒的刀子是致命的,消过毒的刀子怎么也会捅死人?"}
|
| 229 |
+
{"text": "地球上70%的区域都是水,所以人一出生就被溺死的几率也是70%。"}
|
| 230 |
+
{"text": "老板说:“我就是规矩!”;小明把老板杀了,说道:“规矩是死的,人是活的。”"}
|
| 231 |
+
{"text": "“放假的人多轻松”小明抱怨奶奶让他在田里吓鸟。"}
|
| 232 |
+
{"text": "亲爱的游客们,现在我们踩着的这个,就叫阔刀地雷。"}
|
| 233 |
+
{"text": "别的理财方法弱爆了,我教你一招,开春把所有的钱买一大块冰,年化百分之百。"}
|
| 234 |
+
{"text": "领导半个月没从办公室出来,原来是偷偷搞腐败。"}
|
| 235 |
+
{"text": "入殓师:干我们这行最忌讳爱上客人。"}
|
| 236 |
+
{"text": "食人族厨师发现徒弟把食材一锅煮了,大怒道:“好人坏人都让你做了。”"}
|
| 237 |
+
{"text": "佛教认为,一切行为都是为了制造业。"}
|
| 238 |
+
{"text": "王警官展示自己的新发现后,同事吐槽他不仅发型难看,字也打错了。"}
|
| 239 |
+
{"text": "过安检总是让我喝一口,万一里面有毒呢?"}
|
| 240 |
+
{"text": "真的有人喜欢被诛九族吗,一想到要见那么多不熟的亲戚我就觉得好尴尬。"}
|
| 241 |
+
{"text": "咱俩还没谈恋爱呢你就已经这么好了,要是确立关系了,你不得好死。"}
|
| 242 |
+
{"text": "小明死后发现自己生死簿上的寿命还有30年,阎王解释说这是公摊寿命。"}
|
| 243 |
+
{"text": "成步堂一拍桌子把法庭跳转到淘宝。"}
|
| 244 |
+
{"text": "好人有好报,我是庸人,可以给我一个庸报吗?"}
|
| 245 |
+
{"text": "第一次看见柠檬不知道这是什么水果,上海的朋友贴心地和我说是香雾柠,他真好。"}
|
| 246 |
+
{"text": "我永远叫不醒一个装睡的人,但王警官说户口本写不下那么长。"}
|
| 247 |
+
{"text": "野外迷路了怎么办?观察身边,哪里出现东北虎,哪里就是东北。"}
|
| 248 |
+
{"text": "“听说你摔倒的姿势和别人不一样,能摔给我看看吗?”;我:ok"}
|
| 249 |
+
{"text": "倡导居家办公,杀手只好在家给目标P遗照。"}
|
| 250 |
+
{"text": "我发现有些人是真的很怕晒黑,下雨天根本就没有太阳还要打伞。"}
|
| 251 |
+
{"text": "机场这种平平无奇的地方,却最��易出现转机。"}
|
| 252 |
+
{"text": "当你发现每当自己一拧把,你的朋友就会离开,注意你的朋友可能是电动车。"}
|
| 253 |
+
{"text": "当我们迷失方向时可以随机打死一个人,看他驾鹤西去的方向就知道哪边是西边了。"}
|
| 254 |
+
{"text": "朱熹的母亲荣获生理学家称号。"}
|
| 255 |
+
{"text": "周瑜看见诸葛亮准备的草船后恍然大悟:“你是来拉矢的吧!”"}
|
| 256 |
+
{"text": "地府爷爷收到孙子烧来纸钱后惨遭未成年人退款。"}
|
| 257 |
+
{"text": "小明刚入职就感叹道:“男同事真多”,已经有五个男同来和他攀谈了。"}
|
| 258 |
+
{"text": "上帝说:“ ”;后来人们才明白,那次他说的是要有文字。"}
|
| 259 |
+
{"text": "针对我方派出的谈判大师对方派出了一名聋子。"}
|
| 260 |
+
{"text": "我发现了几乎所有比赛的黑幕,总决赛他们总是让亚军去打冠军,这样肯定要输呀。"}
|
| 261 |
+
{"text": "王警官追了犯人两天后发现自己上班没打卡。"}
|
| 262 |
+
{"text": "我爹虽然生了我,但并不代表他是我妈。"}
|
| 263 |
+
{"text": "也不知为什么,最近几年一直感觉自己年龄越来越大了。"}
|
| 264 |
+
{"text": "男性的盆骨比女性的窄,是不是说明男性比女性更容易难产?"}
|
| 265 |
+
{"text": "小小年纪不学好居然在身体打洞?!亚裔家长在美国校园枪击案现场骂孩子。"}
|
| 266 |
+
{"text": "塞翁是马,不信你看马在十二生肖里排第几。"}
|
| 267 |
+
{"text": "墓地滞销,老板:人都死哪去了?"}
|
| 268 |
+
{"text": "车上有人是不能开违停罚单的 交警看着后备箱的尸体失望地走开。"}
|
| 269 |
+
{"text": "“消防的问题都可以来问我!”消防通道。"}
|
| 270 |
+
{"text": "未成年人不能喝酒,为什么代驾公司不雇未成年人开车呢?"}
|
| 271 |
+
{"text": "直到小孩上了清华我才知道原来我家小孩是别人家的孩子。"}
|
| 272 |
+
{"text": "感觉飞机好危险,在所有交通工具里,飞机发生空难的概率是最高的。"}
|
| 273 |
+
{"text": "食人族说“打包”,随后提心吊胆地走了。"}
|
| 274 |
+
{"text": "俄罗斯雪人去中国化了。"}
|
| 275 |
+
{"text": "《斗罗大陆》推出繁中版《斗羅港澳臺》。"}
|
| 276 |
+
{"text": "“你根本就没把他放在眼里!”医生批评错误使用痔疮膏的患者。"}
|
| 277 |
+
{"text": "在与凶手的追逐中,王警官不甘示弱,最终将凶手远远甩在身后。"}
|
| 278 |
+
{"text": "冷知识,一天吃一个医生比一天吃一个苹果更能让医生远离你。"}
|
| 279 |
+
{"text": "小明爷爷生病了,难受得一直叫唤,小明问:爸爸的爸爸叫什么?"}
|
| 280 |
+
{"text": "高考考场出现无头尸体,众人纷纷感叹这么大的考试也会忘记带考试工具入场。"}
|
| 281 |
+
{"text": "孟德尔经过不断观察,觉得豌豆还是应该种在向日葵后面。"}
|
| 282 |
+
{"text": "金箍棒离开悟空,大小便不能自理。"}
|
| 283 |
+
{"text": "宋江对皇帝说:你不打算招安全员吗?"}
|
| 284 |
+
{"text": "独家报道海难幸存者自述:咕噜咕噜你先咕噜咕噜把我咕噜捞上咕噜……"}
|
| 285 |
+
{"text": "最大的敌人是自己,太好了,我从来没见过这么弱的对手。"}
|
| 286 |
+
{"text": "男子冲进灵堂大喊:“我不同意这门丧事。”并抢走了尸体。"}
|
| 287 |
+
{"text": "资本主义的腐朽就在于宁愿把卖不出去的黑人倒进海里都不愿意送出去。"}
|
| 288 |
+
{"text": "一个人在风光无限的时候反而要特别注意,这种情况下非常适合发展风力发电和光伏发电!"}
|
| 289 |
+
{"text": "小明看完表演后没有付钱,白高兴了一场。"}
|
| 290 |
+
{"text": "烟头和烟屁股是一个东西,所以烟可能是腔肠动物。"}
|
| 291 |
+
{"text": "医生开方之后,王老汉从2型糖尿病变成了√2型糖尿病。"}
|
| 292 |
+
{"text": "我向老师求婚,结果老师要见我家长,我是不是成功了。"}
|
| 293 |
+
{"text": "康师傅表示,如果公司有一个员工跳楼公司名就反过来写。"}
|
| 294 |
+
{"text": "身份证下面的神秘数字里居然藏着我的生日,官方真是用心了。"}
|
| 295 |
+
{"text": "我小时候塑料鞋底过敏,后来和我爸分开住就好了。"}
|
| 296 |
+
{"text": "我根本没搜过,为什么搜索记录里有个“得了失忆症怎么办?”"}
|
| 297 |
+
{"text": "神说:要有空气。但是大家都听不到。"}
|
| 298 |
+
{"text": "两个细菌之间的位置,就是最常见的无菌环境。"}
|
| 299 |
+
{"text": "为什么在每次跳水比赛,运动员都会用很慢的速度跳第二遍?"}
|
| 300 |
+
{"text": "朱自清入关后,就不再是国姓了。"}
|
| 301 |
+
{"text": "考古队仔细拼接墓中骸骨,发现了大量人头马和马头人。"}
|
| 302 |
+
{"text": "俗话说一孕傻三年,我们只要让特朗普怀孕就能极大削弱美国实力。"}
|
| 303 |
+
{"text": "警局第二天才发现尸体,因为王警官认为警局第一天才是自己。"}
|
| 304 |
+
{"text": "某酒店被爆厕所卫生不达标,许多人纷纷后悔在该酒店厕所吃屎。"}
|
| 305 |
+
{"text": "有一道光穿过了屋子,屋里的人见状大惊。“爸,你怎么来了?”;咸丰问道。"}
|
| 306 |
+
{"text": "王警官得知蛋糕有毒后惊叹凶手的作案设计是用了点心的。"}
|
| 307 |
+
{"text": "“我的清白没了!”溥仪看到袁世凯复辟不禁感叹。"}
|
| 308 |
+
{"text": "正月诛九族死舅��。"}
|
| 309 |
+
{"text": "都说狗鼻子很灵,为什么没有供奉狗鼻子的庙?"}
|
| 310 |
+
{"text": "“明天公司团建,你不来可说不过去了!”;“不过去了。”"}
|
| 311 |
+
{"text": "生育率下降幼儿园减少,但大学生却遍地都是。幼儿园文凭含金量或超过本科。"}
|
| 312 |
+
{"text": "“不要拿你的爱好挑战别人的饭碗”,医生努力阻止患者把碗塞进屁股。"}
|
| 313 |
+
{"text": "“妈,我手机没电了。”;“玩手机玩的。”"}
|
| 314 |
+
{"text": "特朗普吐痰:了。"}
|
| 315 |
+
{"text": "王警官反复推敲,终于发现门是拉的。"}
|
| 316 |
+
{"text": "老王选择一名阿尔茨海默病患者的房屋进行盗窃,进屋后发现是自己家。"}
|
| 317 |
+
{"text": "我长这么大头一次听说可能是三鹿奶粉导致的。"}
|
| 318 |
+
{"text": "王警官在碎尸杀人狂家里搜出十袋少年团。"}
|
| 319 |
+
{"text": "警方公布碎尸案最新进展:已被翻拍成同名电影。"}
|
| 320 |
+
{"text": "不小心喝了大量的醋没关系,吞几根鱼刺进去就好了。"}
|
| 321 |
+
{"text": "人还是会害怕比自己位置高的人,上次我在楼顶把辅导员和校长吓的。"}
|
| 322 |
+
{"text": "货拉拉司机辞职信:讨厌装货。"}
|
| 323 |
+
{"text": "总觉老公眼睛一直在那女人身上,打开那人口袋果然发现了老公的眼睛。"}
|
| 324 |
+
{"text": "没注意小孩钻洗衣机里直接启动了怎么办他口袋里还有纸巾?"}
|
| 325 |
+
{"text": "饭堂阿姨生病了,午饭改上数学课。"}
|
| 326 |
+
{"text": "理发店是不是有辐射呀?我每次去都掉一堆头发。"}
|
| 327 |
+
{"text": "“考试时遇到不会的题直接跳,不要浪费太多时间。”正在考数学的小明一跃而下。"}
|
| 328 |
+
{"text": "海洋垃圾污染触目惊心,昨天在市场买的海鲜,每一个外面都套着塑料袋。"}
|
| 329 |
+
{"text": "所有人都只在乎我飞得高不高,没有人在乎那个肇事司机开得***有多快。"}
|
| 330 |
+
{"text": "地上最有营养的动物是大象,一头大象的蛋白质含量是一只鸡的2000倍。"}
|
| 331 |
+
{"text": "“太好了还有气!”王警官看着尸体手里的可乐高兴道。"}
|
home/.vscode-server/data/User/History/-ae16f50/entries.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":1,"resource":"vscode-remote://ssh-remote%2B10.220.5.132/home/zangyihe/markov/processed/intelless.jsonl","entries":[{"id":"BxQg.jsonl","timestamp":1772957450525},{"id":"usgO.jsonl","timestamp":1772957574427}]}
|
home/.vscode-server/data/User/History/10fe5520/9IQR.hpp
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include<cstdint>
|
| 2 |
+
#include<cstdlib>
|
| 3 |
+
#include "cache.hpp"
|
| 4 |
+
|
| 5 |
+
struct Move {
|
| 6 |
+
int type;
|
| 7 |
+
int rank;
|
| 8 |
+
int len;
|
| 9 |
+
Hand mask;
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
inline int get_cnt(Hand h, int r) { return (h >> (r << 2)) & 0xF; }
|
| 13 |
+
inline Hand make_mask(int r, int c) { return (Hand)c << (r << 2); }
|
| 14 |
+
|
| 15 |
+
inline size_t fast_hash(Hand a, Hand b, Hand c) {
|
| 16 |
+
uint64_t x = a ^ (b >> 7) ^ (c << 13);
|
| 17 |
+
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9ULL;
|
| 18 |
+
x = (x ^ (x >> 27)) * 0x94d049bb133111ebULL;
|
| 19 |
+
return (x ^ (x >> 31)) & CACHE_MASK;
|
| 20 |
+
}
|
| 21 |
+
|
home/.vscode-server/data/User/History/10fe5520/entries.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":1,"resource":"vscode-remote://ssh-remote%2B10.220.5.132/home/zangyihe/llds/utils/operates.hpp","entries":[{"id":"9IQR.hpp","timestamp":1772720816242},{"id":"zt7s.hpp","timestamp":1772721179451}]}
|
home/.vscode-server/data/User/History/10fe5520/zt7s.hpp
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include<cstdint>
|
| 3 |
+
#include<cstdlib>
|
| 4 |
+
#include "cache.hpp"
|
| 5 |
+
|
| 6 |
+
struct Move {
|
| 7 |
+
int type;
|
| 8 |
+
int rank;
|
| 9 |
+
int len;
|
| 10 |
+
Hand mask;
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
inline int get_cnt(Hand h, int r) { return (h >> (r << 2)) & 0xF; }
|
| 14 |
+
inline Hand make_mask(int r, int c) { return (Hand)c << (r << 2); }
|
| 15 |
+
|
| 16 |
+
inline size_t fast_hash(Hand a, Hand b, Hand c) {
|
| 17 |
+
uint64_t x = a ^ (b >> 7) ^ (c << 13);
|
| 18 |
+
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9ULL;
|
| 19 |
+
x = (x ^ (x >> 27)) * 0x94d049bb133111ebULL;
|
| 20 |
+
return (x ^ (x >> 31)) & CACHE_MASK;
|
| 21 |
+
}
|
| 22 |
+
|
home/.vscode-server/data/User/History/179d5b64/2r2j.hpp
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <vector>
|
| 2 |
+
#include <algorithm>
|
| 3 |
+
#include <atomic>
|
| 4 |
+
#include <string>
|
| 5 |
+
|
| 6 |
+
#include "operates.hpp"
|
| 7 |
+
#include "cache.hpp"
|
| 8 |
+
|
| 9 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 10 |
+
int count = 0;
|
| 11 |
+
int l_type = last ? last->type : 0;
|
| 12 |
+
int l_rank = last ? last->rank : -1;
|
| 13 |
+
|
| 14 |
+
for (int r = 0; r < 15; ++r) {
|
| 15 |
+
int cnt = get_cnt(hand, r);
|
| 16 |
+
if (cnt >= 1){
|
| 17 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 18 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 19 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 20 |
+
int l_len= last?last->len:5;
|
| 21 |
+
Hand m = make_mask(r,1);
|
| 22 |
+
for(int i=r+1;i<12;++i){
|
| 23 |
+
if(get_cnt(hand,i)==0)break;
|
| 24 |
+
m|=make_mask(i,1);
|
| 25 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
if (cnt >= 2){
|
| 31 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 32 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 33 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 34 |
+
int l_len=last?last->len:3;
|
| 35 |
+
Hand m = make_mask(r,2);
|
| 36 |
+
for(int i=r+1;i<12;++i){
|
| 37 |
+
if(get_cnt(hand,i)<2)break;
|
| 38 |
+
m|=make_mask(i,2);
|
| 39 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 45 |
+
Hand base = make_mask(r, 3);
|
| 46 |
+
for (int s = 0; s < 15; ++s) {
|
| 47 |
+
if (s == r) continue;
|
| 48 |
+
int scnt = get_cnt(hand, s);
|
| 49 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 50 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 54 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 58 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 59 |
+
|
| 60 |
+
return count;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
bool can_win_fast(Hand mine, Hand opp, const Move* last) {
|
| 64 |
+
if (mine == 0) return true;
|
| 65 |
+
|
| 66 |
+
Hand last_m = last ? last->mask : 0;
|
| 67 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 68 |
+
auto& entry = global_cache[h];
|
| 69 |
+
|
| 70 |
+
entry.acquire();
|
| 71 |
+
int8_t res = entry.result.load(std::memory_order_relaxed);
|
| 72 |
+
if(res){
|
| 73 |
+
if (entry.mine.load(std::memory_order_relaxed) == mine &&
|
| 74 |
+
entry.opp.load(std::memory_order_relaxed) == opp &&
|
| 75 |
+
entry.last_mask.load(std::memory_order_relaxed) == last_m) {
|
| 76 |
+
return res == 1;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
entry.release();
|
| 80 |
+
|
| 81 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 82 |
+
Move moves[500];
|
| 83 |
+
int count = get_moves(mine, last, moves);
|
| 84 |
+
|
| 85 |
+
bool ans=false;
|
| 86 |
+
for (int i = 0; i < count; ++i) {
|
| 87 |
+
if (!can_win_fast(opp, mine - moves[i].mask, &moves[i])) {
|
| 88 |
+
ans=true;
|
| 89 |
+
break;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// pass
|
| 94 |
+
if (!ans && last && !can_win_fast(opp, mine, nullptr)) {
|
| 95 |
+
ans=true;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
entry.acquire();
|
| 99 |
+
entry.mine.store(mine, std::memory_order_relaxed);
|
| 100 |
+
entry.opp.store(opp, std::memory_order_relaxed);
|
| 101 |
+
entry.last_mask.store(last_m, std::memory_order_relaxed);
|
| 102 |
+
entry.result.store(ans ? 1 : 2, std::memory_order_relaxed);
|
| 103 |
+
return ans;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
void gen_all_combs(int n, int r, Hand cur, std::vector<Hand>& res) {
|
| 107 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 108 |
+
if (r == 15) return;
|
| 109 |
+
int limit = (r < 13) ? 4 : 1;
|
| 110 |
+
for (int i = 0; i <= std::min(n, limit); ++i)
|
| 111 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
std::string hand_to_string(Hand h) {
|
| 115 |
+
std::string res = "";
|
| 116 |
+
const char* ranks = "34567890JQKA2SB";
|
| 117 |
+
for (int r = 0; r < 15; ++r) {
|
| 118 |
+
int cnt = (h >> (r << 2)) & 0xF;
|
| 119 |
+
for (int i = 0; i < cnt; ++i) {
|
| 120 |
+
res += ranks[r];
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
return res;
|
| 124 |
+
}
|
home/.vscode-server/data/User/History/179d5b64/3dDe.hpp
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <vector>
|
| 3 |
+
#include <algorithm>
|
| 4 |
+
#include <atomic>
|
| 5 |
+
#include <string>
|
| 6 |
+
|
| 7 |
+
#include "operates.hpp"
|
| 8 |
+
#include "cache.hpp"
|
| 9 |
+
|
| 10 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 11 |
+
int count = 0;
|
| 12 |
+
int l_type = last ? last->type : 0;
|
| 13 |
+
int l_rank = last ? last->rank : -1;
|
| 14 |
+
|
| 15 |
+
for (int r = 0; r < 15; ++r) {
|
| 16 |
+
int cnt = get_cnt(hand, r);
|
| 17 |
+
if (cnt >= 1){
|
| 18 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 19 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 20 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 21 |
+
int l_len= last?last->len:5;
|
| 22 |
+
Hand m = make_mask(r,1);
|
| 23 |
+
for(int i=r+1;i<12;++i){
|
| 24 |
+
if(get_cnt(hand,i)==0)break;
|
| 25 |
+
m|=make_mask(i,1);
|
| 26 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (cnt >= 2){
|
| 32 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 33 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 34 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 35 |
+
int l_len=last?last->len:3;
|
| 36 |
+
Hand m = make_mask(r,2);
|
| 37 |
+
for(int i=r+1;i<12;++i){
|
| 38 |
+
if(get_cnt(hand,i)<2)break;
|
| 39 |
+
m|=make_mask(i,2);
|
| 40 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 46 |
+
Hand base = make_mask(r, 3);
|
| 47 |
+
for (int s = 0; s < 15; ++s) {
|
| 48 |
+
if (s == r) continue;
|
| 49 |
+
int scnt = get_cnt(hand, s);
|
| 50 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 51 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 55 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 59 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 60 |
+
|
| 61 |
+
return count;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// better than spinlock but still slower than overwritable scenario
|
| 65 |
+
bool can_win_noverite(Hand mine, Hand opp, const Move* last) {
|
| 66 |
+
if (mine == 0) return true;
|
| 67 |
+
|
| 68 |
+
Hand last_m = last ? last->mask : 0;
|
| 69 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 70 |
+
auto& entry = global_cache[h];
|
| 71 |
+
|
| 72 |
+
int8_t res = entry.result.load(std::memory_order_relaxed);
|
| 73 |
+
if(res){
|
| 74 |
+
if (entry.mine.load(std::memory_order_relaxed) == mine &&
|
| 75 |
+
entry.opp.load(std::memory_order_relaxed) == opp &&
|
| 76 |
+
entry.last_mask.load(std::memory_order_relaxed) == last_m) {
|
| 77 |
+
return res == 1;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 82 |
+
Move moves[500];
|
| 83 |
+
int count = get_moves(mine, last, moves);
|
| 84 |
+
|
| 85 |
+
bool ans=false;
|
| 86 |
+
for (int i = 0; i < count; ++i) {
|
| 87 |
+
if (!can_win_noverite(opp, mine - moves[i].mask, &moves[i])) {
|
| 88 |
+
ans=true;
|
| 89 |
+
break;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// pass
|
| 94 |
+
if (!ans && last && !can_win_noverite(opp, mine, nullptr)) {
|
| 95 |
+
ans=true;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if(!entry.result.load(std::memory_order_acquire)){
|
| 99 |
+
entry.mine.store(mine, std::memory_order_relaxed);
|
| 100 |
+
entry.opp.store(opp, std::memory_order_relaxed);
|
| 101 |
+
entry.last_mask.store(last_m, std::memory_order_relaxed);
|
| 102 |
+
entry.result.store(ans ? 1 : 2, std::memory_order_relaxed);
|
| 103 |
+
}
|
| 104 |
+
return ans;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
void gen_all_combs(int n, int r, Hand cur, std::vector<Hand>& res) {
|
| 108 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 109 |
+
if (r == 15) return;
|
| 110 |
+
int limit = (r < 13) ? 4 : 1;
|
| 111 |
+
for (int i = 0; i <= std::min(n, limit); ++i)
|
| 112 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
std::string hand_to_string(Hand h) {
|
| 116 |
+
std::string res = "";
|
| 117 |
+
const char* ranks = "34567890JQKA2SB";
|
| 118 |
+
for (int r = 0; r < 15; ++r) {
|
| 119 |
+
int cnt = (h >> (r << 2)) & 0xF;
|
| 120 |
+
for (int i = 0; i < cnt; ++i) {
|
| 121 |
+
res += ranks[r];
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
return res;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
void print_ans(){}
|
home/.vscode-server/data/User/History/179d5b64/FICo.hpp
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <vector>
|
| 3 |
+
#include <algorithm>
|
| 4 |
+
#include <atomic>
|
| 5 |
+
#include <string>
|
| 6 |
+
|
| 7 |
+
#include "operates.hpp"
|
| 8 |
+
#include "cache.hpp"
|
| 9 |
+
|
| 10 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 11 |
+
int count = 0;
|
| 12 |
+
int l_type = last ? last->type : 0;
|
| 13 |
+
int l_rank = last ? last->rank : -1;
|
| 14 |
+
|
| 15 |
+
for (int r = 0; r < 15; ++r) {
|
| 16 |
+
int cnt = get_cnt(hand, r);
|
| 17 |
+
if (cnt >= 1){
|
| 18 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 19 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 20 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 21 |
+
int l_len= last?last->len:5;
|
| 22 |
+
Hand m = make_mask(r,1);
|
| 23 |
+
for(int i=r+1;i<12;++i){
|
| 24 |
+
if(get_cnt(hand,i)==0)break;
|
| 25 |
+
m|=make_mask(i,1);
|
| 26 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (cnt >= 2){
|
| 32 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 33 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 34 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 35 |
+
int l_len=last?last->len:3;
|
| 36 |
+
Hand m = make_mask(r,2);
|
| 37 |
+
for(int i=r+1;i<12;++i){
|
| 38 |
+
if(get_cnt(hand,i)<2)break;
|
| 39 |
+
m|=make_mask(i,2);
|
| 40 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 46 |
+
Hand base = make_mask(r, 3);
|
| 47 |
+
for (int s = 0; s < 15; ++s) {
|
| 48 |
+
if (s == r) continue;
|
| 49 |
+
int scnt = get_cnt(hand, s);
|
| 50 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 51 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 55 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 59 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 60 |
+
|
| 61 |
+
return count;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// better than spinlock but still slower than overwritable scenario
|
| 65 |
+
template<typename T>
|
| 66 |
+
bool can_win_noverite(Hand mine, Hand opp, const Move* last, T* global_cache) {
|
| 67 |
+
if (stop_flag.load(std::memory_order_relaxed)) return false;// the result isn't important
|
| 68 |
+
if (mine == 0) return true;
|
| 69 |
+
|
| 70 |
+
Hand last_m = last ? last->mask : 0;
|
| 71 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 72 |
+
auto& entry = global_cache[h];
|
| 73 |
+
|
| 74 |
+
int8_t res = entry.result.load(std::memory_order_relaxed);
|
| 75 |
+
if(res){
|
| 76 |
+
if (entry.mine.load(std::memory_order_relaxed) == mine &&
|
| 77 |
+
entry.opp.load(std::memory_order_relaxed) == opp &&
|
| 78 |
+
entry.last_mask.load(std::memory_order_relaxed) == last_m) {
|
| 79 |
+
return res == 1;
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 84 |
+
Move moves[500];
|
| 85 |
+
int count = get_moves(mine, last, moves);
|
| 86 |
+
|
| 87 |
+
bool ans=false;
|
| 88 |
+
for (int i = 0; i < count; ++i) {
|
| 89 |
+
if (!can_win_noverite(opp, mine - moves[i].mask, &moves[i], global_cache)) {
|
| 90 |
+
ans=true;
|
| 91 |
+
break;
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// pass
|
| 96 |
+
if (!ans && last && !can_win_noverite(opp, mine, nullptr, global_cache)) {
|
| 97 |
+
ans=true;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if(!entry.result.load(std::memory_order_acquire)){
|
| 101 |
+
entry.mine.store(mine, std::memory_order_relaxed);
|
| 102 |
+
entry.opp.store(opp, std::memory_order_relaxed);
|
| 103 |
+
entry.last_mask.store(last_m, std::memory_order_relaxed);
|
| 104 |
+
entry.result.store(ans ? 1 : 2, std::memory_order_relaxed);
|
| 105 |
+
}
|
| 106 |
+
return ans;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
template<typename T>
|
| 110 |
+
bool can_win(Hand mine, Hand opp, const Move* last, T* global_cache) {
|
| 111 |
+
if (stop_flag.load(std::memory_order_relaxed)) return false;
|
| 112 |
+
if (mine == 0) return true;
|
| 113 |
+
|
| 114 |
+
Hand last_m = last ? last->mask : 0;
|
| 115 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 116 |
+
auto& entry = global_cache[h];
|
| 117 |
+
|
| 118 |
+
int8_t res = entry.result.load(std::memory_order_relaxed);
|
| 119 |
+
if(res){
|
| 120 |
+
if (entry.mine.load(std::memory_order_relaxed) == mine &&
|
| 121 |
+
entry.opp.load(std::memory_order_relaxed) == opp &&
|
| 122 |
+
entry.last_mask.load(std::memory_order_relaxed) == last_m) {
|
| 123 |
+
return res == 1;
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 128 |
+
Move moves[500];
|
| 129 |
+
int count = get_moves(mine, last, moves);
|
| 130 |
+
|
| 131 |
+
bool ans=false;
|
| 132 |
+
for (int i = 0; i < count; ++i) {
|
| 133 |
+
if (!can_win_noverite(opp, mine - moves[i].mask, &moves[i], global_cache)) {
|
| 134 |
+
ans=true;
|
| 135 |
+
break;
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// pass
|
| 140 |
+
if (!ans && last && !can_win_noverite(opp, mine, nullptr, global_cache)) {
|
| 141 |
+
ans=true;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if(!entry.result.load(std::memory_order_acquire)){
|
| 145 |
+
entry.mine.store(mine, std::memory_order_relaxed);
|
| 146 |
+
entry.opp.store(opp, std::memory_order_relaxed);
|
| 147 |
+
entry.last_mask.store(last_m, std::memory_order_relaxed);
|
| 148 |
+
entry.result.store(ans ? 1 : 2, std::memory_order_relaxed);
|
| 149 |
+
}
|
| 150 |
+
return ans;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
void gen_all_combs(int n, int r, Hand cur, std::vector<Hand>& res) {
|
| 154 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 155 |
+
if (r == 15) return;
|
| 156 |
+
int limit = (r < 13) ? 4 : 1;
|
| 157 |
+
for (int i = 0; i <= std::min(n, limit); ++i)
|
| 158 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
std::string hand_to_string(Hand h) {
|
| 162 |
+
std::string res = "";
|
| 163 |
+
const char* ranks = "34567890JQKA2SB";
|
| 164 |
+
for (int r = 0; r < 15; ++r) {
|
| 165 |
+
int cnt = (h >> (r << 2)) & 0xF;
|
| 166 |
+
for (int i = 0; i < cnt; ++i) {
|
| 167 |
+
res += ranks[r];
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
return res;
|
| 171 |
+
}
|
home/.vscode-server/data/User/History/179d5b64/YVXf.hpp
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <vector>
|
| 2 |
+
#include <algorithm>
|
| 3 |
+
|
| 4 |
+
#include "operates.hpp"
|
| 5 |
+
#include "cache.hpp"
|
| 6 |
+
|
| 7 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 8 |
+
int count = 0;
|
| 9 |
+
int l_type = last ? last->type : 0;
|
| 10 |
+
int l_rank = last ? last->rank : -1;
|
| 11 |
+
|
| 12 |
+
for (int r = 0; r < 15; ++r) {
|
| 13 |
+
int cnt = get_cnt(hand, r);
|
| 14 |
+
if (cnt >= 1){
|
| 15 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 16 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 17 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 18 |
+
int l_len= last?last->len:5;
|
| 19 |
+
Hand m = make_mask(r,1);
|
| 20 |
+
for(int i=r+1;i<12;++i){
|
| 21 |
+
if(get_cnt(hand,i)==0)break;
|
| 22 |
+
m|=make_mask(i,1);
|
| 23 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (cnt >= 2){
|
| 29 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 30 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 31 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 32 |
+
int l_len=last?last->len:3;
|
| 33 |
+
Hand m = make_mask(r,2);
|
| 34 |
+
for(int i=r+1;i<12;++i){
|
| 35 |
+
if(get_cnt(hand,i)<2)break;
|
| 36 |
+
m|=make_mask(i,2);
|
| 37 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 43 |
+
Hand base = make_mask(r, 3);
|
| 44 |
+
for (int s = 0; s < 15; ++s) {
|
| 45 |
+
if (s == r) continue;
|
| 46 |
+
int scnt = get_cnt(hand, s);
|
| 47 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 48 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 52 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 56 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 57 |
+
|
| 58 |
+
return count;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
bool can_win_fast(Hand mine, Hand opp, const Move* last) {
|
| 62 |
+
if (mine == 0) return true;
|
| 63 |
+
|
| 64 |
+
Hand last_m = last ? last->mask : 0;
|
| 65 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 66 |
+
auto& entry = global_cache[h];
|
| 67 |
+
|
| 68 |
+
entry.acquire();
|
| 69 |
+
int8_t res = entry.result.load(memory_order_relaxed);
|
| 70 |
+
if(res){
|
| 71 |
+
if (entry.mine.load(memory_order_relaxed) == mine &&
|
| 72 |
+
entry.opp.load(memory_order_relaxed) == opp &&
|
| 73 |
+
entry.last_mask.load(memory_order_relaxed) == last_m) {
|
| 74 |
+
return res == 1;
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
entry.release();
|
| 78 |
+
|
| 79 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 80 |
+
Move moves[500];
|
| 81 |
+
int count = get_moves(mine, last, moves);
|
| 82 |
+
|
| 83 |
+
bool ans=false;
|
| 84 |
+
for (int i = 0; i < count; ++i) {
|
| 85 |
+
if (!can_win_fast(opp, mine - moves[i].mask, &moves[i])) {
|
| 86 |
+
ans=true;
|
| 87 |
+
break;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// pass
|
| 92 |
+
if (!ans && last && !can_win_fast(opp, mine, nullptr)) {
|
| 93 |
+
ans=true;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
entry.acquire();
|
| 97 |
+
entry.mine.store(mine, memory_order_relaxed);
|
| 98 |
+
entry.opp.store(opp, memory_order_relaxed);
|
| 99 |
+
entry.last_mask.store(last_m, memory_order_relaxed);
|
| 100 |
+
entry.result.store(ans ? 1 : 2, memory_order_relaxed);
|
| 101 |
+
return ans;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
void gen_all_combs(int n, int r, Hand cur, vector<Hand>& res) {
|
| 105 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 106 |
+
if (r == 15) return;
|
| 107 |
+
int limit = (r < 13) ? 4 : 1;
|
| 108 |
+
for (int i = 0; i <= min(n, limit); ++i)
|
| 109 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 110 |
+
}
|
home/.vscode-server/data/User/History/179d5b64/omgD.hpp
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include "operates.hpp"
|
| 2 |
+
#include "cache.hpp"
|
| 3 |
+
|
| 4 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 5 |
+
int count = 0;
|
| 6 |
+
int l_type = last ? last->type : 0;
|
| 7 |
+
int l_rank = last ? last->rank : -1;
|
| 8 |
+
|
| 9 |
+
for (int r = 0; r < 15; ++r) {
|
| 10 |
+
int cnt = get_cnt(hand, r);
|
| 11 |
+
if (cnt >= 1){
|
| 12 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 13 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 14 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 15 |
+
int l_len= last?last->len:5;
|
| 16 |
+
Hand m = make_mask(r,1);
|
| 17 |
+
for(int i=r+1;i<12;++i){
|
| 18 |
+
if(get_cnt(hand,i)==0)break;
|
| 19 |
+
m|=make_mask(i,1);
|
| 20 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
if (cnt >= 2){
|
| 26 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 27 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 28 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 29 |
+
int l_len=last?last->len:3;
|
| 30 |
+
Hand m = make_mask(r,2);
|
| 31 |
+
for(int i=r+1;i<12;++i){
|
| 32 |
+
if(get_cnt(hand,i)<2)break;
|
| 33 |
+
m|=make_mask(i,2);
|
| 34 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 40 |
+
Hand base = make_mask(r, 3);
|
| 41 |
+
for (int s = 0; s < 15; ++s) {
|
| 42 |
+
if (s == r) continue;
|
| 43 |
+
int scnt = get_cnt(hand, s);
|
| 44 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 45 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 49 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 53 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 54 |
+
|
| 55 |
+
return count;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
bool can_win_fast(Hand mine, Hand opp, const Move* last) {
|
| 59 |
+
if (mine == 0) return true;
|
| 60 |
+
|
| 61 |
+
Hand last_m = last ? last->mask : 0;
|
| 62 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 63 |
+
auto& entry = global_cache[h];
|
| 64 |
+
|
| 65 |
+
entry.acquire();
|
| 66 |
+
int8_t res = entry.result.load(memory_order_relaxed);
|
| 67 |
+
if(res){
|
| 68 |
+
if (entry.mine.load(memory_order_relaxed) == mine &&
|
| 69 |
+
entry.opp.load(memory_order_relaxed) == opp &&
|
| 70 |
+
entry.last_mask.load(memory_order_relaxed) == last_m) {
|
| 71 |
+
return res == 1;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
entry.release();
|
| 75 |
+
|
| 76 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 77 |
+
Move moves[500];
|
| 78 |
+
int count = get_moves(mine, last, moves);
|
| 79 |
+
|
| 80 |
+
bool ans=false;
|
| 81 |
+
for (int i = 0; i < count; ++i) {
|
| 82 |
+
if (!can_win_fast(opp, mine - moves[i].mask, &moves[i])) {
|
| 83 |
+
ans=true;
|
| 84 |
+
break;
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// pass
|
| 89 |
+
if (!ans && last && !can_win_fast(opp, mine, nullptr)) {
|
| 90 |
+
ans=true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
entry.acquire();
|
| 94 |
+
entry.mine.store(mine, memory_order_relaxed);
|
| 95 |
+
entry.opp.store(opp, memory_order_relaxed);
|
| 96 |
+
entry.last_mask.store(last_m, memory_order_relaxed);
|
| 97 |
+
entry.result.store(ans ? 1 : 2, memory_order_relaxed);
|
| 98 |
+
return ans;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
void gen_all_combs(int n, int r, Hand cur, vector<Hand>& res) {
|
| 102 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 103 |
+
if (r == 15) return;
|
| 104 |
+
int limit = (r < 13) ? 4 : 1;
|
| 105 |
+
for (int i = 0; i <= min(n, limit); ++i)
|
| 106 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 107 |
+
}
|
home/.vscode-server/data/User/History/179d5b64/wK2H.hpp
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
#include <vector>
|
| 3 |
+
#include <algorithm>
|
| 4 |
+
#include <atomic>
|
| 5 |
+
#include <string>
|
| 6 |
+
|
| 7 |
+
#include "operates.hpp"
|
| 8 |
+
#include "cache.hpp"
|
| 9 |
+
|
| 10 |
+
int get_moves(Hand hand, const Move* last, Move* moves) {
|
| 11 |
+
int count = 0;
|
| 12 |
+
int l_type = last ? last->type : 0;
|
| 13 |
+
int l_rank = last ? last->rank : -1;
|
| 14 |
+
|
| 15 |
+
for (int r = 0; r < 15; ++r) {
|
| 16 |
+
int cnt = get_cnt(hand, r);
|
| 17 |
+
if (cnt >= 1){
|
| 18 |
+
if(l_type==0 || (l_type <= 1 && r > l_rank))
|
| 19 |
+
moves[count++] = {1, r, 1, make_mask(r, 1)};
|
| 20 |
+
if (l_type==0 || l_type==5 && r>l_rank){
|
| 21 |
+
int l_len= last?last->len:5;
|
| 22 |
+
Hand m = make_mask(r,1);
|
| 23 |
+
for(int i=r+1;i<12;++i){
|
| 24 |
+
if(get_cnt(hand,i)==0)break;
|
| 25 |
+
m|=make_mask(i,1);
|
| 26 |
+
if(i-r+1>=l_len)moves[count++]={5,r,i-r+1,m};
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (cnt >= 2){
|
| 32 |
+
if (l_type==0 || (l_type==2 && r > l_rank))
|
| 33 |
+
moves[count++] = {2, r, 1, make_mask(r, 2)};
|
| 34 |
+
if (l_type==0 || l_type==6 && r > l_rank){
|
| 35 |
+
int l_len=last?last->len:3;
|
| 36 |
+
Hand m = make_mask(r,2);
|
| 37 |
+
for(int i=r+1;i<12;++i){
|
| 38 |
+
if(get_cnt(hand,i)<2)break;
|
| 39 |
+
m|=make_mask(i,2);
|
| 40 |
+
if(i-r+1>=l_len)moves[count++]={6,r,i-r+1,m};
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (cnt >= 3 && (l_type == 0 || (l_type >= 3 && l_type <= 4 && r > l_rank))) {
|
| 46 |
+
Hand base = make_mask(r, 3);
|
| 47 |
+
for (int s = 0; s < 15; ++s) {
|
| 48 |
+
if (s == r) continue;
|
| 49 |
+
int scnt = get_cnt(hand, s);
|
| 50 |
+
if (scnt >= 1 && (l_type == 0 || l_type == 3)) moves[count++] = {3, r, 1, base | make_mask(s, 1)};
|
| 51 |
+
if (scnt >= 2 && (l_type == 0 || l_type == 4)) moves[count++] = {4, r, 1, base | make_mask(s, 2)};
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
if(cnt==4 && (l_type!=8 && (!(l_type==7 && r <= l_rank)))){
|
| 55 |
+
moves[count++]={7,r,1,make_mask(r,4)};
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
if (get_cnt(hand, 13) && get_cnt(hand, 14))
|
| 59 |
+
moves[count++] = {8, 99, 2, make_mask(13, 1) | make_mask(14, 1)};
|
| 60 |
+
|
| 61 |
+
return count;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
bool can_win_noverite(Hand mine, Hand opp, const Move* last) {
|
| 66 |
+
if (mine == 0) return true;
|
| 67 |
+
|
| 68 |
+
Hand last_m = last ? last->mask : 0;
|
| 69 |
+
size_t h = fast_hash(mine, opp, last_m);
|
| 70 |
+
auto& entry = global_cache[h];
|
| 71 |
+
|
| 72 |
+
int8_t res = entry.result.load(std::memory_order_relaxed);
|
| 73 |
+
if(res){
|
| 74 |
+
if (entry.mine.load(std::memory_order_relaxed) == mine &&
|
| 75 |
+
entry.opp.load(std::memory_order_relaxed) == opp &&
|
| 76 |
+
entry.last_mask.load(std::memory_order_relaxed) == last_m) {
|
| 77 |
+
return res == 1;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
//15+13+13*14+13*12+(10+9+...+1)+(10+9+...+1)+13+1=490
|
| 82 |
+
Move moves[500];
|
| 83 |
+
int count = get_moves(mine, last, moves);
|
| 84 |
+
|
| 85 |
+
bool ans=false;
|
| 86 |
+
for (int i = 0; i < count; ++i) {
|
| 87 |
+
if (!can_win_noverite(opp, mine - moves[i].mask, &moves[i])) {
|
| 88 |
+
ans=true;
|
| 89 |
+
break;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// pass
|
| 94 |
+
if (!ans && last && !can_win_noverite(opp, mine, nullptr)) {
|
| 95 |
+
ans=true;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if(!entry.result.load(std::memory_order_acquire)){
|
| 99 |
+
entry.mine.store(mine, std::memory_order_relaxed);
|
| 100 |
+
entry.opp.store(opp, std::memory_order_relaxed);
|
| 101 |
+
entry.last_mask.store(last_m, std::memory_order_relaxed);
|
| 102 |
+
entry.result.store(ans ? 1 : 2, std::memory_order_relaxed);
|
| 103 |
+
}
|
| 104 |
+
return ans;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
void gen_all_combs(int n, int r, Hand cur, std::vector<Hand>& res) {
|
| 108 |
+
if (n == 0) { res.push_back(cur); return; }
|
| 109 |
+
if (r == 15) return;
|
| 110 |
+
int limit = (r < 13) ? 4 : 1;
|
| 111 |
+
for (int i = 0; i <= std::min(n, limit); ++i)
|
| 112 |
+
gen_all_combs(n - i, r + 1, cur | make_mask(r, i), res);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
std::string hand_to_string(Hand h) {
|
| 116 |
+
std::string res = "";
|
| 117 |
+
const char* ranks = "34567890JQKA2SB";
|
| 118 |
+
for (int r = 0; r < 15; ++r) {
|
| 119 |
+
int cnt = (h >> (r << 2)) & 0xF;
|
| 120 |
+
for (int i = 0; i < cnt; ++i) {
|
| 121 |
+
res += ranks[r];
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
return res;
|
| 125 |
+
}
|
home/.vscode-server/data/User/History/37fcd955/05vn.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
import torch
|
| 4 |
+
from datasets import load_dataset
|
| 5 |
+
from transformers import GPT2TokenizerFast
|
| 6 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 7 |
+
|
| 8 |
+
# ----------------------------
|
| 9 |
+
# 配置
|
| 10 |
+
# ----------------------------
|
| 11 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 12 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 13 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 14 |
+
# subset = 'plain_text' # 对于 ptb
|
| 15 |
+
|
| 16 |
+
# 加载你的训练好的模型(假设已保存为 ckpt.pth)
|
| 17 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt' # 替换为你的 checkpoint 路径
|
| 18 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 19 |
+
# 如果你用的是 from_pretrained,也可以直接初始化
|
| 20 |
+
# config = GPTConfig(n_layer=24, n_head=16, n_embd=1024) # gpt2-medium
|
| 21 |
+
# model = GPT(config)
|
| 22 |
+
|
| 23 |
+
model = GPT(checkpoint['config'])
|
| 24 |
+
model.load_state_dict(checkpoint['model'])
|
| 25 |
+
model.to(device)
|
| 26 |
+
model.eval()
|
| 27 |
+
|
| 28 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 29 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 30 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 31 |
+
|
| 32 |
+
# ----------------------------
|
| 33 |
+
# 加载数据集
|
| 34 |
+
# ----------------------------
|
| 35 |
+
def tokenize_function(examples):
|
| 36 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 37 |
+
|
| 38 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 39 |
+
tokenized_dataset = raw_dataset.map(
|
| 40 |
+
tokenize_function,
|
| 41 |
+
batched=True,
|
| 42 |
+
remove_columns=raw_dataset.column_names,
|
| 43 |
+
desc="Tokenizing",
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# 合并所有 token 成一个长列表
|
| 47 |
+
full_tokens = []
|
| 48 |
+
for item in tokenized_dataset:
|
| 49 |
+
full_tokens.extend(item['input_ids'])
|
| 50 |
+
|
| 51 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 52 |
+
block_size = model.config.block_size
|
| 53 |
+
n_blocks = len(full_tokens) // block_size
|
| 54 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 55 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 56 |
+
|
| 57 |
+
# ----------------------------
|
| 58 |
+
# 计算 PPL
|
| 59 |
+
# ----------------------------
|
| 60 |
+
total_loss = 0.0
|
| 61 |
+
total_tokens = 0
|
| 62 |
+
|
| 63 |
+
with torch.no_grad():
|
| 64 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 65 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 66 |
+
_, loss = model(x, targets=x)
|
| 67 |
+
total_loss += loss.item() * x.numel()
|
| 68 |
+
total_tokens += x.numel()
|
| 69 |
+
|
| 70 |
+
avg_loss = total_loss / total_tokens
|
| 71 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 72 |
+
|
| 73 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 74 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 75 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/3xeB.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
import torch
|
| 4 |
+
from datasets import load_dataset
|
| 5 |
+
from transformers import GPT2TokenizerFast
|
| 6 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 7 |
+
|
| 8 |
+
# ----------------------------
|
| 9 |
+
# 配置
|
| 10 |
+
# ----------------------------
|
| 11 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 12 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 13 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 14 |
+
# subset = 'plain_text' # 对于 ptb
|
| 15 |
+
|
| 16 |
+
# 加载你的训练好的模型(假设已保存为 ckpt.pth)
|
| 17 |
+
ckpt_path = 'ckpt.pth' # 替换为你的 checkpoint 路径
|
| 18 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 19 |
+
# 如果你用的是 from_pretrained,也可以直接初始化
|
| 20 |
+
# config = GPTConfig(n_layer=24, n_head=16, n_embd=1024) # gpt2-medium
|
| 21 |
+
# model = GPT(config)
|
| 22 |
+
|
| 23 |
+
model = GPT(checkpoint['config'])
|
| 24 |
+
model.load_state_dict(checkpoint['model'])
|
| 25 |
+
model.to(device)
|
| 26 |
+
model.eval()
|
| 27 |
+
|
| 28 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 29 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 30 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 31 |
+
|
| 32 |
+
# ----------------------------
|
| 33 |
+
# 加载数据集
|
| 34 |
+
# ----------------------------
|
| 35 |
+
def tokenize_function(examples):
|
| 36 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 37 |
+
|
| 38 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 39 |
+
tokenized_dataset = raw_dataset.map(
|
| 40 |
+
tokenize_function,
|
| 41 |
+
batched=True,
|
| 42 |
+
remove_columns=raw_dataset.column_names,
|
| 43 |
+
desc="Tokenizing",
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# 合并所有 token 成一个长列表
|
| 47 |
+
full_tokens = []
|
| 48 |
+
for item in tokenized_dataset:
|
| 49 |
+
full_tokens.extend(item['input_ids'])
|
| 50 |
+
|
| 51 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 52 |
+
block_size = model.config.block_size
|
| 53 |
+
n_blocks = len(full_tokens) // block_size
|
| 54 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 55 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 56 |
+
|
| 57 |
+
# ----------------------------
|
| 58 |
+
# 计算 PPL
|
| 59 |
+
# ----------------------------
|
| 60 |
+
total_loss = 0.0
|
| 61 |
+
total_tokens = 0
|
| 62 |
+
|
| 63 |
+
with torch.no_grad():
|
| 64 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 65 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 66 |
+
_, loss = model(x, targets=x)
|
| 67 |
+
total_loss += loss.item() * x.numel()
|
| 68 |
+
total_tokens += x.numel()
|
| 69 |
+
|
| 70 |
+
avg_loss = total_loss / total_tokens
|
| 71 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 72 |
+
|
| 73 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 74 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 75 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/V4pm.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
import torch
|
| 4 |
+
from datasets import load_dataset
|
| 5 |
+
from transformers import GPT2TokenizerFast
|
| 6 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 7 |
+
|
| 8 |
+
# ----------------------------
|
| 9 |
+
# 配置
|
| 10 |
+
# ----------------------------
|
| 11 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 12 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 13 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 14 |
+
# subset = 'plain_text' # 对于 ptb
|
| 15 |
+
n_layer = 24
|
| 16 |
+
n_head = 16
|
| 17 |
+
n_embd = 1024
|
| 18 |
+
dropout = 0.0
|
| 19 |
+
bias = False
|
| 20 |
+
model_args = dict(n_layer=n_layer, n_head=n_head, n_embd=n_embd, block_size=block_size,
|
| 21 |
+
bias=bias, vocab_size=None, dropout=dropout)
|
| 22 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt' # 替换为你的 checkpoint 路径
|
| 23 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 24 |
+
checkpoint_model_args = checkpoint['model_args']
|
| 25 |
+
# force these config attributes to be equal otherwise we can't even resume training
|
| 26 |
+
# the rest of the attributes (e.g. dropout) can stay as desired from command line
|
| 27 |
+
for k in ['n_layer', 'n_head', 'n_embd', 'block_size', 'bias', 'vocab_size']:
|
| 28 |
+
model_args[k] = checkpoint_model_args[k]
|
| 29 |
+
# create the model
|
| 30 |
+
gptconf = GPTConfig(**model_args)
|
| 31 |
+
model = GPT(gptconf)
|
| 32 |
+
state_dict = checkpoint['model']
|
| 33 |
+
# fix the keys of the state dictionary :(
|
| 34 |
+
# honestly no idea how checkpoints sometimes get this prefix, have to debug more
|
| 35 |
+
unwanted_prefix = '_orig_mod.'
|
| 36 |
+
for k,v in list(state_dict.items()):
|
| 37 |
+
if k.startswith(unwanted_prefix):
|
| 38 |
+
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
| 39 |
+
model.load_state_dict(state_dict)
|
| 40 |
+
|
| 41 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 42 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 43 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 44 |
+
|
| 45 |
+
# ----------------------------
|
| 46 |
+
# 加载数据集
|
| 47 |
+
# ----------------------------
|
| 48 |
+
def tokenize_function(examples):
|
| 49 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 50 |
+
|
| 51 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 52 |
+
tokenized_dataset = raw_dataset.map(
|
| 53 |
+
tokenize_function,
|
| 54 |
+
batched=True,
|
| 55 |
+
remove_columns=raw_dataset.column_names,
|
| 56 |
+
desc="Tokenizing",
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
# 合并所有 token 成一个长列表
|
| 60 |
+
full_tokens = []
|
| 61 |
+
for item in tokenized_dataset:
|
| 62 |
+
full_tokens.extend(item['input_ids'])
|
| 63 |
+
|
| 64 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 65 |
+
block_size = model.config.block_size
|
| 66 |
+
n_blocks = len(full_tokens) // block_size
|
| 67 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 68 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 69 |
+
|
| 70 |
+
# ----------------------------
|
| 71 |
+
# 计算 PPL
|
| 72 |
+
# ----------------------------
|
| 73 |
+
total_loss = 0.0
|
| 74 |
+
total_tokens = 0
|
| 75 |
+
|
| 76 |
+
with torch.no_grad():
|
| 77 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 78 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 79 |
+
_, loss = model(x, targets=x)
|
| 80 |
+
total_loss += loss.item() * x.numel()
|
| 81 |
+
total_tokens += x.numel()
|
| 82 |
+
|
| 83 |
+
avg_loss = total_loss / total_tokens
|
| 84 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 85 |
+
|
| 86 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 87 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 88 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/XcDC.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
os.environ['HF_ENDPOINT']='https://hf-mirror.com'
|
| 4 |
+
import torch
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
+
from transformers import GPT2TokenizerFast
|
| 7 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 8 |
+
|
| 9 |
+
# ----------------------------
|
| 10 |
+
# 配置
|
| 11 |
+
# ----------------------------
|
| 12 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 13 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 14 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 15 |
+
# subset = 'plain_text' # 对于 ptb
|
| 16 |
+
n_layer = 24
|
| 17 |
+
n_head = 16
|
| 18 |
+
n_embd = 1024
|
| 19 |
+
dropout = 0.0
|
| 20 |
+
block_size=1024
|
| 21 |
+
bias = False
|
| 22 |
+
model_args = dict(n_layer=n_layer, n_head=n_head, n_embd=n_embd, block_size=block_size,
|
| 23 |
+
bias=bias, vocab_size=None, dropout=dropout)
|
| 24 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt' # 替换为你的 checkpoint 路径
|
| 25 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 26 |
+
checkpoint_model_args = checkpoint['model_args']
|
| 27 |
+
# force these config attributes to be equal otherwise we can't even resume training
|
| 28 |
+
# the rest of the attributes (e.g. dropout) can stay as desired from command line
|
| 29 |
+
for k in ['n_layer', 'n_head', 'n_embd', 'block_size', 'bias', 'vocab_size']:
|
| 30 |
+
model_args[k] = checkpoint_model_args[k]
|
| 31 |
+
# create the model
|
| 32 |
+
gptconf = GPTConfig(**model_args)
|
| 33 |
+
model = GPT(gptconf)
|
| 34 |
+
state_dict = checkpoint['model']
|
| 35 |
+
# fix the keys of the state dictionary :(
|
| 36 |
+
# honestly no idea how checkpoints sometimes get this prefix, have to debug more
|
| 37 |
+
unwanted_prefix = '_orig_mod.'
|
| 38 |
+
for k,v in list(state_dict.items()):
|
| 39 |
+
if k.startswith(unwanted_prefix):
|
| 40 |
+
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
| 41 |
+
model.load_state_dict(state_dict)
|
| 42 |
+
|
| 43 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 44 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 45 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 46 |
+
|
| 47 |
+
# ----------------------------
|
| 48 |
+
# 加载数据集
|
| 49 |
+
# ----------------------------
|
| 50 |
+
def tokenize_function(examples):
|
| 51 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 52 |
+
|
| 53 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 54 |
+
tokenized_dataset = raw_dataset.map(
|
| 55 |
+
tokenize_function,
|
| 56 |
+
batched=True,
|
| 57 |
+
remove_columns=raw_dataset.column_names,
|
| 58 |
+
desc="Tokenizing",
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# 合并所有 token 成一个长列表
|
| 62 |
+
full_tokens = []
|
| 63 |
+
for item in tokenized_dataset:
|
| 64 |
+
full_tokens.extend(item['input_ids'])
|
| 65 |
+
|
| 66 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 67 |
+
block_size = model.config.block_size
|
| 68 |
+
n_blocks = len(full_tokens) // block_size
|
| 69 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 70 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 71 |
+
|
| 72 |
+
# ----------------------------
|
| 73 |
+
# 计算 PPL
|
| 74 |
+
# ----------------------------
|
| 75 |
+
total_loss = 0.0
|
| 76 |
+
total_tokens = 0
|
| 77 |
+
|
| 78 |
+
with torch.no_grad():
|
| 79 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 80 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 81 |
+
_, loss = model(x, targets=x)
|
| 82 |
+
total_loss += loss.item() * x.numel()
|
| 83 |
+
total_tokens += x.numel()
|
| 84 |
+
|
| 85 |
+
avg_loss = total_loss / total_tokens
|
| 86 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 87 |
+
|
| 88 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 89 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 90 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/ZpQF.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME'] = '/zfspool/zangyihe/cache'
|
| 3 |
+
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
from datasets import load_dataset
|
| 7 |
+
from transformers import GPT2TokenizerFast
|
| 8 |
+
from model import GPT, GPTConfig
|
| 9 |
+
|
| 10 |
+
# ----------------------------
|
| 11 |
+
# 模型加载(保持不变)
|
| 12 |
+
# ----------------------------
|
| 13 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 14 |
+
n_layer = 24
|
| 15 |
+
n_head = 16
|
| 16 |
+
n_embd = 1024
|
| 17 |
+
dropout = 0.0
|
| 18 |
+
block_size = 1024
|
| 19 |
+
bias = False
|
| 20 |
+
|
| 21 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt'
|
| 22 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 23 |
+
checkpoint_model_args = checkpoint['model_args']
|
| 24 |
+
|
| 25 |
+
model_args = dict(
|
| 26 |
+
n_layer=n_layer, n_head=n_head, n_embd=n_embd,
|
| 27 |
+
block_size=block_size, bias=bias, vocab_size=None, dropout=dropout
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
for k in ['n_layer', 'n_head', 'n_embd', 'block_size', 'bias', 'vocab_size']:
|
| 31 |
+
model_args[k] = checkpoint_model_args[k]
|
| 32 |
+
|
| 33 |
+
gptconf = GPTConfig(**model_args)
|
| 34 |
+
model = GPT(gptconf)
|
| 35 |
+
|
| 36 |
+
state_dict = checkpoint['model']
|
| 37 |
+
unwanted_prefix = '_orig_mod.'
|
| 38 |
+
for k in list(state_dict.keys()):
|
| 39 |
+
if k.startswith(unwanted_prefix):
|
| 40 |
+
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
| 41 |
+
|
| 42 |
+
model.load_state_dict(state_dict)
|
| 43 |
+
model.to(device)
|
| 44 |
+
model.eval() # ⚠️ 必须加!否则 dropout 会干扰 eval
|
| 45 |
+
|
| 46 |
+
# ----------------------------
|
| 47 |
+
# Tokenizer(保持不变)
|
| 48 |
+
# ----------------------------
|
| 49 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 50 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 51 |
+
|
| 52 |
+
# ----------------------------
|
| 53 |
+
# ✅ 关键修改:使用清理版数据集 + 正确分段
|
| 54 |
+
# ----------------------------
|
| 55 |
+
dataset_name = 'wikitext'
|
| 56 |
+
subset = 'wikitext-2-v1' # ← 改这里!不要用 -raw
|
| 57 |
+
|
| 58 |
+
# 加载测试集
|
| 59 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 60 |
+
|
| 61 |
+
# ✅ 预处理:将每个非空段落结尾加上 EOS,避免跨文档污染
|
| 62 |
+
def preprocess_function(examples):
|
| 63 |
+
texts = []
|
| 64 |
+
for text in examples['text']:
|
| 65 |
+
# 移除纯等号行(如 "= = = Section = = =" 中的孤立等号)
|
| 66 |
+
lines = [line.strip() for line in text.split('\n') if line.strip()]
|
| 67 |
+
cleaned = ' '.join(lines)
|
| 68 |
+
if cleaned:
|
| 69 |
+
texts.append(cleaned + tokenizer.eos_token) # 段落结束加 EOS
|
| 70 |
+
else:
|
| 71 |
+
texts.append(tokenizer.eos_token)
|
| 72 |
+
return {'text': texts}
|
| 73 |
+
|
| 74 |
+
cleaned_dataset = raw_dataset.map(preprocess_function, batched=True, desc="Preprocessing")
|
| 75 |
+
|
| 76 |
+
# Tokenize
|
| 77 |
+
def tokenize_function(examples):
|
| 78 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024, add_special_tokens=False)
|
| 79 |
+
|
| 80 |
+
tokenized_dataset = cleaned_dataset.map(
|
| 81 |
+
tokenize_function,
|
| 82 |
+
batched=True,
|
| 83 |
+
remove_columns=cleaned_dataset.column_names,
|
| 84 |
+
desc="Tokenizing",
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
# 合并所有 tokens
|
| 88 |
+
full_tokens = []
|
| 89 |
+
for item in tokenized_dataset:
|
| 90 |
+
full_tokens.extend(item['input_ids'])
|
| 91 |
+
|
| 92 |
+
# 分块(适配模型 block_size)
|
| 93 |
+
block_size = model.config.block_size
|
| 94 |
+
n_blocks = len(full_tokens) // block_size
|
| 95 |
+
if n_blocks == 0:
|
| 96 |
+
raise ValueError("Not enough tokens! Check your data preprocessing.")
|
| 97 |
+
|
| 98 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 99 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 100 |
+
|
| 101 |
+
# ----------------------------
|
| 102 |
+
# 计算 PPL(保持不变,但加 tqdm 可选)
|
| 103 |
+
# ----------------------------
|
| 104 |
+
total_loss = 0.0
|
| 105 |
+
total_tokens = 0
|
| 106 |
+
|
| 107 |
+
model.eval() # 再次确保
|
| 108 |
+
with torch.no_grad():
|
| 109 |
+
for i in range(input_ids.size(0)):
|
| 110 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 111 |
+
_, loss = model(x, targets=x)
|
| 112 |
+
if torch.isnan(loss) or torch.isinf(loss):
|
| 113 |
+
print(f"Warning: NaN/Inf loss at batch {i}")
|
| 114 |
+
continue
|
| 115 |
+
total_loss += loss.item() * x.numel()
|
| 116 |
+
total_tokens += x.numel()
|
| 117 |
+
|
| 118 |
+
avg_loss = total_loss / total_tokens
|
| 119 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 120 |
+
|
| 121 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 122 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 123 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/entries.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":1,"resource":"vscode-remote://ssh-remote%2B10.220.5.132/home/zangyihe/nanoGPT/eeval.py","entries":[{"id":"xK08.py","timestamp":1768804604713},{"id":"3xeB.py","timestamp":1768804664910},{"id":"05vn.py","timestamp":1768804745432},{"id":"V4pm.py","timestamp":1768804942735},{"id":"iinr.py","timestamp":1768804967648},{"id":"XcDC.py","timestamp":1768805022409},{"id":"vyXH.py","timestamp":1768805100438},{"id":"ZpQF.py","timestamp":1768805516902}]}
|
home/.vscode-server/data/User/History/37fcd955/iinr.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
import torch
|
| 4 |
+
from datasets import load_dataset
|
| 5 |
+
from transformers import GPT2TokenizerFast
|
| 6 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 7 |
+
|
| 8 |
+
# ----------------------------
|
| 9 |
+
# 配置
|
| 10 |
+
# ----------------------------
|
| 11 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 12 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 13 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 14 |
+
# subset = 'plain_text' # 对于 ptb
|
| 15 |
+
n_layer = 24
|
| 16 |
+
n_head = 16
|
| 17 |
+
n_embd = 1024
|
| 18 |
+
dropout = 0.0
|
| 19 |
+
block_size=1024
|
| 20 |
+
bias = False
|
| 21 |
+
model_args = dict(n_layer=n_layer, n_head=n_head, n_embd=n_embd, block_size=block_size,
|
| 22 |
+
bias=bias, vocab_size=None, dropout=dropout)
|
| 23 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt' # 替换为你的 checkpoint 路径
|
| 24 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 25 |
+
checkpoint_model_args = checkpoint['model_args']
|
| 26 |
+
# force these config attributes to be equal otherwise we can't even resume training
|
| 27 |
+
# the rest of the attributes (e.g. dropout) can stay as desired from command line
|
| 28 |
+
for k in ['n_layer', 'n_head', 'n_embd', 'block_size', 'bias', 'vocab_size']:
|
| 29 |
+
model_args[k] = checkpoint_model_args[k]
|
| 30 |
+
# create the model
|
| 31 |
+
gptconf = GPTConfig(**model_args)
|
| 32 |
+
model = GPT(gptconf)
|
| 33 |
+
state_dict = checkpoint['model']
|
| 34 |
+
# fix the keys of the state dictionary :(
|
| 35 |
+
# honestly no idea how checkpoints sometimes get this prefix, have to debug more
|
| 36 |
+
unwanted_prefix = '_orig_mod.'
|
| 37 |
+
for k,v in list(state_dict.items()):
|
| 38 |
+
if k.startswith(unwanted_prefix):
|
| 39 |
+
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
| 40 |
+
model.load_state_dict(state_dict)
|
| 41 |
+
|
| 42 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 43 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 44 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 45 |
+
|
| 46 |
+
# ----------------------------
|
| 47 |
+
# 加载数据集
|
| 48 |
+
# ----------------------------
|
| 49 |
+
def tokenize_function(examples):
|
| 50 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 51 |
+
|
| 52 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 53 |
+
tokenized_dataset = raw_dataset.map(
|
| 54 |
+
tokenize_function,
|
| 55 |
+
batched=True,
|
| 56 |
+
remove_columns=raw_dataset.column_names,
|
| 57 |
+
desc="Tokenizing",
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# 合并所有 token 成一个长列表
|
| 61 |
+
full_tokens = []
|
| 62 |
+
for item in tokenized_dataset:
|
| 63 |
+
full_tokens.extend(item['input_ids'])
|
| 64 |
+
|
| 65 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 66 |
+
block_size = model.config.block_size
|
| 67 |
+
n_blocks = len(full_tokens) // block_size
|
| 68 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 69 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 70 |
+
|
| 71 |
+
# ----------------------------
|
| 72 |
+
# 计算 PPL
|
| 73 |
+
# ----------------------------
|
| 74 |
+
total_loss = 0.0
|
| 75 |
+
total_tokens = 0
|
| 76 |
+
|
| 77 |
+
with torch.no_grad():
|
| 78 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 79 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 80 |
+
_, loss = model(x, targets=x)
|
| 81 |
+
total_loss += loss.item() * x.numel()
|
| 82 |
+
total_tokens += x.numel()
|
| 83 |
+
|
| 84 |
+
avg_loss = total_loss / total_tokens
|
| 85 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 86 |
+
|
| 87 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 88 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 89 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/vyXH.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ['HF_HOME']='/zfspool/zangyihe/cache'
|
| 3 |
+
os.environ['HF_ENDPOINT']='https://hf-mirror.com'
|
| 4 |
+
import torch
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
+
from transformers import GPT2TokenizerFast
|
| 7 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 8 |
+
|
| 9 |
+
# ----------------------------
|
| 10 |
+
# 配置
|
| 11 |
+
# ----------------------------
|
| 12 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 13 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 14 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 15 |
+
# subset = 'plain_text' # 对于 ptb
|
| 16 |
+
n_layer = 24
|
| 17 |
+
n_head = 16
|
| 18 |
+
n_embd = 1024
|
| 19 |
+
dropout = 0.0
|
| 20 |
+
block_size=1024
|
| 21 |
+
bias = False
|
| 22 |
+
model_args = dict(n_layer=n_layer, n_head=n_head, n_embd=n_embd, block_size=block_size,
|
| 23 |
+
bias=bias, vocab_size=None, dropout=dropout)
|
| 24 |
+
ckpt_path = '/zfspool/zangyihe/models/300m/ckpt_iter_126000.pt' # 替换为你的 checkpoint 路径
|
| 25 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 26 |
+
checkpoint_model_args = checkpoint['model_args']
|
| 27 |
+
# force these config attributes to be equal otherwise we can't even resume training
|
| 28 |
+
# the rest of the attributes (e.g. dropout) can stay as desired from command line
|
| 29 |
+
for k in ['n_layer', 'n_head', 'n_embd', 'block_size', 'bias', 'vocab_size']:
|
| 30 |
+
model_args[k] = checkpoint_model_args[k]
|
| 31 |
+
# create the model
|
| 32 |
+
gptconf = GPTConfig(**model_args)
|
| 33 |
+
model = GPT(gptconf)
|
| 34 |
+
state_dict = checkpoint['model']
|
| 35 |
+
# fix the keys of the state dictionary :(
|
| 36 |
+
# honestly no idea how checkpoints sometimes get this prefix, have to debug more
|
| 37 |
+
unwanted_prefix = '_orig_mod.'
|
| 38 |
+
for k,v in list(state_dict.items()):
|
| 39 |
+
if k.startswith(unwanted_prefix):
|
| 40 |
+
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
|
| 41 |
+
model.load_state_dict(state_dict)
|
| 42 |
+
model.to(device)
|
| 43 |
+
|
| 44 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 45 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 46 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 47 |
+
|
| 48 |
+
# ----------------------------
|
| 49 |
+
# 加载数据集
|
| 50 |
+
# ----------------------------
|
| 51 |
+
def tokenize_function(examples):
|
| 52 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 53 |
+
|
| 54 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 55 |
+
tokenized_dataset = raw_dataset.map(
|
| 56 |
+
tokenize_function,
|
| 57 |
+
batched=True,
|
| 58 |
+
remove_columns=raw_dataset.column_names,
|
| 59 |
+
desc="Tokenizing",
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# 合并所有 token 成一个长列表
|
| 63 |
+
full_tokens = []
|
| 64 |
+
for item in tokenized_dataset:
|
| 65 |
+
full_tokens.extend(item['input_ids'])
|
| 66 |
+
|
| 67 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 68 |
+
block_size = model.config.block_size
|
| 69 |
+
n_blocks = len(full_tokens) // block_size
|
| 70 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 71 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 72 |
+
|
| 73 |
+
# ----------------------------
|
| 74 |
+
# 计算 PPL
|
| 75 |
+
# ----------------------------
|
| 76 |
+
total_loss = 0.0
|
| 77 |
+
total_tokens = 0
|
| 78 |
+
|
| 79 |
+
with torch.no_grad():
|
| 80 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 81 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 82 |
+
_, loss = model(x, targets=x)
|
| 83 |
+
total_loss += loss.item() * x.numel()
|
| 84 |
+
total_tokens += x.numel()
|
| 85 |
+
|
| 86 |
+
avg_loss = total_loss / total_tokens
|
| 87 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 88 |
+
|
| 89 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 90 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 91 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|
home/.vscode-server/data/User/History/37fcd955/xK08.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from datasets import load_dataset
|
| 3 |
+
from transformers import GPT2TokenizerFast
|
| 4 |
+
from model import GPT, GPTConfig # 假设你的 model.py 在同目录
|
| 5 |
+
|
| 6 |
+
# ----------------------------
|
| 7 |
+
# 配置
|
| 8 |
+
# ----------------------------
|
| 9 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 10 |
+
dataset_name = 'wikitext' # 可选: 'wikitext', 'ptb', 'lm1b'
|
| 11 |
+
subset = 'wikitext-2-raw-v1' # 对于 wikitext
|
| 12 |
+
# subset = 'plain_text' # 对于 ptb
|
| 13 |
+
|
| 14 |
+
# 加载你的训练好的模型(假设已保存为 ckpt.pth)
|
| 15 |
+
ckpt_path = 'ckpt.pth' # 替换为你的 checkpoint 路径
|
| 16 |
+
checkpoint = torch.load(ckpt_path, map_location=device)
|
| 17 |
+
# 如果你用的是 from_pretrained,也可以直接初始化
|
| 18 |
+
# config = GPTConfig(n_layer=24, n_head=16, n_embd=1024) # gpt2-medium
|
| 19 |
+
# model = GPT(config)
|
| 20 |
+
|
| 21 |
+
model = GPT(checkpoint['config'])
|
| 22 |
+
model.load_state_dict(checkpoint['model'])
|
| 23 |
+
model.to(device)
|
| 24 |
+
model.eval()
|
| 25 |
+
|
| 26 |
+
# 使用 GPT-2 tokenizer(与你的模型 vocab_size=50257/50304 兼容)
|
| 27 |
+
tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
|
| 28 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 29 |
+
|
| 30 |
+
# ----------------------------
|
| 31 |
+
# 加载数据集
|
| 32 |
+
# ----------------------------
|
| 33 |
+
def tokenize_function(examples):
|
| 34 |
+
return tokenizer(examples['text'], truncation=True, max_length=1024)
|
| 35 |
+
|
| 36 |
+
raw_dataset = load_dataset(dataset_name, subset, split='test')
|
| 37 |
+
tokenized_dataset = raw_dataset.map(
|
| 38 |
+
tokenize_function,
|
| 39 |
+
batched=True,
|
| 40 |
+
remove_columns=raw_dataset.column_names,
|
| 41 |
+
desc="Tokenizing",
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
# 合并所有 token 成一个长列表
|
| 45 |
+
full_tokens = []
|
| 46 |
+
for item in tokenized_dataset:
|
| 47 |
+
full_tokens.extend(item['input_ids'])
|
| 48 |
+
|
| 49 |
+
# 分成 block_size 长度的 chunks(适配你的模型 block_size)
|
| 50 |
+
block_size = model.config.block_size
|
| 51 |
+
n_blocks = len(full_tokens) // block_size
|
| 52 |
+
input_ids = torch.tensor(full_tokens[:n_blocks * block_size], dtype=torch.long)
|
| 53 |
+
input_ids = input_ids.view(n_blocks, block_size)
|
| 54 |
+
|
| 55 |
+
# ----------------------------
|
| 56 |
+
# 计算 PPL
|
| 57 |
+
# ----------------------------
|
| 58 |
+
total_loss = 0.0
|
| 59 |
+
total_tokens = 0
|
| 60 |
+
|
| 61 |
+
with torch.no_grad():
|
| 62 |
+
for i in range(0, input_ids.size(0), 1): # batch_size=1(避免 OOM)
|
| 63 |
+
x = input_ids[i:i+1].to(device) # (1, T)
|
| 64 |
+
_, loss = model(x, targets=x)
|
| 65 |
+
total_loss += loss.item() * x.numel()
|
| 66 |
+
total_tokens += x.numel()
|
| 67 |
+
|
| 68 |
+
avg_loss = total_loss / total_tokens
|
| 69 |
+
ppl = torch.exp(torch.tensor(avg_loss)).item()
|
| 70 |
+
|
| 71 |
+
print(f"Dataset: {dataset_name}/{subset}")
|
| 72 |
+
print(f"Average Loss: {avg_loss:.4f}")
|
| 73 |
+
print(f"Perplexity (PPL): {ppl:.2f}")
|