Good Teacher
Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
I want to be a good teacher, so at least I need to remember all the student names. However, there are
too many students, so I failed. It is a shame, so I don’t want my students to know this. Whenever Ineed to call someone, I call his CLOSEST student instead. For example, there are 10 students:A ? ? D ? ? ? H ? ?Then, to call each student, I use this table:Pos Reference1 A2 right of A3 left of D4 D5 right of D6 middle of D and H7 left of H8 H9 right of H10 right of right of HInputThere is only one test case. The first line contains n, the number of students (1 ≤ n ≤ 100). The nextline contains n space-separated names. Each name is either ‘?’ or a string of no more than 3 Englishletters. There will be at least one name not equal to ‘?’. The next line contains q, the number ofqueries (1 ≤ q ≤ 100). Then each of the next q lines contains the position p (1 ≤ p ≤ n) of a student(counting from left).OutputPrint q lines, each for a student. Note that ‘middle of X and Y ’ is only used when X and Y areboth closest of the student, and X is always to his left.Sample Input10
A ? ? D ? ? ? H ? ?438610Sample Outputleft of DHmiddle of D and Hright of right of H题解:老师点名,由于一些同学不认识名字,所以要找离他最近的同学代替,题中的I call his CLOSEST student instead;
还有一点就是两个同学中间,但是这两个同学间不能有人。。。
代码:
#include#include #include #include #include #include