当前位置:网站首页>2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
2022-04-23 03:22:00 【再敲一行就去睡】
众所周知,PAT 有 9 枚徽章,分别对应青铜、白银、黄金、白金、钻石、大师、王者、大圣、天神这 9 个段位,只有成绩非常优秀的考生才有资格获得刻有自己名字的徽章。现在,PAT 制作了徽章的小型纪念版,要制成盲盒给大家玩了!
下图是一条盲盒包装流水线的示意图。首先徽章通过进货口被压入货栈里,空盒在履带上从左向右传送。每次从货栈里弹出一枚徽章,进入打包机,装入一只空盒,打包后继续向右边传送。当货栈为空时,打包机会暂停,等待下一批徽章压入货栈。

每只盒子都有一个编号,小拼姐姐手里有进入流水线的空盒编号顺序表,也有每一批送往货栈的徽章顺序表,这样她其实可以知道每只盒子里装了哪种徽章。有些小朋友收到了盲盒,就想在拆封前问无所不知的小拼姐姐,盒子里的徽章是哪一种。但是因为盲盒总量有 105 这么多,小拼姐姐可记不住每只盒子里装的是什么,于是你就被请来写个程序帮小拼姐姐回复这种信息。
输入格式:
输入第一行给出 2 个正整数,分别为盲盒总量 N(≤105)和货栈容量 S(≤100)。接下来一行给出 N 只盒子的编号,编号由 5 位数字组成,给出的顺序是空盒进入传送带的顺序。随后 N/S(保证是整数)行,每行给出一批 S 枚徽章的类型,为 1-9 的数字,给出的顺序是从进货口入栈的顺序。
再下面给出一个正整数 K(≤104),为查询次数。随后 K 行,每行给出一个 5 位编号。
输出格式:
对每个查询编号,在一行中输出该盒子中装的徽章类型。如果编号是错误的,则在一行中输出 Wrong Number。
输入样例:
10 5
00132 10093 92001 23333 66666 88888 09009 34658 82750 69251
1 2 3 4 5
9 8 7 6 1
5
66666
88888
69251
55555
10093
输出样例:
1
1
9
Wrong Number
4
考察简单的栈和队列操作,简单的哈希
#include <bits/stdc++.h>
using namespace std;
int v[100000]={0};
int main(void){
int n,s,k;
cin>>n>>s;
queue<int> q;
stack<int> p;
for(int i=0;i<n;i++){
int x;
cin>>x;
q.push(x);
}
for(int i=0;i<n;i++){
int x;
cin>>x;
p.push(x);
if(p.size()==s){
while(!p.empty()){
int y=q.front();q.pop();
int z=p.top();p.pop();
v[y]=z;
}
}
}
cin>>k;
while(k--){
int x;
cin>>x;
if(v[x])cout<<v[x];
else cout<<"Wrong Number";
if(k)cout<<endl;
}
return 0;
}

版权声明
本文为[再敲一行就去睡]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_46212625/article/details/124349741
边栏推荐
- Is it difficult to choose binary version control tools? After reading this article, you will find the answer
- Explication détaillée des fonctions send () et recv () du programme Socket
- Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
- Configure automatic implementation of curd projects
- Peut recevoir plusieurs paramètres de type de données - paramètres variables
- Experiment 6 input / output stream
- 全新的ORM框架——BeetlSQL介绍
- 2022年做跨境电商五大技巧小分享
- Huawei mobile ADB devices connection device is empty
- . net 5 Web custom middleware implementation returns the default picture
猜你喜欢

2022t elevator repair test simulation 100 questions and online simulation test

《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案

Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions

When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director

2022 P cylinder filling training test questions and simulation test

JS inheritance

Why is bi so important to enterprises?

【无标题】

A comprehensive understanding of static code analysis

Charles uses three ways to modify requests and responses
随机推荐
MySQL installation pit
TCP three handshakes and four waves
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
QT learning summary
After the mobile phone is connected to the computer, how can QT's QDIR read the mobile phone file path
12.<tag-链表和常考点综合>-lt.234-回文链表
“如何实现集中管理、灵活高效的CI/CD”在线研讨会精彩内容分享
File upload vulnerability summary and upload labs shooting range documentary
C WPF UI framework mahapps switching theme
《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
2022年做跨境电商五大技巧小分享
The most understandable life cycle of dependency injection
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
js递归树结构计算每个节点的叶子节点的数量并且输出
一套组合拳,打造一款 IDEA 护眼方案
批量下載文件----壓縮後再下載
QT dynamic translation of Chinese and English languages
Scenario Title: how does system a use the page of system B
Mysql database, inconsistent index character set, slow SQL query, interface timeout
Generate QR code through zxing