aboutsummaryrefslogtreecommitdiff
path: root/works/life/chuanzhi-cup/contest/4.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-02-12 15:55:21 +0800
committerYuqian Yang <crupest@crupest.life>2025-02-12 15:55:21 +0800
commit1ecfd0ab7f1f511268fd6404dbc110c3c277b48c (patch)
tree49449a4076ded9bd937a51679318edbe2a532cae /works/life/chuanzhi-cup/contest/4.cpp
parent55d8b025e8d6ea971e8ee5762c892405fedc316b (diff)
parentf8c10dd1fc55e60f35286475356e48c4f642eb63 (diff)
downloadcrupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.tar.gz
crupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.tar.bz2
crupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.zip
import(life): IMPORT crupest/life COMPLETE.
Diffstat (limited to 'works/life/chuanzhi-cup/contest/4.cpp')
-rw-r--r--works/life/chuanzhi-cup/contest/4.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/works/life/chuanzhi-cup/contest/4.cpp b/works/life/chuanzhi-cup/contest/4.cpp
new file mode 100644
index 0000000..da01a23
--- /dev/null
+++ b/works/life/chuanzhi-cup/contest/4.cpp
@@ -0,0 +1,48 @@
+#include <algorithm>
+#include <cstdio>
+#include <iostream>
+#include <string>
+#include <vector>
+
+int main() {
+ std::vector<std::string> files;
+ int n;
+ std::cin >> n;
+ int current_count = 0;
+ while (current_count < n) {
+ std::string command;
+ std::cin >> command;
+ char a = command[0];
+ if (a == 't') {
+ std::string file;
+ std::cin >> file;
+ auto iter = std::find(files.cbegin(), files.cend(), file);
+ if (iter == files.cend()) {
+ files.push_back(std::move(file));
+ }
+ } else if (a == 'l') {
+ for (const auto &f : files) {
+ std::cout << f << '\n';
+ }
+ } else {
+ char b = command[1];
+ if (b == 'm') {
+ std::string file;
+ auto iter = std::find(files.cbegin(), files.cend(), file);
+ if (iter != files.cend())
+ files.erase(iter);
+ } else {
+ std::string old, new_f;
+ std::cin >> old >> new_f;
+ auto iter = std::find(files.begin(), files.end(), old);
+ auto iter2 = std::find(files.begin(), files.end(), new_f);
+ if (iter != files.end() && iter2 == files.end()) {
+ *iter = std::move(new_f);
+ }
+ }
+ }
+ current_count++;
+ }
+
+ return 0;
+}