版本比较
字典树
正文
增加 8 行删除 8 行
108 行未改动全部展开1091101111121131131141151161161171181191204 行未改动125126127128129129130131132133133134135136137138139140141141142143144144145146147148149150151152152153154155156157158159160161162162163108 行未改动全部展开 if (c >= 'a' && c <= 'z') return c - 'a'; if (c >= 'A' && c <= 'Z') return c - 'A' + 26; return c - '0' + 52;}void insert(string s) void insert(string s){ int len = s.size(), u = 0; for (int i = 0; i < len; i++) for (int i = 0; i < len; i++) { int c = get_sum(s[i]); if (node[u][c] == 0) {4 行未改动 } vis[u]++; return;}int search(string s) int search(string s){ int len = s.size(); int u = 0; for (int i = 0; i < len; i++) for (int i = 0; i < len; i++) { int c = get_sum(s[i]); if (node[u][c] == 0) return 0; u = node[u][c]; } return vis[u]++;}signed main() signed main(){ cin >> n; for (int i = 1; i <= n; i++) for (int i = 1; i <= n; i++) { string s; cin >> s; insert(s); } int m; cin >> m; while(m--) while(m--) { string s; cin >> s; int x = search(s); if (x == 0) cout << "WRONG\n"; else if (x == 1) cout << "OK\n"; else cout << "REPEAT\n"; } return 0;} }```