当前位置:网站首页>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
边栏推荐
- js递归树结构计算每个节点的叶子节点的数量并且输出
- JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
- C-11 problem h: treasure chest 2
- Supersocket is Used in net5 - command
- MySQL grouping query rules
- QT uses drag and drop picture to control and mouse to move picture
- socket编程 send()与 recv()函数详解
- ASP. Net 6 middleware series - conditional Middleware
- poi根据数据创建导出excel
- Web Course Design - his system
猜你喜欢

2022a special equipment related management (elevator) work license question bank and simulation examination

The most understandable life cycle of dependency injection

Web Course Design - his system

Experiment 6 input / output stream

It can receive multiple data type parameters - variable parameters
![Use of ADB command [1]](/img/e6/fb8fd6956c226f75b831f8eb46277f.png)
Use of ADB command [1]

Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer

Problem a: face recognition

MySql关键字GROUP_CONCAT,组合连接查询

IDEA查看历史记录【文件历史和项目历史】
随机推荐
String input problem
Test experience data
Experiment 6 input / output stream
Idempotency practice operation, explaining idempotency based on business
Docker拉取mysql并连接
The most understandable life cycle of dependency injection
The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
2022t elevator repair test simulation 100 questions and online simulation test
JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
Course design of Database Principle -- material distribution management system
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
C-11 problem h: treasure chest 2
[MySQL] left function | right function
JS implementation of new
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
Top 9 task management system in 2022
poi根据数据创建导出excel
QT learning summary
Explication détaillée des fonctions send () et recv () du programme Socket