国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

refresh的停車(chē)場(chǎng)

2019-11-10 18:48:37
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

PRoblem Description refresh最近發(fā)了一筆橫財(cái),開(kāi)了一家停車(chē)場(chǎng)。由于土地有限,停車(chē)場(chǎng)內(nèi)停車(chē)數(shù)量有限,但是要求進(jìn)停車(chē)場(chǎng)的車(chē)輛過(guò)多。當(dāng)停車(chē)場(chǎng)滿(mǎn)時(shí),要進(jìn)入的車(chē)輛會(huì)進(jìn)入便道等待,最先進(jìn)入便道的車(chē)輛會(huì)優(yōu)先 進(jìn)入停車(chē)場(chǎng),而且停車(chē)場(chǎng)的結(jié)構(gòu)要求只出去的車(chē)輛必須是停車(chē)場(chǎng)中最后進(jìn)去的車(chē)輛?,F(xiàn)告訴你停車(chē)場(chǎng)容量N以及命令數(shù)M,以及一些命令(Add num 表示車(chē)牌號(hào)為num的車(chē)輛要進(jìn)入停車(chē)場(chǎng)或便道, Del 表示停車(chē)場(chǎng)中出去了一輛車(chē),Out 表示便道最前面的車(chē)輛不再等待,放棄進(jìn)入停車(chē)場(chǎng))。假設(shè)便道內(nèi)的車(chē)輛不超過(guò)1000000. Input 輸入為多組數(shù)據(jù),每組數(shù)據(jù)首先輸入N和M(0< n,m?。?00000),接下來(lái)輸入M條命令。 Output 輸入結(jié)束后,如果出現(xiàn)停車(chē)場(chǎng)內(nèi)無(wú)車(chē)輛而出現(xiàn)Del或者便道內(nèi)無(wú)車(chē)輛而出現(xiàn)Out,則輸出Error,否則輸出停車(chē)場(chǎng)內(nèi)的車(chē)輛,最后進(jìn)入的最先輸出,無(wú)車(chē)輛不輸出。 Example Input

2 6Add 18353364208Add 18353365550Add 18353365558Add 18353365559DelOut

Example Output

1835336555818353364208

Hint

Author

#include <iostream>#include <algorithm>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <bits/stdc++.h>#include <stack>#include <deque>#include <queue>using namespace std;typedefstruct node{ char p[20];}ras;int main(){ stack< ras> p; queue <ras> g; int n, m; while(~scanf("%d%d", &n, &m)) { while(!p.empty()) { p.pop(); } while(!g.empty()) { g.pop(); } int top=1; while(m--) { char kk[5]; scanf("%s", kk); if(strcmp(kk, "Add")==0) { struct node l; scanf("%s", l.p); if(p.size()<n) { p.push(l); } else g.push(l); } else if(strcmp(kk, "Del")==0) { if(p.empty()) { top=0; } else { p.pop(); if(!g.empty()) { p.push(g.front()); g.pop(); } } } else if(strcmp(kk, "Out")==0) { if(g.empty()) { top=0; } else g.pop(); } } if(top) while(!p.empty()) { printf("%s/n", p.top().p); p.pop(); } else printf("Error/n"); } return 0;}
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 且末县| 曲松县| 邻水| 巩义市| 竹北市| 司法| 石门县| 武陟县| 苍溪县| 和硕县| 界首市| 白朗县| 宜宾县| 仁布县| 临江市| 南召县| 柯坪县| 张掖市| 广南县| 沅江市| 卢湾区| 右玉县| 连南| 定安县| 新河县| 湟中县| 抚州市| 华容县| 图片| 敦化市| 民县| 确山县| 岑溪市| 威信县| 额敏县| 敦化市| 夏邑县| 大英县| 革吉县| 林西县| 临邑县|