#include<iostream>
#include<string>
using namespace std;
const int n = 100005;
int head, tail;
string queue[n];
void enqueue(string name) {
queue[tail++] = name;//tail队尾的后一位
}
string dequeue() {
return queue[head++];//返回头元素后 head++
}
string query(int pos) {
return queue[head + pos - 1];
}
int main() {
int n;
cin >> n;
while (n--) {
int op;
cin >> op;
if (op == 1) {
string name;
cin >> name;
enqueue(name);
}
else if (op == 2) {
cout << dequeue() << endl;
}
else if (op == 3) {
int pos;
cin >> pos;
cout << query(pos) << endl;
}
}
return 0;
}
相关文章: