提交时间:2026-06-17 06:14:22

运行 ID: 91805

#include <bits/stdc++.h> using namespace std ; const int N = 1e5 + 1 ; const int M = 2e5 + 10 ; int a[M] , l = N , r = N ; int q ; int main() { cin >> q ; int op , x ; while(q--) { cin >> op >> x ; if(op == 1) a[l++] = x ; if(op == 2) a[--r] = x ; if(op == 3) cout << a[l - x] << endl ; } return 0 ; }