商城网站开发模板,建设淘宝网站需要多少钱,建筑设计就业方向及前景,php 网站换空间题目链接如下#xff1a;
Online Judge
对比刘汝佳的代码#xff0c;我没有用queue来排整个队伍#xff0c;因为那样的话遍历整个队伍太麻烦#xff0c;vector比较方便。但vector删除元素比较耗时#xff0c;所以就不删了#xff0c;仅仅用pivot来指代目前队伍的开始。…题目链接如下
Online Judge
对比刘汝佳的代码我没有用queue来排整个队伍因为那样的话遍历整个队伍太麻烦vector比较方便。但vector删除元素比较耗时所以就不删了仅仅用pivot来指代目前队伍的开始。
代码如下
#include cstdio
#include queue
#include algorithm
#include vector
// #define debug
const int maxx 1000000;
const int maxOp 8;int t, k, nbr, pivot, kase 0;
int team[maxx];
char op[maxOp];int main(){#ifdef debugfreopen(0.txt, r, stdin);freopen(1.txt, w, stdout);#endifwhile(scanf(%d, t) 1 t){printf(Scenario #%d\n, kase);std::fill(team, team maxx, -1);for(int i 0; i t; i){scanf(%d, k);for(int j 0; j k; j){scanf(%d, nbr);team[nbr] i;}}std::vectorstd::queueint vec;pivot 0;while(scanf(%s, op) 1 op[0] ! S){if(op[0] E){scanf(%d, nbr);int i;for(i pivot; i vec.size(); i){if(team[vec[i].front()] team[nbr]){vec[i].push(nbr);break;}}if(i vec.size()){std::queueint tmp;tmp.push(nbr);vec.push_back(tmp);}} else{printf(%d\n, vec[pivot].front());vec[pivot].pop();if(vec[pivot].empty()){pivot;}}}printf(\n);}#ifdef debugfclose(stdin);fclose(stdout);#endifreturn 0;
}