///@author Sycamore, ZJNU ///@date 2017-02-09 #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int T, N; cin >> T; while (T--) { cin >> N; vector<int>v(N); for (auto &e : v)cin >> e; vector<int>w(N); for (auto &e : w)cin >> e; bool s = false, q = false; if (v == w)q = true; reverse(w.begin(), w.end()); if (v == w)s = true; if (s && !q)cout << "stack"; else if (!s && q)cout << "queue"; else if (s && q)cout << "both"; else cout << "neither"; cout << endl; } return 0; }
时间: 2024-11-10 10:39:50