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

Ended

Participants:430

Verdict:Wrong Answer
Score:20 / 100
Submitted:2017-08-20 12:49:39

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
#include <unordered_map> 
#include <string> 
#include <vector> 
#include <iostream> 
using namespace std; 
const int MAXN = 10000; 
struct Trie{
    unordered_map<string, Trie*> mp; 
    unordered_map<string, int> cnt_mp; 
}; 
int main(){
    int n; 
    while(cin >> n){
        Trie *root = new Trie(); 
        vector<string> s(n, ""); 
        for(int i=0; i<n; ++i){
            cin >> s[i];  
            Trie *tmp = root; 
            size_t sd = 1, fd = s[i].find('/', sd); 
            while(fd != string::npos){
                string t = s[i].substr( sd, fd - sd ); 
                if(tmp->mp.find( t ) == tmp->mp.end()){
                    tmp->mp[ t ] = new Trie(); 
                    tmp->cnt_mp[ t ] = 1; 
                }else{
                    tmp->cnt_mp[ t ] += 1; 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX