1 条题解
-
3
既然没人发题解,那就我来
#include <bits/stdc++.h> #define ll long long #define re register int using namespace std; int n, x, a[10005], cnt; string s; deque<int> dq; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (re i = 1; i <= n; i++) { cin >> s; if (s == "LIN") { cin >> x; dq.push_front(x); } else if (s == "RIN") { cin >> x; dq.push_back(x); } else if (s == "ROUT") { if (dq.empty()) a[++cnt] = i; else dq.pop_back(); } else if (s == "LOUT") { if (dq.empty()) a[++cnt] = i; else dq.pop_front(); } } for (auto b : dq) cout << b << " "; cout << "\n"; for (re i = 1; i <= cnt; i++) cout << a[i] << " ERROR\n"; return 0; }
- 1
信息
- ID
- 785
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 44
- 已通过
- 21
- 上传者