#include #include #include #include struct cat{ int x,y; bool yelpOK;//yelpOKは鳴きOK }; struct timer{ int catNo,time,type;//0なら鳴き終わりイベント、1ならY秒間の鳴きやめ期間から復帰 bool operator<(const timer t)const{ if(time!=t.time)return time>t.time; if(type!=t.type)return typet.catNo; } bool operator==(const timer t)const { return catNo==t.catNo && time==t.time && type==t.type; } }; cat c[1001]; std::vector catG[1001];//50以内にいる猫たちの関係を表すグラフ std::priority_queue timeTable; int lastTime; timer lastEvent;//今の時点で一番最後に来るイベントを保管する int X,Y,n;// void event(const timer t){ if(t.type==0){ //鳴き終わりイベント lastTime=t.time;//最後に鳴いた猫の時刻 timer nextT; nextT.time=t.time+Y; nextT.type=1; nextT.catNo=t.catNo; lastEvent=lastEvent::iterator it=catG[t.catNo].begin(); while(it!=catG[t.catNo].end()){ if(c[(*it)].yelpOK==true){ c[(*it)].yelpOK=false; nextT.catNo=(*it); lastEvent=lastEvent > eventMemo; int baseTime=X; timer nowEvent; std::vector nowMemo; lastTime=0; timer nowSplitEvent=lastEvent; while(timeTable.empty()==false){ nowEvent=timeTable.top(); timeTable.pop(); event(nowEvent); if(nowSplitEvent==nowEvent){ nowEvent.time-=baseTime; nowMemo.push_back(nowEvent); nowSplitEvent=lastEvent; if(eventMemo.find(nowMemo)!=eventMemo.end()){ printf("You're always welcome!\n"); return ; } eventMemo.insert(nowMemo); nowMemo.clear(); if(timeTable.empty()==false)baseTime=timeTable.top().time; }else{ nowEvent.time-=baseTime; nowMemo.push_back(nowEvent); } } printf("%d\n",lastTime); } void setCatPosition(int n){ for(int i=0;i