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

【题意】

在这里输入题意

【题解】

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

【代码】

#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;
}

【例题 6-1 UVA - 210】Concurrency Simulator的更多相关文章

  1. uva 210 - Concurrency Simulator (并行程序模拟)

    from CSDN: https://blog.csdn.net/su_cicada/article/details/87898579 例题6-1 并行程序模拟( Concurrency Simula ...

  2. Uva - 210 - Concurrency Simulator

    自己写个双端队列,或者直接用deque,这个也比较好用 AC代码: #include <iostream> #include <cstdio> #include <cst ...

  3. UVa 210 Concurrency Simulator (双端队列+模拟)

    题意:给定n个程序,每种程序有五种操作,分别为 var = constant(赋值),print var (打印), lock, unlock,end. 变量用小写字母表示,初始化为0,为程序所公有( ...

  4. 210 - Concurrency Simulator(WF1991, deque, 模拟)

    题目有点长,理解题花了不少时间 粘下别人的翻译~ 你的任务是模拟n个程序(按输入顺序编号为1~n)的并行执行.每个程序包含不超过25条语句,格式一共有5种: var=constant(赋值): pri ...

  5. UVA 11423 - Cache Simulator (树状数组)

    UVA 11423 - Cache Simulator (树状数组) option=com_onlinejudge&Itemid=8&category=523&page=sho ...

  6. UVa210 Concurrency Simulator (ACM/ICPC World Finals 1991) 双端队列

    Programs executed concurrently on a uniprocessor system appear to be executed at the same time, but ...

  7. 并行程序模拟(Concurrency Simulator, ACM/ICPC World Finals 1991,Uva210)

    任务介绍 你的任务是模拟n个程序的并行运算.(按照输入编号为1~n)的并行执行. 代码实现 #define LOCAL #include<bits/stdc++.h> using name ...

  8. UVa 210 并行程序模拟(deque)

    题意: 模拟n个程序运行 格式一共有5种:var = constant(赋值):print var(打印):lock:unlock:end, 上述5种语句分别需要t1.t2.t3.t4.t5单位时间 ...

  9. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

随机推荐

  1. android-开发环境相关概念

    Android中IDE.ADT.SDK.JDK.NDK的解释 1. IDE: Intelligent Development Environm的简称.即智能开发环境.是一种开发工具.常用的IDE有ad ...

  2. VS NuGet使用

    通过这个可以自动联网下载内容! 很方便! 工具->NuGet包管理工具->程序包管理器控制台

  3. Codefroces Educational Round 27 845G Shortest Path Problem?

    Shortest Path Problem? You are given an undirected graph with weighted edges. The length of some pat ...

  4. AIX lsof 命令

    1.查看某端口运行情况 如查看22端口运行情况 # lsof –i:22 # lsof –i:22 –r   ----每隔15秒显示22端口的监听情况.   2.查看活动的连接 如:查看ip地址为19 ...

  5. chkconfig---检查设置系统服务

    chkconfig命令   chkconfig命令检查.设置系统的各种服务.这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务 ...

  6. mkfs---创建Linux文件系统

    [root@xiaolizi ~]# mkfsmkfs mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs ...

  7. CMDB学习之三数据采集

    判断系统因为是公用的方法,所有要写基类方法使用,首先在插件中创建一个基类 将插件文件继承基类 思路是创建基类使用handler.cmd ,命令去获取系统信息,然后进行判断,然后去执行 磁盘 ,cpu, ...

  8. 【iOS与EV3混合机器人编程系列之中的一个】iOS要干嘛?EV3能够更酷!

    乐高Mindstorm EV3智能机器人(下面简称EV3)自从在2013年的CES(Consumer Electronics Show美国消费电子展)上展出之后,就吸引了全球广大机器人爱好者的眼球!E ...

  9. 负载均衡器&amp;http正向代理

    透明的负载均衡器&http正向代理 * master-workers架构,http正向代理由独立的dns请求以及缓冲进程  * 使用epoll(ET)模式,採用全异步方式(双缓存,实现双向同一 ...

  10. onvif开发实战1--总结框架搭建

    Gsoap及开发框架生成: 一:gsoap下载和编译   1.下载Gsoap:地址:http://sourceforge.net/projects/gsoap2/files/gSOAP/ 2.安装: ...