From 8e52eb791683a0602c706a69c53bcbf9ab6a3a9d Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 10 Jul 2022 09:38:16 +0800 Subject: [PATCH] =?UTF-8?q?734.=20=E3=80=90=E7=BB=9F=E4=B8=80=E7=9C=81?= =?UTF-8?q?=E9=80=892022=E3=80=91=E9=A2=84=E5=A4=84=E7=90=86=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://uoj.ac/submission/563016 --- UniversalOJ/734/734.cpp | 69 +++++++++++++++++++++++ UniversalOJ/734/data/ex_preprocessor1.ans | 3 + UniversalOJ/734/data/ex_preprocessor1.in | 3 + UniversalOJ/734/data/ex_preprocessor2.ans | 3 + UniversalOJ/734/data/ex_preprocessor2.in | 3 + UniversalOJ/734/data/preprocessor1.ans | 3 + UniversalOJ/734/data/preprocessor1.in | 3 + UniversalOJ/734/data/preprocessor10.ans | 3 + UniversalOJ/734/data/preprocessor10.in | 3 + UniversalOJ/734/data/preprocessor2.ans | 3 + UniversalOJ/734/data/preprocessor2.in | 3 + UniversalOJ/734/data/preprocessor3.ans | 3 + UniversalOJ/734/data/preprocessor3.in | 3 + UniversalOJ/734/data/preprocessor4.ans | 3 + UniversalOJ/734/data/preprocessor4.in | 3 + UniversalOJ/734/data/preprocessor5.ans | 3 + UniversalOJ/734/data/preprocessor5.in | 3 + UniversalOJ/734/data/preprocessor6.ans | 3 + UniversalOJ/734/data/preprocessor6.in | 3 + UniversalOJ/734/data/preprocessor7.ans | 3 + UniversalOJ/734/data/preprocessor7.in | 3 + UniversalOJ/734/data/preprocessor8.ans | 3 + UniversalOJ/734/data/preprocessor8.in | 3 + UniversalOJ/734/data/preprocessor9.ans | 3 + UniversalOJ/734/data/preprocessor9.in | 3 + 25 files changed, 141 insertions(+) create mode 100644 UniversalOJ/734/734.cpp create mode 100644 UniversalOJ/734/data/ex_preprocessor1.ans create mode 100644 UniversalOJ/734/data/ex_preprocessor1.in create mode 100644 UniversalOJ/734/data/ex_preprocessor2.ans create mode 100644 UniversalOJ/734/data/ex_preprocessor2.in create mode 100644 UniversalOJ/734/data/preprocessor1.ans create mode 100644 UniversalOJ/734/data/preprocessor1.in create mode 100644 UniversalOJ/734/data/preprocessor10.ans create mode 100644 UniversalOJ/734/data/preprocessor10.in create mode 100644 UniversalOJ/734/data/preprocessor2.ans create mode 100644 UniversalOJ/734/data/preprocessor2.in create mode 100644 UniversalOJ/734/data/preprocessor3.ans create mode 100644 UniversalOJ/734/data/preprocessor3.in create mode 100644 UniversalOJ/734/data/preprocessor4.ans create mode 100644 UniversalOJ/734/data/preprocessor4.in create mode 100644 UniversalOJ/734/data/preprocessor5.ans create mode 100644 UniversalOJ/734/data/preprocessor5.in create mode 100644 UniversalOJ/734/data/preprocessor6.ans create mode 100644 UniversalOJ/734/data/preprocessor6.in create mode 100644 UniversalOJ/734/data/preprocessor7.ans create mode 100644 UniversalOJ/734/data/preprocessor7.in create mode 100644 UniversalOJ/734/data/preprocessor8.ans create mode 100644 UniversalOJ/734/data/preprocessor8.in create mode 100644 UniversalOJ/734/data/preprocessor9.ans create mode 100644 UniversalOJ/734/data/preprocessor9.in diff --git a/UniversalOJ/734/734.cpp b/UniversalOJ/734/734.cpp new file mode 100644 index 00000000..560b977a --- /dev/null +++ b/UniversalOJ/734/734.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 105; + +int n; +std::string s[N]; +std::unordered_map> def; + +std::string dfs(std::string s) { + std::string r; + + for (int i = 0, j; i < s.size(); i += j) { + for (j = 0; i + j < s.size() && + ('0' <= s[i + j] && s[i + j] <= '9' || + 'a' <= s[i + j] && s[i + j] <= 'z' || + 'A' <= s[i + j] && s[i + j] <= 'Z' || s[i + j] == '_'); + j++) + ; + if (j) { + std::string tmp = s.substr(i, j), tmp2; + + if (def.count(tmp) && !def[tmp].second) { + def[tmp].second = true; + r += dfs(def[tmp].first); + def[tmp].second = false; + } else { + r += tmp; + } + } else { + r += s[i++]; + } + } + + return r; +} + +int main() { + cin >> n; + for (int i = 0; i <= n; i++) { + std::getline(cin, s[i]); + } + + for (int i = 1; i <= n; i++) { + if (s[i][0] == '#') { + if (s[i].substr(1, 6) == "define") { + int p = s[i].find_first_of(' ', 8); + std::string name = s[i].substr(8, p - 8), + content = s[i].substr(p + 1); + def[name] = std::make_pair(content, false); + } else { // s[i].substr(1, 6) == "undef" + std::string name = s[i].substr(7); + def.erase(name); + } + cout << endl; + } else { + cout << dfs(s[i]) << endl; + } + } + + return 0; +} diff --git a/UniversalOJ/734/data/ex_preprocessor1.ans b/UniversalOJ/734/data/ex_preprocessor1.ans new file mode 100644 index 00000000..cef8a13c --- /dev/null +++ b/UniversalOJ/734/data/ex_preprocessor1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86919d6fd2da1a28c380430021e707472a56b647fb27b1fa6626892169c60531 +size 6 diff --git a/UniversalOJ/734/data/ex_preprocessor1.in b/UniversalOJ/734/data/ex_preprocessor1.in new file mode 100644 index 00000000..c086d2e8 --- /dev/null +++ b/UniversalOJ/734/data/ex_preprocessor1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6c64b3fef38bf92a7c49b74f7e0dd1f2e27d5139f03865bb74ec6145ee71aaa +size 45 diff --git a/UniversalOJ/734/data/ex_preprocessor2.ans b/UniversalOJ/734/data/ex_preprocessor2.ans new file mode 100644 index 00000000..fd481aab --- /dev/null +++ b/UniversalOJ/734/data/ex_preprocessor2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 diff --git a/UniversalOJ/734/data/ex_preprocessor2.in b/UniversalOJ/734/data/ex_preprocessor2.in new file mode 100644 index 00000000..e284fabc --- /dev/null +++ b/UniversalOJ/734/data/ex_preprocessor2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67abd1a3a065e2adb41374084cdce755026b2e6392d5529e30a86adcf89b1611 +size 15 diff --git a/UniversalOJ/734/data/preprocessor1.ans b/UniversalOJ/734/data/preprocessor1.ans new file mode 100644 index 00000000..a999b575 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:242d5afec92830db7a8d353bf627c1eefff7d2d49c94136ccac9e90658293423 +size 27 diff --git a/UniversalOJ/734/data/preprocessor1.in b/UniversalOJ/734/data/preprocessor1.in new file mode 100644 index 00000000..0559b2b0 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62772d3bcfc45dcecc19e942ae397e2e490148bedb5c4abe2efc81bc03756674 +size 29 diff --git a/UniversalOJ/734/data/preprocessor10.ans b/UniversalOJ/734/data/preprocessor10.ans new file mode 100644 index 00000000..dddb7814 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ce01b324f2858c3a24718347f54beae0ca71fa29d6070e598af392f5e03ff98 +size 7153 diff --git a/UniversalOJ/734/data/preprocessor10.in b/UniversalOJ/734/data/preprocessor10.in new file mode 100644 index 00000000..2d4315a7 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0617f329162a885f95790284be314426b6566997e9cf35acb7515b64cbd1e659 +size 5630 diff --git a/UniversalOJ/734/data/preprocessor2.ans b/UniversalOJ/734/data/preprocessor2.ans new file mode 100644 index 00000000..fd256d06 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7997cd3178bd413619089f4d2306fbfce4b44ff9403dc64f69d9a929dd6e26a9 +size 157 diff --git a/UniversalOJ/734/data/preprocessor2.in b/UniversalOJ/734/data/preprocessor2.in new file mode 100644 index 00000000..2e84412f --- /dev/null +++ b/UniversalOJ/734/data/preprocessor2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df44f037d92444cc250be0649898778492f86e64da14c1a11022d3d0d38eb1f6 +size 172 diff --git a/UniversalOJ/734/data/preprocessor3.ans b/UniversalOJ/734/data/preprocessor3.ans new file mode 100644 index 00000000..72fb7573 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70b6d000a49b687f6b494b49bab220f26698e6b008f8a3ddbbc39cc99313ed5f +size 43 diff --git a/UniversalOJ/734/data/preprocessor3.in b/UniversalOJ/734/data/preprocessor3.in new file mode 100644 index 00000000..a0a3ee39 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ce4f3beb0e4d9c94526951c49ae299fa0d2147c5e77800c230263dc67a6557d +size 67 diff --git a/UniversalOJ/734/data/preprocessor4.ans b/UniversalOJ/734/data/preprocessor4.ans new file mode 100644 index 00000000..5bdfb1d2 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58459ff55d663422bf5c64c1b96be1f8cc1e0852055c3e24b56d3b5263ff5cb7 +size 187 diff --git a/UniversalOJ/734/data/preprocessor4.in b/UniversalOJ/734/data/preprocessor4.in new file mode 100644 index 00000000..50dea4f2 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93fd1394ab38366386445ec05d36c8347d8458d0e34e2ebc478d7cbb1d3867f5 +size 86 diff --git a/UniversalOJ/734/data/preprocessor5.ans b/UniversalOJ/734/data/preprocessor5.ans new file mode 100644 index 00000000..ae878f96 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2987a0328ce661b260728ac237680858dd88016aaa49f8db6419fbed0f207b3 +size 44 diff --git a/UniversalOJ/734/data/preprocessor5.in b/UniversalOJ/734/data/preprocessor5.in new file mode 100644 index 00000000..9585bf03 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d55c95502d9ae786a8ef50ce333ea8da40c2eabbe1c6d2efa2b5cdf16cb8d1e +size 67 diff --git a/UniversalOJ/734/data/preprocessor6.ans b/UniversalOJ/734/data/preprocessor6.ans new file mode 100644 index 00000000..d5914122 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b1c8d5a015f34d82461fafa6ba2a9efe058be2980ec460ebd7e781e053999aa +size 10100 diff --git a/UniversalOJ/734/data/preprocessor6.in b/UniversalOJ/734/data/preprocessor6.in new file mode 100644 index 00000000..c611d977 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:164cde75617fdaa02b91ef4542fd6fcfab15e458d2f2af50c9892833a7eacb84 +size 10104 diff --git a/UniversalOJ/734/data/preprocessor7.ans b/UniversalOJ/734/data/preprocessor7.ans new file mode 100644 index 00000000..9eaa4a76 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b131e678ce183dc871a22a3007817a5a3a87a8fcb633b41e773505e07992296 +size 28000 diff --git a/UniversalOJ/734/data/preprocessor7.in b/UniversalOJ/734/data/preprocessor7.in new file mode 100644 index 00000000..3fed9800 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98afdc5b8a48a52eef0c65b49dd857481d564b4bcc0f89c73f572ff415d7e335 +size 6504 diff --git a/UniversalOJ/734/data/preprocessor8.ans b/UniversalOJ/734/data/preprocessor8.ans new file mode 100644 index 00000000..22a2e1c0 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52e43ea3106c1e985e3be0dfbc8d5e62f94d6f8c149baa089feb0d34c453f806 +size 11152 diff --git a/UniversalOJ/734/data/preprocessor8.in b/UniversalOJ/734/data/preprocessor8.in new file mode 100644 index 00000000..058394e3 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c663e5bbaf5d18e0d133ebffcad2019b3f39d49a2979e40206a5a7a9fd04556b +size 6126 diff --git a/UniversalOJ/734/data/preprocessor9.ans b/UniversalOJ/734/data/preprocessor9.ans new file mode 100644 index 00000000..72933bde --- /dev/null +++ b/UniversalOJ/734/data/preprocessor9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcfc99630e297b6107f1c4ebbb271db1e149da050df15791f5a7b893c1983b52 +size 6558 diff --git a/UniversalOJ/734/data/preprocessor9.in b/UniversalOJ/734/data/preprocessor9.in new file mode 100644 index 00000000..0b1fe056 --- /dev/null +++ b/UniversalOJ/734/data/preprocessor9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1800500f348cafeefe8c0a74af8bb0bb2a6fbc675d725df9b53d23fdf85a88ba +size 5618