Library.h
_auto_
·
·
个人记录
// Copyright (C) since 2026 _auto_ / hwz007
// All rights reserved
#include "Tools.h"
struct _OIer{
string name, happy;
int good, trait;
vector<int> skills;
};
vector<_OIer> OIer;
vector<int> scofNOIP;
struct _Contests{
string name;
int day, tim;
vector<int> hard, trait;
};
vector<_Contests> Contests;
struct _Cutoff{
string name, rea;
int val;
};
vector<_Cutoff> Cutoff;
int MONEY, WEEK;
bool ISADMIN, ISNEW;
string NOWSAVE;
void mycls(string s = ""){system("cls");}
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);
}
bool checkS(int x, int y){
for(auto u : OIer[x].skills)
if(u == y) return true;
return false;
}
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, s] : OIer){
cout << x << " " << y << " " << z << " " << w << " ";
cout << s.size() << " ";
for(auto u : s) cout << u << " ";
}
for(auto x : scofNOIP) cout << x << " ";
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 << _ << " ";
}
for(auto [x, y, z] : Cutoff){
cout << x << " " << y << " " << z << " ";
}
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;
int siz; vector<int> s;
cin >> siz;
for(int j = 1; j <= siz; j++){
int u; cin >> u;
s.push_back(u);
}
OIer.push_back({x, y, z, w, s});
}
for(int i = 1; i <= n; i++){
int x; cin >> x;
scofNOIP.push_back(x);
}
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});
}
for(int i = 1; i <= m; i++){
string x, y; int val;
cin >> x >> y >> val;
Cutoff.push_back({x, y, val});
}
cin >> MONEY >> WEEK >> ISADMIN;
}
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 GameOver(string rea){
cout << "\n";
if(rea == "student") printH("你没有了学员\n\n游戏结束 !!\n", 30);
if(rea == "money") printH("你破产了\n\n游戏结束 !!\n", 30);
if(rea == "teacher") printH("你辞职了\n\n游戏结束 !!\n", 30);
mypau("\n"); Save("OVER");
exit(0);
}
void AFO(string name, string rea){
cout << name << " 因为" << rea << "而退役" << "\n\n";
vector<_OIer> newOIer;
vector<int> newscofNOIP;
for(int i = 0; i < OIer.size(); i++){
auto [x, y, z, w, s] = OIer[i];
if(x != name){
newOIer.push_back({x, y, z, w, s});
newscofNOIP.push_back(scofNOIP[i]);
}
}
OIer = newOIer;
scofNOIP = newscofNOIP;
if(OIer.empty()) GameOver("student");
}
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";}
string PrintHappy(string s){
if(s == "低") return Color::green + s + Color::reset;
if(s == "中") return Color::yellow + s + Color::reset;
if(s == "高") return Color::bold + Color::red + s + Color::reset;
if(s == "极高") return Color::red + s + Color::reset;
if(s == "爆表") return Color::red + s + Color::reset;
return "";
}
void PrintOIer(){
for(auto [x, y, z, w, s] : OIer){
cout << x << " 压力 : " << PrintHappy(y) << " 能力 : " << z << "\n";
for(auto u : s) cout << Color::bold << "[" << SKILL[u - 1] << "]" << Color::reset << " ";
cout << "\n\n";
}
}
void InitMoney(){MONEY = 50000;}
void InitWeek(){WEEK = 1;}
void InitOIer(){
OIer.push_back({"周康阳", "低", 100, int(mrand() % 100 + 1), {1}});
OIer.push_back({"许琪文", "低", 100, int(mrand() % 100 + 1), {2}});
OIer.push_back({"蒋凌宇", "低", 100, int(mrand() % 100 + 1), {3}});
OIer.push_back({"邓明扬", "低", 100, int(mrand() % 100 + 1), {4}});
scofNOIP.resize(OIer.size());
}
void InitContest(){
Contests.push_back({"CSP-S初赛", 5, 120, (vector<int>){200}, (vector<int>){int(mrand() % 100 + 1)}});
Contests.push_back({"CSP-S复赛", 9, 240, (vector<int>){60, 120, 180, 320}, (vector<int>){int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1)}});
Contests.push_back({"NOIP", 13, 270, (vector<int>){80, 160, 200, 360}, (vector<int>){int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1)}});
Contests.push_back({"省选", 18, 600, (vector<int>){180, 240, 380, 220, 260, 340}, (vector<int>){int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1)}});
Contests.push_back({"NOI", 25, 600, (vector<int>){10, 200, 280, 440, 240, 260, 480}, (vector<int>){int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1), int(mrand() % 100 + 1)}});
Cutoff.push_back({"CSP-S复赛晋级线:", "未晋级CSP-S复赛", 55 + (int)mrand() % 10});
Cutoff.push_back({"NOIP晋级线:", "未晋级NOIP", 170 + (int)mrand() % 20});
Cutoff.push_back({"NULL", "NULL", 0});
Cutoff.push_back({"省队队线(7.5%NOIP+11.7%省选分数):", "未进入省队", 75 + (int)mrand() % 5});
Cutoff.push_back({"NOI国集线:", "未进入国集", 550 + (int)mrand() % 20});
}
void Init(){
InitMoney(); InitWeek();
InitOIer(); InitContest();
}
void Print(){
PrintTime(); PrintShit();
PrintMoney(); PrintOIer();
}
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<double>> sc, vector<vector<int>> psc, vector<int> cho){
mycls();
cout << name << " " << ntim << " / " << tim << " min\n\n ";
for(int i = 0; i < sizm; i++){
cout << setw(6) << "T" << i + 1;
}
cout << "\n";
for(int i = 0; i < sizn; i++){
auto [x, y, z, w, s] = OIer[i];
cout << x;
for(int j = 1; j <= 5 - x.size() / 3; j++)
cout << " ";
for(int j = 0; j < sizm; j++){
for(int k = psc[j].size() - 1; k >= 0; k--){
if(sc[i][j] >= psc[j][k]){
if(j == cho[i]) cout << Color::bold;
string s = to_string(psc[j][k]);
s.insert(0, 7 - s.size(), ' ');
if(psc[j][k] == 0)
cout << Color::reset << s << Color::reset;
else if(psc[j][k] < 30)
cout << Color::red << s << Color::reset;
else if(psc[j][k] < 70)
cout << Color::yellow << s << Color::reset;
else
cout << Color::green << s << Color::reset;
if(j == cho[i]) cout << Color::reset;
break;
}
}
}
cout << "\n";
}
Sleep(200);
}
void Jump(int id, int u, int sizm, vector<vector<double>> sc, vector<int>& cho, vector<int>& lst){
vector<pii> h;
int sum = 0;
for(int i = 0; i < sizm; i++){
sum += sqrt(u) * (100 - sc[id][i]);
if(i != cho[id]) h.push_back({sum, i});
}
if(sum == 0) return;
int mcho = mrand() % sum;
for(int i = 0; i < h.size(); i++){
auto [s, k] = h[i];
if(mcho < s){
cho[id] = k, lst[id] *= 0.6;
return;
}
}
}
void Win(){
for(auto [x, y, z, w, s] : OIer){
printH(x + " 进入了国集 !\n\n", 30);
}
mypau("\n"); mycls();
printH("你的学员进入了国集,你是一名优秀的教练 !\n\n游戏胜利 !!\n", 30);
mypau("\n"); Save("OVER"); exit(0);
}
void Contest(int id){
auto [name, day, tim, hard, trait] = Contests[id];
int sizn = OIer.size(), sizm = hard.size();
vector<vector<double>> 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);
vector<vector<int>> psc(sizm);
for(int i = 0; i < sizm; i++){
int task = mrand() % 2 ? 5 : 4;
int sizt = mrand() % 5 + 4;
vector<int> tasks;
tasks.push_back(0);
tasks.push_back(100);
for(int j = 1; j <= sizt; j++){
tasks.push_back(mrand() % (100 / task) * task);
}
sort(tasks.begin(), tasks.end());
tasks.erase(unique(tasks.begin(), tasks.end()), tasks.end());
psc[i] = tasks;
}
for(int i = 0; i < sizn; i++){
if(checkS(i, 4)) pw[i] = 0.6;
else pw[i] = 1;
}
for(int i = 5; i <= tim; i += 5){
PrintContest(name, tim, i, sizn, sizm, sc, psc, cho);
for(int j = 0; j < sizn; j++){
auto [x, y, z, w, s] = OIer[j];
int u = hard[cho[j]];
int v = trait[cho[j]];
lst[j] += 5;
double traitS = (checkS(j, 1) ? (w ^ v) * 0.3 + 250 : (w ^ v) + 150);
double p = 0.00004L * (100 - mrand() % 50) * sqrt(1.0 * z / u) * (log(lst[j]) * log(lst[j])) * traitS * pw[j];
if(checkS(j, 2)){
if(mrand() % 100 <= 20.0 * lst[j] / tim * max(1.0, 1.0 + 1.0 * (i - tim / 2) / tim))
p += 100;
else p *= 0.5;
}
sc[j][cho[j]] = min(100.0, sc[j][cho[j]] + p);
if(sc[j][cho[j]] == 100 || mrand() % 100 <= (checkS(j, 2) ? 10.0 : 30.0) * lst[j] / tim)
Jump(j, u, sizm, sc, cho, lst);
pw[j] = pw[j] * (checkS(j, 4) ? 1.01 : 0.97);
}
}
mypau("\n");
if(id == 2){ // NOIP
for(int i = 0; i < sizn; i++){
int sum = 0;
for(int j = 0; j < sizm; j++){
for(int k = psc[j].size() - 1; k >= 0; k--){
if(sc[i][j] >= psc[j][k]){
sum += psc[j][k]; break;
}
}
}
scofNOIP[i] = sum;
}
}else{
auto [_name, rea, val] = Cutoff[id];
cout << "\n" << _name << val << "\n\n";
bool flag = true;
while(flag){
flag = false;
for(int i = 0; i < sizn; i++){
int sum = 0;
for(int j = 0; j < sizm; j++){
for(int k = psc[j].size() - 1; k >= 0; k--){
if(sc[i][j] >= psc[j][k]){
sum += psc[j][k]; break;
}
}
}
double lstsc = sum;
if(id == 3)
lstsc = 0.117 * sum + 0.075 * scofNOIP[i]; // 省选
if(lstsc < val){
AFO(OIer[i].name, rea), Sleep(200);
flag = true, sizn--; break;
}
}
}
mypau("\n");
if(id == 4) Win(); // NOI
}
}
void checkMoney(){if(MONEY < 0) GameOver("money");}
int checkPro(string s){return s[0] - '0';}
int calcProN(int x){return 20 * x - 10;}
int calcProG(int x){return 5 * x;}
string nxtHappy(string x){
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){
string sx = x;
while(y > 100){
x = changeHappy(x, 100, name);
y -= 100;
}
int rnd = mrand() % 100 + 1;
if(rnd <= y) x = nxtHappy(x);
if((sx == "低" || sx == "中") && x == "爆表") x = "极高";
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, bool b){
int rnd = mrand() % (b ? 5 : 3) + 1;
return x + y * rnd;
}
void checkHappy(int mod){
bool canMod = false;
while(true){
bool flag = false;
for(auto [x, y, z, w, s] : OIer){
if(y == "爆表"){
flag = true, canMod = true;
AFO(x, "压力过大"); Sleep(300); break;
}
}
if(!flag) break;
}
if(mod && canMod) mypau("", mycls);
}
void checkOver(int mod = 0){
checkMoney();
checkHappy(mod);
}