hiho Week 15 register

Ended

Participants:1653

Verdict:Accepted
Score:100 / 100
Submitted:2014-10-14 00:08:04

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
25
26
27
28
29
30
31
//hashmapzieiuk@hihocoder
#include <stdio.h>
#include <string.h>
#include <vector>
#include <list>
using namespace std;
vector<int> unionset;
vector<bool> visited;
vector<char*> namevec;
vector<int> result;
vector<list<int> > rlist;
vector<pair<int, int> > req; 
typedef list<int>::iterator iter;
const int N = 100003;
const int L = 101;
struct hashnode {
    char str[L];
    int key;
    struct hashnode *next;
} nodes[N << 1], *hashtable[N];
int hashid;
int hashfind(int hashkey, char *s)
{
    struct hashnode *node;
    for (node = hashtable[hashkey]; node && strcmp(node->str, s); node = node->next)
        ;
    return node == NULL ? -1 : (node - nodes);
}
int hashinsert(int hashkey, char *s, int key)
{
    strcpy(nodes[hashid].str, s);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX