跳到正文

题解

题解 P3370 【【模板】字符串哈希】

Retired_OIer约 1 分钟
原文
文章信息与版本

文章信息

发布
2019年10月27日
收录
2026年9月2日
更新
2026年11月10日
篇幅
约 1 分钟
题目
P3370

版本

  1. v1当前

下面的大佬发了一堆很长很长的程序,殊不知我们C++有个伟大的东西——STL(STL大法好)使用set可以自动去重,最后输出set容器的长度即可! 程序很短

C++
#include<bits/stdc++.h>
using namespace std;
set<string>s;
int n;
string a;
int main() {
	cin >> n;
	while(n--) {
		cin >> a;//输入
		s.insert(a);//把a插入s中
	}
	cout << s.size();//输出长度
	return 0;//十分完美
}
原文