【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

队列模拟题。
注意初始化。。
然后题目中是让读入一个数据组数然后再输入数据的。
但样例。。但样例没有!?

【代码】

#include <bits/stdc++.h>
using namespace std; const int P = 5;
const int N = 10;
const int L = 25; int n,t[P+5],Q;
string Pro[N + 10][L + 10];
int lines[N + 10],cur[N+10];
deque <int> dl;
queue <int> blocked;
bool flag = 0,ru;
int val[300]; void run(int idx)
{
int QAQ = 0;
while (QAQ < Q)
{
cur[idx]++;
switch (Pro[idx][cur[idx]][2])
{
case '=':
{
QAQ += t[1];
int x;
if (isdigit(Pro[idx][cur[idx]][5]))
x = (Pro[idx][cur[idx]][4] - '0') * 10 + (Pro[idx][cur[idx]][5] - '0');
else
x = Pro[idx][cur[idx]][4] - '0';
val[Pro[idx][cur[idx]][0]] = x;
break;
} case 'i'://print
{
QAQ += t[2];
cout << idx << ": "<<val[Pro[idx][cur[idx]][6]] << endl;
break;
} case 'c'://lock
{
QAQ += t[3];
if (!flag)
flag = 1;
else
{
ru = true;
blocked.push(idx);
cur[idx]--;
return;
}
break;
} case 'l'://unlock
{
QAQ += t[4];
flag = 0;
if (!blocked.empty())
{
dl.push_front(blocked.front());
blocked.pop();
}
break;
} case 'd':
{
QAQ += t[5];
return;
break;
} default:break;
}
}
} int main()
{
/*freopen("F:\\rush.txt", "r", stdin);
freopen("F:\\rush_out.txt", "w", stdout);*/
int kase = 0;
int T;
scanf("%d", &T);
while (T--)
{
memset(val, 0, sizeof val);
if (kase > 0) puts("");
kase++;
scanf("%d", &n);
for (int i = 1; i <= 5; i++) scanf("%d", &t[i]);
scanf("%d", &Q);
getchar();
for(int i=1;i<=10;i++) lines[i]=0;
for(int i=1;i<=10;i++) cur[i]=0;
for (int i = 1; i <= n; i++)
{
string s;
while (getline(cin, s))
{
lines[i]++;
Pro[i][lines[i]] = s;
if (s =="end") break;
}
} while (!dl.empty()) dl.pop_back();
while (!blocked.empty()) blocked.pop();
flag = false; for (int i = 1; i <= n; i++) dl.push_back(i); while (!dl.empty())
{
ru = false;
int x = dl.front();
dl.pop_front();
run(x);
if (!ru && lines[x] > cur[x]) dl.push_back(x);
}
}
return 0;
}

最新文章

  1. [翻译]用 Puppet 搭建易管理的服务器基础架构(2)
  2. nodejs学习资料
  3. wamp服务下部署禅道或其它项目时访问缓慢的解决办法
  4. nginx配置负载
  5. 16 款最流行的 JavaScript 框架
  6. Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想
  7. gulp构建前端开发环境
  8. mybatis模板
  9. Python3学习
  10. Android 常用网站
  11. angular2 学习笔记 ( DI 依赖注入 )
  12. 如何查找ORACLE中的跟踪文件
  13. 搭建windows环境下(nginx+mysql+php)开发环境
  14. 【LeetCode】49. Group Anagrams
  15. NumPy学习笔记 三 股票价格
  16. 福州首届.NET开源社区技术交流会圆满成功
  17. Spark GraphX快速入门
  18. June 2. 2018 Week 22nd Saturday
  19. Confluence 6 删除垃圾内容
  20. The processing instruction target matching &amp;quot;[xX][mM][lL]&amp;quot; is not allowed.

热门文章

  1. 39.C语言操作数据库
  2. C_深入(内存模型)
  3. LuoguP3356 火星探险问题(费用流)
  4. mkfs---创建Linux文件系统
  5. 搜索 debian8.7.1 ,google vs baidu
  6. ubuntu14.04 printk()默认打印的位置
  7. Navicat for MySQL 新建查询时,报can&#39;t create file ...系统找不到指定的文件夹出现问题
  8. HML5
  9. Robot Framework 自动化测试
  10. 【Codeforces Round #455 (Div. 2) A】Generate Login