From 63a72b5f14f8d0f16be2d331d40dc87124ce1142 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sun, 12 Oct 2025 09:43:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0P3879=E9=A2=98?= =?UTF-8?q?=E7=9B=AE=E8=A7=A3=E7=AD=94=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现一个基于map和set的字符串索引系统,用于快速查询包含特定字符串的文档ID。通过同步输入输出流提高性能,适用于大规模数据处理场景。 --- src/10/12/P3879.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/10/12/P3879.cpp diff --git a/src/10/12/P3879.cpp b/src/10/12/P3879.cpp new file mode 100644 index 0000000..bfab136 --- /dev/null +++ b/src/10/12/P3879.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include +using ll = int64_t; + +ll n,m,l; +std::map> s; +std::string tmp; + +int main(){ + std::iostream::sync_with_stdio(false); + std::cin.tie(nullptr); + + std::cin>>n; + for(ll i=1;i<=n;i++){ + std::cin>>l; + for(ll j=1;j<=l;j++){ + std::cin>>tmp; + s[tmp].insert(i); + } + } + std::cin>>m; + while(m--){ + std::cin>>tmp; + if(const auto p = s.find(tmp);p!=s.end()){ + for(const ll i:p->second){ + std::cout<