申请加强数据
查看原帖
申请加强数据
808180
HDS_Acenaphthylene楼主2023/11/21 19:43
// #include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#define int long long
using namespace std;
const unsigned int p = 1145141;
pair<unsigned int, unsigned int >hasht[1000000];
        char sx[20000]; 
signed main() {
    register unsigned int k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> k;
    register auto enda = hasht + k;
    while(k --) {
        cin >> sx;
        register unsigned int now1 = 0, now2 = 0;
        for(register char c : sx)
            if(c)
                now1 = (now1 * p ^ c) ,
                now2 = (now2 * p ^ c);
            else break;
        // s.push_back({now1, now2});
        hasht[k] = {now1, now2};
    }
    sort(hasht, enda);
    cout << unique(hasht, enda) - hasht ;
    return 0;
}

rt,单哈希可过

2023/11/21 19:43
加载中...