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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. 查看activity task相关信息

    可以使用命令 adb shell dumpsys activity 查看的结果如下 ACTIVITY MANAGER PENDING INTENTS (dumpsys activity intents ...

  2. WebMethod Description

    http://www.webxml.com.cn/WebServices/WeatherWebService.asmx https://www.cnblogs.com/wanganyi/p/72202 ...

  3. 关于MySQL utf8mb4 字符集中字符串长度的问题

    MySQL之前推出的utf8字符集中,一个汉字占3个字节,新的utf8mb4字符集中一个汉字占4个字节. 那么我们平时建表的时候输入的varchar=16这种,到底指的是字符长度还是字节长度? 如果是 ...

  4. PHP生成二维码方法

    <?php //先下载一份phpqrcode类,下载地址http://down.51cto.com/data/780947require_once("phpqrcode/phpqrco ...

  5. HDU 2563 统计问题 (递推)

    A - 统计问题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  6. HBase高速导入数据--BulkLoad

    Apache HBase是一个分布式的.面向列的开源数据库.它能够让我们随机的.实时的訪问大数据.可是如何有效的将数据导入到HBase呢?HBase有多种导入数据的方法.最直接的方法就是在MapRed ...

  7. OPENSSL 制作 Ikev2证书

    OPENSSL 制作 Ikev2证书 在一个 VPS 上配置 IKEV2 VPN 服务器时,用 OPENSSL 制作了所需的数字证书,奇怪的怎么弄都无法连接服务器,一直提示 "IKE_SA ...

  8. Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7:

    Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7: 参考 http://blog.csdn.ne ...

  9. cc1.exe -fno-stack-protector

    # github.com/mattn/go-sqlite3 cc1.exe: error: unrecognized command line option "-fno-stack-prot ...

  10. 【2017 Multi-University Training Contest - Team 6】Classes

    [链接]http://acm.hdu.edu.cn/showproblem.php?pid=6106 [题意] 给出选 A,B,C,AB,AC,BC,ABC 课程的学生,其中 AB 是 A 和 B 都 ...