diff options
author | crupest <crupest@outlook.com> | 2021-02-24 00:36:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-24 00:36:15 +0800 |
commit | 71d1ec361fda9a119f31099a783b36cc814f4de8 (patch) | |
tree | b698d4f42dd525d1286154236641bfc3e68ceced /chuanzhi-cup/contest/4.cpp | |
parent | 0d5160de7c120de4d7f7bb1344f205f1144afc1f (diff) | |
download | life-71d1ec361fda9a119f31099a783b36cc814f4de8.tar.gz life-71d1ec361fda9a119f31099a783b36cc814f4de8.tar.bz2 life-71d1ec361fda9a119f31099a783b36cc814f4de8.zip |
Add chuanzhi-cup codes.
Diffstat (limited to 'chuanzhi-cup/contest/4.cpp')
-rw-r--r-- | chuanzhi-cup/contest/4.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/chuanzhi-cup/contest/4.cpp b/chuanzhi-cup/contest/4.cpp new file mode 100644 index 0000000..da01a23 --- /dev/null +++ b/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;
+}
|