正文
增加 9 行删除 703 行
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709将 `OIcoach.cpp` 和 `Library.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.编译系统要求 C++17 及以上,Windows 系统.Library.h :```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reserved#include<bits/stdc++.h>#include<windows.h>using namespace std;typedef long long ll;typedef pair<int, int> pii;mt19937 mrand(time(0));class IORedirector{private:streambuf* old_cin_buf;streambuf* old_cout_buf;ifstream input_file;ofstream output_file;bool input_redirected;bool output_redirected;public:explicit IORedirector(const string& in_file = "", const string& out_file = ""): old_cin_buf(nullptr), old_cout_buf(nullptr),input_redirected(false), output_redirected(false){if(!in_file.empty()){input_file.open(in_file);if(input_file.is_open()){old_cin_buf = cin.rdbuf(input_file.rdbuf());input_redirected = true;}else{system("cls");cout << "错误 : 找不到指定文件 " << in_file << "\n";exit(0);}}if(!out_file.empty()){output_file.open(out_file);if(output_file.is_open()){old_cout_buf = cout.rdbuf(output_file.rdbuf());output_redirected = true;}}}~IORedirector(){if(input_redirected && old_cin_buf){cin.rdbuf(old_cin_buf);if(output_redirected && old_cout_buf){cout.rdbuf(old_cout_buf);}}if(output_redirected && old_cout_buf){cout.rdbuf(old_cout_buf);}}IORedirector(const IORedirector&) = delete;IORedirector& operator=(const IORedirector&) = delete;IORedirector(IORedirector&& other) noexcept: old_cin_buf(other.old_cin_buf),old_cout_buf(other.old_cout_buf),input_redirected(other.input_redirected),output_redirected(other.output_redirected){other.old_cin_buf = nullptr;other.old_cout_buf = nullptr;other.input_redirected = false;other.output_redirected = false;}};const string SAVE = "Copyright (C) since 2026 _auto_ / hwz007\nAll rights reserved\n\n";const string NOW_V = "V 0.3.1\n\n";const vector<string> UPDATE_DAILY = {"V 0.1.1 更新内容 : \n 1. 优化了 \"集训\" 界面显示\n 2. 移除了彩蛋,并修复了无限刷钱的 Bug\n\n","V 0.1.2 更新内容 : \n 1. 更好的操作系统\n\n","V 0.1.3 更新内容 : \n 1. 优化代码架构,提升运行速度\n\n","V 0.1.4 更新内容 : \n 1. 现在,打开调试工具需要管理员权限\n\n","V 0.2.0 更新内容 : \n 1. 主界面会随机显示批话(摘自洛谷用户 dAniel_lele )\n\n","V 0.3.0 更新内容 : \n 1. 新增存档功能,游戏内每周自动存档\n 2. 修复若干 Bug\n\n","V 0.3.1 更新内容 : \n 1. 比赛功能开启内测\n\n"};const string PASSWORD = "PenaltyKingAKIOI";const vector<string> BULLSHIT = {"\"当你在幻想上天会给你开一扇窗的时候,你已经输一半了\"","\"不要害怕跟比自己强的人对线。当他已经无理到用自己的强弱来对线时,这个人已经无药可救了\"","\"永远拿着早就不属于自己的能力在欺骗\"","\"由俭入奢易,由奢入俭难。谁不曾幻想多当一会儿赢家呢,只是幻想永远是幻想罢了\"","\"脑子不好是硬伤\"","\"如果平时训练的时候没有压力每天摆烂从不从自己身上找原因,正式考完需要承担原本可以分摊到每天的压力\"","\"有些事情,你没有必要对它有责任感,毕竟没有人对它有责任感\"","\"戒一周游戏都戒不明白吗?\"","\"让每一个时刻的你,不要成为另一个时刻的累赘。仅此而已\"","\"活在这里…好累…如果上天不愿意让我活在一具能赢的躯体,能不能至少让我活在一具输了也不会难受的…\"","\"因为别人比自己强而讨厌他/她是正常的吗…\"","\"不要去思考未来,把这留给未来的你\"","\"该认真一点了,他们已经超越你了,为什么还不端正态度?以前的你会因为这个天天夜夜破防,现在的你为何别得这般无耻?\"","\"享受胜利就像吸毒,没有意义,容易上瘾,使人麻痹,无法持续\"","\"为了守住友谊而看淡竞争,而不是为了看淡竞争而守住友谊\"","\"你不能只在别人比你菜的时候才把别人当成朋友\"","\"你羡慕啥呢?别人不过是学术比你强,脑子比你牛,天赋比你高,学习比你卷,干事效率比你高,进步比你快,性格比你好,人际关系比你好,情感比你赢,前途比你广,看不起你罢了,有什么好羡慕的呢?对吧?\"","\"你不能只在你输的时候才想到要努力\"","\"活着是干啥的是应该放在如何活着之前思考的吗?还是说都是毫不值得思考的问题\"","\"把世界幻想得太简单,把自己幻想得太幸运\"","\"日常做题过一个题理应与打比赛过一个题获得相同的成就感。别再执着于面子\"","\"有过过去不代表会有未来\"","\"又有谁会记住自己无心立下的承诺\"""\"积极乐观,不意味着也不应基于忘却乃至回避那段不堪而屈辱的过去\"","\"自信不应当靠虚伪成就\"","\"不要为功利的一丝希望而活,你的人生不止有它,它也不配占据你活着的全部理由\"","\"当你没能达到目标的时候,反思一下你定目标的能力\"","\"渴望改变别人观点使别人认同自己是一件极度愚蠢且自负的行为\"","\"运气在信息学竞赛中没有用,请不要为你水平菜找借口说运气不好\""};struct _OIer{string name, happy;int good, trait;};vector<_OIer> OIer;struct _Contests{string name;int day, tim;vector<int> hard, trait;};vector<_Contests> Contests;int MONEY, WEEK;bool ISADMIN, ISNEW;string NOWSAVE;void mycls(string s = ""){system("cls");}int myToInt(string s){int res = 0, f = 1;for(auto x : s){if(x == '-') f = -1;else res = res * 10 + x - '0';}return f * res;}void GetMoney(int x){MONEY += x;}void turnWeek(){WEEK--; GetMoney(-500);}void NoworkVoid(string s){return;}void mypau(string c, void work(string s) = NoworkVoid){cout << c; system("pause"); work("");}int NoworkInt(string s){return 0;}string NoworkString(string s){return "";}string ReaRes(string s){return s;}bool checkJ(string s, string t, void work(string s)){cout << s << "\n";string c = "\n"; getline(cin, c);work(c);return t == "ALL" || c == t;}bool checkJ(string s, vector<string> t, void work(string s)){cout << s << "\n";string c = "\n"; getline(cin, c);work(c);for(auto x : t)if(c == x) return true;return t == (vector<string>){"ALL"};}int checkJ(string s, string t, int work(string s)){cout << s << "\n";string c = "\n"; getline(cin, c);return work(c);}string checkJ(string s, string t, string work(string s)){cout << s << "\n";string c = "\n"; getline(cin, c);return work(c);}void printH(string s, int del){for(auto x : s){cout << x; Sleep(del);}}void buildSave(string s){NOWSAVE = s + ".OIcoachSave", ISNEW = true;}void Save(string key = "SAVE"){mycls();IORedirector redirect("", NOWSAVE);cout << key << " ";cout << OIer.size() << " ";for(auto [x, y, z, w] : OIer){cout << x << " " << y << " " << z << " " << w << " ";}cout << Contests.size() << " ";for(auto [x, y, z, u, v] : Contests){cout << x << " " << y << " " << z << " ";cout << u.size() << " ";for(auto _ : u) cout << _ << " ";for(auto _ : v) cout << _ << " ";}cout << MONEY << " " << WEEK << " " << ISADMIN << " ";}void loadSave(string s){NOWSAVE = s + ".OIcoachSave";IORedirector redirect(NOWSAVE, "");string c; cin >> c;if(c == "OVER"){mycls();cout << "该存档游戏已结束,无法载入\n\n";exit(0);}else if(c != "SAVE"){mycls();cout << "错误 : 文件 " << NOWSAVE << " 校验码错误,请检查它是否是你的游戏存档\n\n";exit(0);}int n; cin >> n;for(int i = 1; i <= n; i++){string x, y; int z, w;cin >> x >> y >> z >> w;OIer.push_back({x, y, z, w});}int m; cin >> m;for(int i = 1; i <= m; i++){string x; int y, z;cin >> x >> y >> z;vector<int> u, v; int siz;cin >> siz;for(int j = 0; j < siz; j++){int x; cin >> x;u.push_back(x);}for(int j = 0; j < siz; j++){int x; cin >> x;v.push_back(x);}Contests.push_back({x, y, z, u, v});}cin >> MONEY >> WEEK >> ISADMIN;WEEK--;}void checkSave(string s){mycls();if(s == "1"){checkJ("请输入新建存档名:", "ALL", buildSave);mypau("\n创建成功 !\n", mycls);Save();}else if(s == "2"){checkJ("请输入载入存档名:", "ALL", loadSave);mypau("\n载入成功 !\n", mycls);}}void turnUTF(){system("chcp 65001");mycls();}void PrintTime(){cout << "第 " << WEEK << " 周 " ;for(auto [x, y, z, u, v] : Contests){if(WEEK < y){cout << "距离 " << x << " 还有 " << y - WEEK << " 周";break;}}cout << "\n\n";}void PrintMoney(){cout << " 经费 : " << MONEY << " $\n\n";}void PrintShit(){cout << BULLSHIT[mrand() % BULLSHIT.size()] << "\n\n\n";}void PrintOIer(){for(auto [x, y, z, w] : OIer){cout << x << " 压力 : " << y << " 能力 : " << z << "\n\n";}}void InitMoney(){MONEY = 50000;}void InitOIer(){OIer.push_back({"周康阳", "低", 100, int(mrand() % 100 + 1)});OIer.push_back({"许琪文", "低", 100, int(mrand() % 100 + 1)});OIer.push_back({"蒋凌宇", "低", 100, int(mrand() % 100 + 1)});OIer.push_back({"邓明扬", "低", 100, int(mrand() % 100 + 1)});}void InitContest(){Contests.push_back({"CSP-S初赛", 5, 120, (vector<int>){100}, (vector<int>){int(mrand() % 100 + 1)}});}void Init(){InitMoney(); InitOIer(); InitContest();}void Print(){PrintTime(); PrintShit();PrintMoney(); PrintOIer();}```OIcoach.cpp :```cpp// Copyright (C) since 2026 _auto_ / hwz007// All rights reserved#include "library.h"void GameOver(string rea){cout << "\n";if(rea == "student") printH("你没有了学员\n\n游戏结束 !!\n", 50);if(rea == "money") printH("你破产了\n\n游戏结束 !!\n", 50);if(rea == "teacher") printH("你辞职了\n\n游戏结束 !!\n", 50);mypau("\n"); Save("OVER");exit(0);}void AFO(string name){cout << name << " 因为压力过大而退役" << "\n\n";vector<_OIer> newOIer;for(auto [x, y, z, w] : OIer){if(x != name) newOIer.push_back({x, y, z, w});}OIer = newOIer;if(OIer.empty()) GameOver("student");}string nxtHappy(string x, string name){if(x == "低") return "中";if(x == "中") return "高";if(x == "高") return "极高";if(x == "极高") return "爆表";if(x == "爆表") return "爆表";return "";}string nxtLowHappy(string x){if(x == "低") return "低";if(x == "中") return "低";if(x == "高") return "中";if(x == "极高") return "高";return "";}string changeHappy(string x, int y, string name){while(y > 100){x = changeHappy(x, 100, name);y -= 100;}int rnd = mrand() % 100 + 1;if(rnd <= y) x = nxtHappy(x, name);return x;}string changeLowHappy(string x, int y){while(y > 100){x = changeLowHappy(x, 100);y -= 100;}int rnd = mrand() % 100 + 1;if(rnd <= y) x = nxtLowHappy(x);return x;}int changeGood(int x, int y){int rnd = mrand() % 3 + 1;return x + y * rnd;}void checkHappy(int mod){bool canMod = false;while(true){bool flag = false;for(auto [x, y, z, w] : OIer){if(y == "爆表"){flag = true, canMod = true;AFO(x); Sleep(300); break;}}if(!flag) break;}if(mod && canMod) mypau("", mycls);}void checkMoney(){if(MONEY < 0) GameOver("money");}void checkOver(int mod = 0){checkMoney();checkHappy(mod);}int checkPro(string s){return s[0] - '0';}int calcProN(int x){return 20 * x - 10;}int calcProG(int x){return 5 * x;}void Training(){mycls();int cho = checkJ("请选择题目难度 : \n1.入门 2.普及- 3.普及/提高- 4.普及+/提高 5.提高+/省选- 6.省选/NOI- 7.NOI/NOI+/CTSC", "ALL", checkPro);while(cho < 1 || cho > 7){mycls();cho = checkJ("请选择题目难度 : \n1.入门 2.普及- 3.普及/提高- 4.普及+/提高 5.提高+/省选- 6.省选/NOI- 7.NOI/NOI+/CTSC", "ALL", checkPro);}int ProN = calcProN(cho), ProG = calcProG(cho);mycls();for(int i = 1; i <= 6; i++){cout << "训练中";for(int j = 1; j <= i % 3 + 1; j++)cout << ".";cout << "\n";Sleep(150); mycls();}cout << "训练完成 !" << "\n\n";cout << "训练结果 :" << "\n\n";cout << "经费 : " << MONEY << " -> " << (MONEY -= 1000) << "\n\n";Sleep(500);for(int i = 0; i < (int)OIer.size(); i++){auto [x, y, z, w] = OIer[i];cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeHappy(y, ProN, x)) << " 能力 : " << OIer[i].good << " -> " << (OIer[i].good = changeGood(z, ProG)) << "\n\n";Sleep(200);}checkOver();mypau("", mycls);}void Camp(){int newMoney = MONEY;vector<_OIer> bx;for(auto [x, y, z, w] : OIer){mycls();cout << "请选择参加集训的人员 : " << "\n\n";cout << x << " 压力 : " << y << " 能力 : " << z << "\n";cout << "你希望 " << x << " 参加集训吗 ( 希望请输入 'Y' 或 'y' ) 预计剩余经费 : " << MONEY << " -> " << newMoney - 10000 << "\n";string cho = checkJ("", "ALL", ReaRes);if(cho == "Y" || cho == "y"){newMoney -= 10000;bx.push_back({x, y, z, w});}}mycls();for(int i = 1; i <= 6; i++){cout << "集训中";for(int j = 1; j <= i % 3 + 1; j++)cout << ".";cout << "\n";Sleep(150); mycls();}cout << "集训完成 !" << "\n\n";cout << "集训结果 :" << "\n\n";cout << "经费 : " << MONEY << " -> " << (MONEY = newMoney) << "\n\n";Sleep(500);for(auto [x, y, z, w] : bx){for(int i = 0; i < (int)OIer.size(); i++){if(OIer[i].name != x) continue;cout << x << " 压力 : " << y << " -> " << (OIer[i].happy = changeHappy(y, 250, x)) << " 能力 : " << z << " -> " << (OIer[i].good = changeGood(z, 50)) << "\n\n";Sleep(200); break;}}checkOver();mypau("", mycls);}void Competition(){mycls();cout << "功能仍在开发中哟~" << "\n";mypau("", mycls); turnWeek();}void Entertainment(){mycls();for(int i = 1; i <= 6; i++){cout << "娱乐中";for(int j = 1; j <= i % 3 + 1; j++)cout << ".";cout << "\n";Sleep(150); mycls();}cout << "娱乐完成 !" << "\n\n";cout << "娱乐结果 :" << "\n";for(int i = 0; i < (int)OIer.size(); i++){auto [x, y, z, w] = OIer[i];cout << x << " 压力 : " << OIer[i].happy << " -> " << (OIer[i].happy = changeLowHappy(y, 120)) << "\n\n";Sleep(200);}mypau("", mycls);}void Quit(){mycls();string cho = checkJ("确认辞职吗 ( 确认请输入 'Y' 或 'y' )", "ALL", ReaRes);if(cho == "Y" || cho == "y"){mycls();GameOver("teacher");}else{turnWeek();}}void ChangeMoney(string x){MONEY = myToInt(x);mypau("\n修改完成 ! \n\n", mycls);}void ChangeWeek(string x){WEEK = myToInt(x);mypau("\n修改完成 ! \n\n", mycls);}bool NotFindHappy(string s){if(s == "低") return false;if(s == "中") return false;if(s == "高") return false;if(s == "极高") return false;if(s == "爆表") return false;return true;}void ChangeOIer(string id){mycls();int zid = myToInt(id);if(zid < 1 || zid > (int)OIer.size()){mypau("\n错误 : 未找到该 OIer\n\n", mycls);return;}cout << OIer[zid - 1].name << " 原压力 : " << OIer[zid - 1].happy << " 原能力 : " << OIer[zid - 1].good << "\n\n";string newHappy = checkJ("\n你要将 " + OIer[zid - 1].name + " 的压力值改为 : ", "ALL", ReaRes);int newGood = myToInt(checkJ("\n你要将 " + OIer[zid - 1].name + " 的能力值改为 : ", "ALL", ReaRes));if(NotFindHappy(newHappy)){mypau("\n错误 : 压力值输入错误\n\n", mycls);return;}OIer[zid - 1].happy = newHappy;OIer[zid - 1].good = newGood;mypau("\n修改完成 ! \n\n", mycls);checkOver(1);}void DeMoney(){mycls();checkJ("\n你要将 MONEY 修改为 : ", "ALL", ChangeMoney);}void DeWEEK(){mycls();checkJ("\n你要将 WEEK 修改为 : ", "ALL", ChangeWeek);}void DeOIer(){mycls();int cnt = 0;for(auto [x, y, z, w] : OIer){cout << ++cnt << ". " << x << " 压力 : " << y << " 能力 : " << z << "\n\n";}checkJ("你要将谁的数据修改 ( 输入编号 ) : ", "ALL", ChangeOIer);}void checkDe(string s){if(s == "1") DeMoney();else if(s == "2") DeWEEK();else if(s == "3") DeOIer();turnWeek();}void checkPass(string s){if(s == PASSWORD){ISADMIN = true; mycls();checkJ("请选择要修改的数据: \n1.MONEY 2.WEEK 3.OIer_data 4.退出", "ALL", checkDe);}else{mycls(); mypau("密码错误!\n\n", mycls);turnWeek();}}void Debug(){mycls();if(!ISADMIN)checkJ("请输入管理员密码: ", "ALL", checkPass);elsecheckJ("请选择要修改的数据: \n1.MONEY 2.WEEK 3.OIer_data 4.退出", "ALL", checkDe);}void Log(){mycls();cout << SAVE << "当前版本 : " << NOW_V;for(auto x : UPDATE_DAILY)cout << x;mypau("", mycls); turnWeek();}void _Quit(){mycls(); exit(0);}void checkit(string s){if(s == "1") Training();else if(s == "2") Camp();else if(s == "3") Competition();else if(s == "4") Entertainment();else if(s == "5") Quit();else if(s == "6") Debug();else if(s == "7") Log();else if(s == "8") _Quit();else turnWeek();}int checkCont(){for(int i = 0; i < Contests.size(); i++){auto [x, y, z, u, v] = Contests[i];if(WEEK == y) return i;}return -1;}void PrintContest(string name, int tim, int ntim, int sizn, int sizm, vector<vector<int>> sc){mycls();cout << name << " " << ntim << " / " << tim << " min\n\n ";for(int j = 0; j < sizm; j++)cout << "T" << j + 1 << " ";cout << "\n";for(int j = 0; j < sizn; j++){auto [x, y, z, w] = OIer[j];cout << x << " ";for(int k = 1; k <= 6 - (int)x.size() / 3; k++)cout << " ";for(auto u : sc[j]) cout << u << " ";cout << "\n";}Sleep(200);}void Contest(int id){auto [name, day, tim, hard, trait] = Contests[id];int sizn = OIer.size(), sizm = hard.size();vector<vector<int>> sc(sizn);for(int i = 0; i < sizn; i++){sc[i].resize(sizm);}vector<int> cho(sizn);vector<int> lst(sizn);vector<double> pw(sizn, 1);for(int i = 5; i <= tim; i += 5){PrintContest(name, tim, i, sizn, sizm, sc);for(int j = 0; j < sizn; j++){auto [x, y, z, w] = OIer[j];int u = hard[cho[j]];int v = trait[cho[j]];lst[j] += 5;int p = 0.00002L * (100 - mrand() % 50) * z / u * lst[j] * ((w ^ v) + 50) * pw[j];sc[j][cho[j]] = min(100, sc[j][cho[j]] + p);if(sc[j][cho[j]] == 100){cho[j] = mrand() % sizm;lst[j] = 0;}pw[j] = pw[j] * 0.97;}}mypau("");}void GameLoop(){Save();int posCont = checkCont();if(posCont != -1){Contest(posCont);}else{Print();if(MONEY > 10000)checkJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 ~ " + to_string(10000 * min(MONEY / 10000, (int)OIer.size())) + " $) 3.比赛(开发中) 4.娱乐 5.辞职 6.调试工具 7.更新日志 8.退出", "ALL", checkit);elsecheckJ("请选择:\n1.训练 (-1000 $) 2.集训 (-10000 $) 3.比赛(开发中) 4.娱乐 5.辞职 6.调试工具 7.更新日志 8.退出", "ALL", checkit);GetMoney(500); checkOver();}}void Story(){printH("[背景故事] 你是一名 OI 教练...\n\n", 50);mypau("", mycls);}int main(){turnUTF();mypau("OI 教 练 模 拟 器\n\n", mycls);while(!checkJ("请选择:\n1.新建存档 2.载入存档", (vector<string>){"1", "2"}, checkSave))mycls();if(ISNEW){Init(); Story();}while(++WEEK) GameLoop();return 0;}```123456789101112131415V 0.4.1 版本将 `OIcoach.cpp` , `Library.h` 和 `Tools.h` 放在同一个文件夹内然后运行 `OIcoach.cpp` 即可.编译系统要求 C++17 及以上,Windows 系统.:::warning[如果你遇到中文乱码]请检查你的编辑器是否使用 UTF-8 编码保存文件。如果不是,可以向 AI 询问解决方法。:::[Tools.h](https://www.luogu.me/article/mxymkmrh)[Library.h](https://www.luogu.me/article/ugnc4dvz)[OIcoach.cpp](https://www.luogu.me/article/7p0n9ovf)