当前位置:网站首页>2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
2022-04-23 03:23:00 【One more line and go to bed】
as everyone knows ,PAT Yes 9 Badge , Corresponding to bronze 、 Silver 、 gold 、 Platinum 、 diamond 、 The master 、 The king 、 The risk 、 God this 9 Segments , Only candidates with excellent results are eligible for badges engraved with their names . Now? ,PAT Made a small commemorative version of the badge , To make a blind box for everyone to play !
The following figure is a schematic diagram of a blind box packaging line . First, the badge is pressed into the warehouse through the purchase port , The empty box is conveyed from left to right on the track . Each time a badge pops up from the warehouse , Enter the packer , Put in an empty box , After packing, continue to transfer to the right . When the warehouse is empty , The packaging opportunity is suspended , Wait for the next batch of badges to be pressed into the warehouse .
Each box has a number , Sister Xiaopin has the empty box number sequence table entering the assembly line in her hand , There is also a badge sequence table for each batch sent to the warehouse , So she can actually know what kind of badge is in each box . Some children received a blind box , Just want to ask the omniscient little spell sister before unpacking , What kind of badge is in the box . But because the total number of blind boxes is 105 So much , Sister Xiaopin can't remember what's in each box , So you were invited to write a program to help Xiaopin reply to this message .
Input format :
The first line of input is given 2 A positive integer , They are the total number of blind boxes N(≤105) And warehouse capacity S(≤100). The next line shows N Numbered boxes , No. by 5 Digit composition , The sequence given is the sequence of empty boxes entering the conveyor belt . And then N/S( Guaranteed to be an integer ) That's ok , One batch per line S The type of badge , by 1-9 The number of , The order given is the order of entering the stack from the purchase port .
Next, we give a positive integer K(≤104), Is the number of queries . And then K That's ok , Each line gives a 5 Bit number .
Output format :
Number each query , Output the badge type contained in the box in one line . If the number is wrong , Output in one line Wrong Number
.
sample input :
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
sample output :
1
1
9
Wrong Number
4
Look at simple stack and queue operations , Simple hash
#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;
}
版权声明
本文为[One more line and go to bed]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230322232843.html
边栏推荐
猜你喜欢
打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
浅学一下I/O流和File类文件操作
Unity knowledge points (ugui)
Configuration table and page information automatically generate curd operation page
Huawei mobile ADB devices connection device is empty
Web Course Design - his system
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
General testing technology [1] classification of testing
随机推荐
C-10 program error correction (recursive function): number to character
JSON related
Batch download of files ---- compressed and then downloaded
QT dynamic translation of Chinese and English languages
场景题:A系统如何使用B系统的页面
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
. NETCORE sets the API post mode, which can accept parameters directly in parentheses
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
2022g2 boiler stoker examination question bank and online simulation examination
Preview of converting doc and PDF to SWF file
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
Super easy to use [general excel import function]
Flink real-time data warehouse project - Design and implementation of DWS layer
Explication détaillée des fonctions send () et recv () du programme Socket
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
批量下载文件----压缩后再下载
Problem B: small challenge
Super easy to use asynchronous export function of Excel
Do you really understand hashcode and equals???