UVa 540 Team Queue
2016-04-06 11:33
399 查看
请参考佳佳的书
#include <cstdio> #include <iostream> #include <map> #include <queue> using namespace std; const int maxt = 1000 + 9; int t = 0; map<int, int> team; void solve() { for (int i = 0; i < t; i++) { int n; cin >> n; for (int j = 0; j < n; j++) { int x; cin >> x; team[x] = i; } } queue<int> q, q2[maxt]; for (; ;) { string cmd; cin >> cmd; if (cmd[0] == 'S') break; if (cmd[0] == 'D') { int t = q.front(); cout << q2[t].front() << endl; q2[t].pop(); if (q2[t].empty()) q.pop(); }else { int x; cin >> x; int t = team[x]; if (q2[t].empty()) q.push(t); q2[t].push(x); } } cout << endl; } int main() { //freopen("input.txt", "r", stdin); for (int i = 1; ;i++) { cin >> t; if (t == 0) break; cout << "Scenario #" << i << endl; solve(); } }
相关文章推荐
- Java Map 按Key排序和按Value排序
- Ui_Spinner
- iOS监听UITextField的输入事件
- android.util.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at lin
- 【Android UI设计与开发】8.顶部标题栏(一)ActionBar 奥义·详解
- get和post、cookie和session、include和require之前的区别
- UIButton基本属性及定义
- 【iOS】UITextView多行文本动态高度
- @RequestBody应用
- 安装rrdtool-1.4.5报错
- Missing required libmysql_e.dll
- C# Dictionary.Add(key,value) 与 Dictionary[key]=value的区别
- Android Build System 构建系统
- hdu 1711Number Sequence(kmp模板题)
- iOS图形编辑之UIBezierPath小结
- 蓝牙连接 uuid的问题
- aERROR getting 'android:icon' attribute: attribute is not a string value
- UIView的layoutSubviews和drawRect方法何时调用
- UINavigationBar
- StringBuilder与StringBuffer的区别