1 条题解
-
0
#include <iostream> #include <vector> #include <string> using namespace std; int main() { int n; cin >> n; vector<string> history; // 用于存储浏览历史 int currentIndex = -1; // 当前所在页面的索引 for (int i = 0; i < n; i++) { string operation; cin >> operation; if (operation == "VISIT") { string url; cin >> url; // 清除当前索引之后的所有历史记录 if (currentIndex < history.size() - 1) { history.erase(history.begin() + currentIndex + 1, history.end()); } // 添加新的网址到历史记录中 history.push\_back(url); currentIndex++; cout << url << endl; } else if (operation == "BACK") { if (currentIndex > 0) { currentIndex--; cout << history[currentIndex] << endl; } else { cout << "Ignore" << endl; } } else if (operation == "FORWARD") { if (currentIndex < history.size() - 1) { currentIndex++; cout << history[currentIndex] << endl; } else { cout << "Ignore" << endl; } } } return 0; }
信息
- ID
- 139
- 时间
- 2000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 73
- 已通过
- 16
- 上传者