#include<bits/stdc++.h>#define get(X); std::cin>>X;
#define endl '\n'#define echo(S); std::cout<<S<<endl;
#ifdef _WIN32#define clscr; system("cls");
#else#define clscr; system("clear");
#endif#define tpdf types::difficulty
void hear()
{
std::string sfffffff;
getline(std::cin,sfffffff);
}
bool vis[105];
int tmp[105];
namespace types
{
bool sym;
char difficulty;
int level;
int points;
int hp,dp,is,st,gp,ct;
void set_level()
{
switch(difficulty)
{
case 'A':{level=1;break;}
case 'B':{level=3;break;}
case 'C':{level=5;break;}
case 'D':{level=10;break;}
case 'P':{level=0;break;}
default:{level=1e9;break;}
}
points=30;
if(level>=1)points-=5;
if(level>=3)points-=5;
if(level>=10)points-=5;
hp=12;
if(level==0)
{
hp=dp=is=st=gp=ct=9999;
}
}
void echo_types()
{
//clscr;std::cout<<"level : "<<level<<endl<<"heartpoints : "<<hp<<endl<<"dp : "<<dp<<" | data-structure : "<<is<<" | string : "<<st<<" | graph : "<<gp<<" | counting : "<<ct<<endl;
}
}
struct _event
{
char describe[105];
int effect;
bool direct;
int effective;
bool mysterious;
void write()
{
using namespace types;
using namespace std;
cout<<describe;
if(mysterious)
{
cout<<"(???)\n";
return;
}
cout<<" (choosing this to make the ";
if(level==0)direct=!direct;
switch(effect)
{
case 0:{cout<<"cultural courses";break;}
case 1:{cout<<"dp";break;}
case 2:{cout<<"data-structure";break;}
case 3:{cout<<"string";break;}
case 4:{cout<<"graph";break;}
case 5:{cout<<"counting";break;}
case 6:{cout<<"heartpoints";break;}
case 8:{cout<<"algorithms";break;}
}
if(direct)cout<<"+";
else cout<<"-";
if(level==0)direct=!direct;
cout<<effective<<")\n";
}
void ef()
{
using namespace types;
using namespace std;
if(effect==9)cout<<"%%%,";
cout<<"your ";
if(level==0)direct=!direct;
if(!direct)effective=-effective;
switch(effect)
{
case 0:{cout<<"cultural courses";break;}
case 1:{cout<<"dp";dp+=effective;break;}
case 2:{cout<<"data-structure";is+=effective;break;}
case 3:{cout<<"string";st+=effective;break;}
case 4:{cout<<"graph";gp+=effective;break;}
case 5:{cout<<"counting";ct+=effective;break;}
case 6:{cout<<"heartpoints";hp+=effective;break;}
case 7:{cout<<"all";dp+=effective;is+=effective;st+=effective;gp+=effective;ct+=effective;hp+=effective;break;}
case 8:{cout<<"algorithms";dp+=effective;is+=effective;st+=effective;gp+=effective;ct+=effective;break;}
case 9:{cout<<"rp";dp+=effective;is+=effective;st+=effective;gp+=effective;ct+=effective;break;}
}
if(direct)cout<<"+";
else cout<<"-",effective=-effective;
if(level==0)direct=!direct;
cout<<effective<<"\n";
hear();
}
};
_event contest[105],training[105],article[105],relaxing[105],anxious[105],forgetting[105];
std::string names[105];
int cnt_contest,cnt_training,cnt_article,cnt_relaxing,cnt_anxious,cnt_forgetting,cnt_names;
void set_events()
{
int i=0;
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",1,1,2,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",2,1,2,1};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",4,1,2,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",5,1,2,1};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",6,0,1,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",1,1,2,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",1,1,3,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",2,1,1,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",2,1,2,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",3,1,1,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",4,1,2,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",4,1,3,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",6,0,1,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,3,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",2,1,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",1,1,3,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",3,1,2,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,0,3,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,1,2,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,1,1,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",3,1,0,1};
contest[++i]=(_event){"you have heard SPOJ, and want to engage in\0",1,1,1,0};
contest[++i]=(_event){"you have heard SPOJ, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,0,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",1,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",2,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",2,1,4,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",3,1,6,1};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",1,1,2,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",2,1,2,1};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",4,1,2,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",5,1,2,1};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",6,0,1,0};
contest[++i]=(_event){"you have heard ATCODER, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",1,1,2,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",1,1,3,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",2,1,1,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",2,1,2,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",3,1,1,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",4,1,2,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",4,1,3,1};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",6,0,1,0};
contest[++i]=(_event){"you have heard CODEFORCES, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,3,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",2,1,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",1,1,3,1};
contest[++i]=(_event){"you have heard LUOGU, and want to engage in\0",3,1,2,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,0,3,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,1,2,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",6,1,1,1};
contest[++i]=(_event){"you have heard UOJ, and want to engage in\0",3,1,1,1};
contest[++i]=(_event){"you have heard SPOJ, and want to engage in\0",1,1,1,0};
contest[++i]=(_event){"you have heard SPOJ, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,0,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,0,2,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",6,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",1,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",2,1,1,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",2,1,4,1};
contest[++i]=(_event){"you have heard TEAM CONTEST, and want to engage in\0",3,1,6,1};
contest[++i]=(_event){"you have heard ???, and want to engage in\0",7,1,4,1};
cnt_contest=i;
i=0;
training[++i]=(_event){"training dp\0",1,1,2,0};
training[++i]=(_event){"training data-structure\0",2,1,2,0};
training[++i]=(_event){"training string\0",3,1,2,0};
training[++i]=(_event){"training graph\0",4,1,2,0};
training[++i]=(_event){"training counting\0",5,1,2,0};
training[++i]=(_event){"training cultural courses\0",0,1,4,0};
training[++i]=(_event){"training dp\0",1,1,6,0};
training[++i]=(_event){"training data-structure\0",2,1,6,0};
training[++i]=(_event){"training string\0",3,1,8,0};
training[++i]=(_event){"training graph\0",4,1,6,0};
training[++i]=(_event){"training counting\0",5,1,8,0};
training[++i]=(_event){"training cultural courses\0",0,1,4,0};
training[++i]=(_event){"training algorithms\0",8,1,2,0};
cnt_training=i;
i=0;
article[++i]=(_event){"reading EricWan's article\0",9,1,4,1};
article[++i]=(_event){"reading EricWan's article\0",4,1,3,1};
article[++i]=(_event){"reading EricWan's article\0",2,1,2,1};
article[++i]=(_event){"reading EricWan's article\0",6,0,1,1};
article[++i]=(_event){"reading EricWan's article\0",6,0,3,1};
article[++i]=(_event){"reading Wuyuzhe123's article\0",9,1,4,1};
article[++i]=(_event){"reading Wuyuzhe123's article\0",5,1,3,1};
article[++i]=(_event){"reading Wuyuzhe123's article\0",6,0,2,1};
article[++i]=(_event){"reading Wuyuzhe123's article\0",2,1,2,1};
article[++i]=(_event){"reading Wuyuzhe123's article\0",1,1,2,1};
article[++i]=(_event){"reading The Author's article\0",8,0,1,1};
cnt_article=i;
i=0;
names[++i]="train";
names[++i]="explode";
names[++i]="explore";
names[++i]="turn";
names[++i]="arena";
names[++i]="translate";
names[++i]="AAA";
names[++i]="responsibility";
cnt_names=i;
i=0;
}
struct _problem
{
std::string name;
int cnt_subtask;
int scores[15];
int cur[15];
int maxn[15];
int first,second;
int diff;
int diff_f,diff_s;
int score;
double k[15];
void producting(int difficulty)
{
memset(cur,0,sizeof(cur));
diff=difficulty;
srand(rand());
name=names[rand()%cnt_names+1];
cnt_subtask=rand()%4+1;
int tmp=rand()%5+1;
switch(tmp)
{
case 1:
{
score=4;
break;
}
case 2:
{
score=5;
break;
}
case 3:
{
score=10;
break;
}
case 4:
{
score=20;
break;
}
case 5:
{
score=2;
break;
}
}
first=rand()%5+1;
srand(rand());
second=rand()%5+1;
while(second==first)
{
srand(rand());
second=rand()%5+1;
}
diff_f=difficulty+5;
diff_s=difficulty/2;
tmp=0;
int ss[6];
using namespace types;
using namespace std;
ss[1]=dp;ss[2]=is;ss[3]=st;ss[4]=gp;ss[5]=ct;
for(int i=1;i<cnt_subtask;i++)
{
srand(rand());
tmp=tmp+rand()%(100/score-tmp-cnt_subtask+i)+1;
scores[i]=score*tmp;
maxn[i]=max(max((diff_f-((100-scores[i])/score)-ss[first]),(diff_s-((100-scores[i])/score)-ss[second])),1);
}
maxn[cnt_subtask]=max(max((diff_f-ss[first]),(diff_s-ss[second])),1);
scores[cnt_subtask]=100;
}
void write()
{
using namespace std;
using namespace types;
echo(name);
cout<<"debug:"<<first<<":"<<diff_f<<" "<<second<<":"<<diff_s<<endl;
for(int i=1;i<=cnt_subtask;i++)
{
cout<<(char)('A'+i-1)<<".";
cout<<"subtask"<<i<<":"<<scores[i]<<"pts\n";
cout<<min(cur[i],maxn[i])<<"/"<<maxn[i]<<" (";
k[i]=100;
k[i]-=100/types::hp;
k[i]-=1*(maxn[i]-2);
cout<<(int)k[i]<<"%)\n";
echo("");
}
}
void clear()
{
name="";
cnt_subtask=first=second=diff=diff_f=diff_s=score=0;
memset(scores,0,sizeof(scores));
memset(cur,0,sizeof(cur));
}
}problems[105];
void set_origin()
{
std::string double_check;
int times=0;
do
{
times++;
using namespace types;
using namespace std;
if(times>10)
{
clscr;
cerr<<"ERROR\nGAME EXIT...\n";
exit(0);
}
clscr;
int sum=0;
for(int i=1;i<=5;i++)
{
echo("please give your original value of the bottom variable:");
cout<<"you have "<<points-sum<<" points to define your original value"<<endl;
cout<<"dp ";
if(i > 1)cout<<": "<<dp<<" ";
cout<<"| data-structure ";
if(i > 2)cout<<": "<<is<<" ";
cout<<"| string ";
if(i > 3)cout<<": "<<st<<" ";
cout<<"| graph ";
if(i > 4)cout<<": "<<gp<<" ";
cout<<"| counting ";
if(i > 5)cout<<": "<<ct<<" ";
cout<<endl;
switch (i)
{
case 1:
{
echo("now value \"dp\"");
cin>>dp;
sum+=dp;
hear();
break;
}
case 2:
{
echo("now value \"data-structure\"");
cin>>is;
sum+=is;
hear();
break;
}
case 3:
{
echo("now value \"string\"");
cin>>st;
sum+=st;
hear();
break;
}
case 4:
{
echo("now value \"graph\"");
cin>>gp;
sum+=gp;
hear();
break;
}
case 5:
{
echo("now value \"counting\"");
cin>>ct;
sum+=ct;
hear();
break;
}
}
if(sum>points)
{
clscr;
echo("you can\'t add too much.");
hear();
i=0;
sum=0;
}
clscr;
}
if(sum<points)
{
clscr;
echo("it\'s not reach the highest points value, are you sure?");
echo("type \"YES\" to check over, or type anything to try again");
double_check="";
get(double_check);
hear();
if(double_check!="YES")continue;
}
clscr;
double_check="";
echo("double checking:");
echo("your choice is:");
cout<<"dp : "<<dp<<" | data-structure : "<<is<<" | string : "<<st<<" | graph : "<<gp<<" | counting : "<<ct<<endl;
echo("type \"OK\" to check over, or type anything to try again");
get(double_check);hear();
}
while(double_check!="OK");
}
void event_contest()
{
using namespace std;
types::echo_types();
echo("training contest");
memset(vis,0,sizeof(vis));
memset(tmp,0,sizeof(tmp));
//contest[69].write();for(int i=1;i<=3;i++)
{
cout<<(char)('A'-1+i)<<'.';
do
{
srand(rand());
tmp[i]=rand()%cnt_contest+1;
}
while(vis[tmp[i]]);
vis[tmp[i]]=1;
if(tmp[i]<=cnt_contest/2)vis[tmp[i]+34]=1;
else if(tmp[i]<=cnt_contest-1)vis[tmp[i]-34]=1;
//cout<<tmp[i]<<endl;
contest[tmp[i]].write();
}
char choice;
get(choice);
hear();
while(choice>'C'||choice<'A')
{
clscr;
cout<<"error, press enter to type again\n";
hear();
clscr;
types::echo_types();
echo("training contest");
for(int i=1;i<=3;i++)
{
cout<<(char)('A'-1+i)<<'.';
contest[tmp[i]].write();
}
get(choice);
hear();
}
int k=choice-'A'+1;
contest[tmp[k]].ef();
}
bool tr_flag=0;
void event_training()
{
using namespace std;
types::echo_types();
echo("training");
memset(vis,0,sizeof(vis));
memset(tmp,0,sizeof(tmp));
int N;
if(!tr_flag)N=cnt_training/2+1;
else N=cnt_training/2;
for(int i=1;i<=5;i++)
{
cout<<(char)('A'-1+i)<<'.';
do
{
srand(rand());
tmp[i]=rand()%N+1;
}
while(vis[tmp[i]]);
vis[tmp[i]]=1;
//cout<<tmp[i]<<endl;if(!tr_flag)tmp[i]+=cnt_training/2;
training[tmp[i]].write();
}
char choice;
get(choice);
hear();
while(choice>'E'||choice<'A')
{
clscr;
cout<<"error, press enter to type again\n";
hear();
clscr;
types::echo_types();
echo("training");
for(int i=1;i<=5;i++)
{
cout<<(char)('A'-1+i)<<'.';
training[tmp[i]].write();
}
get(choice);
hear();
}
int k=choice-'A'+1;
training[tmp[k]].ef();
tr_flag=1;
}
void event_article()
{
using namespace std;
types::echo_types();
echo("reading articles");
memset(vis,0,sizeof(vis));
memset(tmp,0,sizeof(tmp));
for(int i=1;i<=4;i++)
{
cout<<(char)('A'-1+i)<<'.';
do
{
srand(rand());
tmp[i]=rand()%cnt_article+1;
}
while(vis[tmp[i]]);
vis[tmp[i]]=1;
//cout<<tmp[i]<<endl;
article[tmp[i]].write();
}
char choice;
get(choice);
hear();
while(choice>'D'||choice<'A')
{
clscr;
cout<<"error, press enter to type again\n";
hear();
clscr;
types::echo_types();
echo("reading articles");
for(int i=1;i<=4;i++)
{
cout<<(char)('A'-1+i)<<'.';
article[tmp[i]].write();
}
get(choice);
hear();
}
int k=choice-'A'+1;
article[tmp[k]].ef();
}
void event()
{
//types::echo_types();srand(time(NULL));
int N=3;
int etype=rand()%N+1;
switch(etype)
{
case 1:
{
event_contest();
break;
}
case 2:
{
event_training();
break;
}
case 3:
{
event_article();
break;
}
}
}
void problem(int difficulty,int k)
{
problems[k].clear();
problems[k].producting(difficulty*2);
}
void competition(std::string name,int difficulty)
{
using namespace std;
if(difficulty<5)
{
int score[5]={0};
problem(difficulty,1);
problem(difficulty*2,2);
problem(difficulty*4,3);
problem(difficulty*6,4);
int time=max(difficulty*5+5,20);
while(time)
{
clscr;
types::echo_types();
echo(name);
cout<<"time lasting..."<<time--<<endl;
cout<<"T1:";problems[1].write();
cout<<"T2:";problems[2].write();
cout<<"T3:";problems[3].write();
cout<<"T4:";problems[4].write();
echo("now you can choose and think one problem, type 1,2,3,4 to choose which you want, or type \"F\" give up");
char choice;
char c;
int t;
cin>>c;
hear();
if(c>48&&c<=52)t=c-48;
else if(c=='F')break;
else
{
clscr;echo("error, press enter and type again");time++;hear();continue;
}
echo("now choose the subtask you want to think, or type \"F\" back to last page");
cin>>choice;
hear();
if(choice=='F'){time++;continue;}
if(choice<'A'||choice>'A'+problems[t].cnt_subtask-1){clscr;echo("error, press enter and type again");time++;hear();continue;}
int tmp=choice-'A'+1;
tmp=problems[t].k[tmp]*10;
srand(rand());
int random=rand()%1000;
if(random<tmp)
{
echo("Thinking Succeeded!");
for(int i=1;i<=choice-'A'+1;i++)
{
problems[t].cur[i]++;
if(problems[t].cur[i]==problems[t].maxn[i])score[t]=problems[t].scores[i];
}
}
else
{
echo("Thinking Failed");
}
hear();
}
echo("your score is...");
int tot=0;
for(int i=1;i<=4;i++)
{
cout<<score[i]<<endl;
tot+=score[i];
}
cout<<"total:"<<tot<<endl;
hear();
return;
}
else
{
//cout<<;
}
}
void events()
{
for(int round=1;round <= 2;round++)
{
for(int i=1;i<=7;i++)
{
clscr;
echo("csp-s is coming!");
event();
}
clscr;
echo("csp-s is coming!");
//event_shop();competition("CSP-S",1);
}
}
int main()
{
set_events();
clscr;
echo("press enter to start the game");
hear();
clscr;
echo("choose your difficulty")
echo("A. EZ");
echo("B. NR");
echo("C. HD");
echo("D. EP");
get(tpdf);hear();
while(tpdf!='k'&&tpdf!='P'&&(tpdf<'A'||tpdf>'D'))
{
clscr;
echo("error, press enter to type again");
hear();
clscr;
echo("choose your difficulty")
echo("A. EZ");
echo("B. NR");
echo("C. HD");
echo("D. EP");
get(tpdf);hear();
}
if(tpdf=='P')
{
clscr;
echo("how do you know that?");
hear();
}
types::set_level();
if(tpdf!='k'&&tpdf!='P')set_origin();
else if(tpdf!='k')
{
clscr;
echo("p?ea?e g?ve y?ur o?igi?al v?lue o? ??? b?tt?m v?ria?le?");
std::cout<<"y?u h??e ??? p???ts t? d?fin? y?ur or?gi?al va??e"<<endl;
echo("\?\? | \?\?\?\?-\?\?\?\?\?\?\?\?\? | \?\?\?\?\?\? | \?\?\?\?\? | \?\?\?\?\?\?\?\?");
echo("|?%))(#%(%)#$(%$)$|#>@???$(#:#(@!_@))@_)!(@)!_!_@");
echo("-ERROR-");
hear();
}
events();
return 0;
}