7 solutions

  • 4
    @ 2022-10-13 20:59:55

    优化单哈希就可以过!

    // code
    #pragma GCC optimize("Ofast", "inline")
    #include <bits/stdc++.h>
    #define int unsigned long long
    #define SIZE 200010
    #define all(x) x.begin(), x.end()
    #define debug(x) cout<<#x<<":"<<x<<endl;
    using namespace std;
    
    char s[4000005];
    unordered_map<int, int> S;
    
    signed main()
    {
    	signed n; scanf("%d", &n);
    	for(signed i=0; i<n; i++)
    	{
    		scanf("%s", s);
    		int x=0;
    		for(signed i=0; i<strlen(s); i++) x=(x*(1<<7)+s[i]);
    		S[x];
    	}
    	printf("%u", S.size());
    
        return 0;
    }
    

    Information

    ID
    180
    Time
    300~1000ms
    Memory
    1024MiB
    Difficulty
    3
    Tags
    # Submissions
    839
    Accepted
    131
    Uploaded By