Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
65 lines (53 loc) · 1.15 KB

File metadata and controls

65 lines (53 loc) · 1.15 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
const int MAXN = 100000;
int N;
char str[MAXN];
typedef struct trieNode{
bool mark;
struct trieNode* nextNode[27];
}tN;
tN *root;
void insert_trie(string s, tN* root){
tN* cur = root;
for(int i=0; i<s.size(); i++){
int nc = s[i]-'a';
if(root->nextNode[nc]==NULL){
tN* tmpNode = new tN();
memset(tmpNode->nextNode, 0, sizeof(tmpNode->nextNode));
cur->nextNode[nc] = tmpNode;
cur = tmpNode;
}else{
cur = root->nextNode[nc];
}
cout<<"here -> "<<s[i]<<" "<<cur<<endl;
}
cur->mark = true;
}
void build_trie(){
vector<string> dic;
dic.push_back("out");
dic.push_back("output");
dic.push_back("puton");
dic.push_back("in");
dic.push_back("input");
dic.push_back("one");
root = new tN();
for(int i=0; i<dic.size(); i++){
insert_trie(dic[i], root);
}
}
void work(){
build_trie();
}
int main(){
scanf("%d",&N);
while(N--){
scanf("%s",str);
work();
}
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.