求助
查看原帖
求助
812890
fanwenbing楼主2023/3/30 15:22
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long ULL;
const int P = 131, N = 1e5 + 10;
vector<ULL> vec;
ULL h[N], p[N], a[N];
ULL f(string s) {
	ULL res = 0;
	for (int i = 0; i < s.size(); i++)
		res = res * P + (ULL)s[i];
	return res;
}
int n, ret;
string s;
int main() {
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		cin >> s;
		vec.push_back(f(s));
	}

	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()));
	
	printf("%d", vec.size());
  
	return 0;
}
2023/3/30 15:22
加载中...