--- title: "校庆" created: 2025-11-28 tags: - 算法 --- # 校庆 ## 题目 [校庆](https://www.acwing.com/problem/content/description/4272/) ![[image-64766e43.png]] ## 思路分析 看是否出现过 用unordered\_set即可 看年长只要看身份证7~14位谁更小即可 因为从1开始而程序从0 其实就是从6截取8长度 ## 代码实现 ```cpp #include using namespace std; unordered_set h; int n,m; int main() { cin>>n; while(n--){ string name; cin>>name; h.insert(name); } cin>>m; string all_older,come_older; int cnt=0; while(m--){ string name; cin>>name; if(h.count(name)){ cnt++; if(all_older.empty() || all_older.substr(6,8)>name.substr(6,8)) all_older=name; } if(come_older.empty() || come_older.substr(6,8)>name.substr(6,8)) come_older=name; } cout<