Description
Xiaoming's job is to record the information of the people who are queuing up in the canteen.
There will be three possible events in his work:
1. The student ID is added to the last side of the team
2. The top students leave the team after dinner.
3. The boss came to inquire about the number of the students currently ranked in front of the team.
Because the daily workload is too large (up to 100,000 events per day),
Xiao Ming's miserable, let you write a program to help him
Input
The first number entered is a positive integer t, indicating that there is a T-group of data next
The first number of each set of data is a positive integer n, indicating that there are n things that happen
Then there are n rows, each representing one of the three types of events to be appealed, in the following format:
1 ID
2
3 K
Note that when there is no one in the team, please ignore the 2nd event, each group of data start with the number of the team is 0
Output
For a 3rd event, please output the number of the K-student,
If the number of teams is less than K, output "Na Li you zhe me duo Ren".
Sample Input251 123 121 2Sample Output12na Li You zhe me duo RenHINT
Effect:--| | Stupid like to see the topic think is the queue later found to read out the number of K, need a loop to all the queue values to read out that K value and put in the result timeout, read someone else's code ~ ~ ~ Only Worship Orzorzorz —————— is actually an array, with a mark, Mark where the first person is now.
#include <cstdio>#include<cstring>#include<iostream>using namespacestd;Const intMAX =1000010;intA[max];intMain () {intT,n,m,k,number,flag1,flag2; CIN>>T; while(t--) {Flag1= Flag2 =0; CIN>>N; while(n--) {scanf ("%d",&m); if(M = =1) {scanf ("%d",&Number ); A[flag1++] =Number ; } Else if(M = =2){ if(Flag2 < Flag1) flag2++; } Else{scanf ("%d",&k); if(k > Flag1-flag2) printf ("na li you zhe me duo ren\n"); Elseprintf"%d\n", a[flag2+k-1]); } } } return 0;}
View Code
Xiao Ming is working