Compare commits

...

3 Commits

Author SHA1 Message Date
9d948bead1 refactor(P3879.cpp): 显式声明迭代器类型以增强代码可读性
将auto替换为具体的迭代器类型声明,使代码意图更清晰
2025-10-12 09:49:31 +08:00
63a72b5f14 feat: 添加P3879题目解答实现
实现一个基于map和set的字符串索引系统,用于快速查询包含特定字符串的文档ID。通过同步输入输出流提高性能,适用于大规模数据处理场景。
2025-10-12 09:43:37 +08:00
eb1f6031d1 feat: 添加P7988题目基础代码框架
实现题目P7988的基础代码框架,包括输入处理和基本数据结构定义
2025-10-11 20:56:55 +08:00
2 changed files with 59 additions and 0 deletions

24
src/10/11/P7988.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <cstdint>
#include <iostream>
#include <istream>
using ll = int64_t;
#define sl static inline
const ll maxn = 2e5+5;
ll n, a[maxn];
sl void dfs(){
}
int main(){
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin>>n;
for(ll i=1;i<=n;i++){
std::cin>>a[i];
}
}

35
src/10/12/P3879.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <cstdint>
#include <iostream>
#include <istream>
#include <map>
#include <set>
#include <string>
using ll = int64_t;
ll n,m,l;
std::map<std::string,std::set<ll>> 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(std::map<std::string,std::set<ll>>::const_iterator p = s.find(tmp);p!=s.end()){
for(const ll i:p->second){
std::cout<<i<<" ";
}
}
std::cout<<"\n";
}
}