[Offer收割]编程练习赛51 register

Ended

Participants:280

Verdict:Accepted
Score:100 / 100
Submitted:2018-03-18 12:13:07

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
set<ull>s;
char str[1000005];
int main(){
    int n; scanf("%d", &n);
    while (n--){
        scanf("%s", str);
        ull ha = 0;
        int len = strlen(str);
        for (int i = 1; i < len; i++){
            ha *= 27;
            if (str[i] >= str[i - 1]) ha += str[i] - str[i - 1];
            else ha += str[i] - str[i - 1] + 26;
        }
        s.insert(ha);
    }
    printf("%d\n", s.size());
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX