标签:source sea strong out several lan 总数 The ted
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 66022 Accepted Submission(s): 16607
#include <iostream> #include <cstdio> #include <sstream> #include <cstring> using namespace std; int pos; int trie[100001][26]; bool ex[100001]; int Insert(string s) { int i = 0,c = 0,len = s.size(); while(i < len) { int d = s[i] - ‘a‘; if(!trie[c][d]) { trie[c][d] = ++ pos; } c = trie[c][d]; i ++; } if(!ex[c]) { ex[c] = true; return 1; } return 0; } int main() { string s; while(getline(cin,s) && s != "#") { istringstream in(s); memset(ex,false,sizeof(ex)); string t; int c = 0; while(in>>t) { c += Insert(t); } printf("%d\n",c); } }
标签:source sea strong out several lan 总数 The ted
原文地址:https://www.cnblogs.com/8023spz/p/9591319.html