hiho week 62 register

Ended

Participants:714

Verdict:Accepted
Score:100 / 100
Submitted:2015-09-10 15:51:31

Lang:GCC

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
25
26
27
28
29
30
31
#include <stdio.h>
#define MAXN 20000
#define MAX_LENGTH 30
/* uses trie tree */
struct {
    int next[26 + 10 + 1];
    int data;
} Last_visit[MAXN * MAX_LENGTH];
int tree_end = 1;
char url[MAX_LENGTH + 1];
/* projection[i] stores the index in Last_visit[] of a[i] */
int projection[MAXN + 1];
int code_of[128];
void init() {
    int i;
    for (i = '0'; i <= '9'; ++i)
        code_of[i] = i - '0' + 26;
    for (i = 'a'; i <= 'z'; ++i)
        code_of[i] = i - 'a';
    code_of['.'] = 26 + 10;
}
/* x is the index in a[], initial value is 0 if not set */
int* get(int x) {
    if (projection[x] == 0) {
        int index = 0, i, code;
        for (i = 0; url[i]; ++i) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX