Submission #152769

#TimeUsernameProblemLanguageResultExecution timeMemory
152769phillipLozinke (COCI17_lozinke)C++14
100 / 100
54 ms19860 KiB
#include <bits/stdc++.h> using namespace std; long long the,n; string s[100004]; struct trie { int en=0,cnt=0; trie *a[27]={0}; void inse(int x,int y) { if (y==s[x].size()) { en++; cnt++; return; } int ind=s[x][y]-'a'; if (a[ind]==0) a[ind]=new trie; a[ind]->inse(x,y+1); } void ans(int x,int y) { the+=en; en=0; if (y==s[x].size()) return ; if (a[s[x][y]-'a']!=0) a[s[x][y]-'a']->ans(x,y+1); return ; } void rep(int x,int y) { en=cnt; if (y==s[x].size()) return ; if (a[s[x][y]-'a']!=0) a[s[x][y]-'a']->rep(x,y+1); return ; } }; trie tr; int main() { cin>>n; for (int i=0;i<n;i++) { cin>>s[i]; tr.inse(i,0); } for (int i=0;i<n;i++) { for (int j=0;j<s[i].size();j++) tr.ans(i,j); for (int j=0;j<s[i].size();j++) tr.rep(i,j); } cout<<the-n; return 0; } //Sent from Mail for Windows 10

Compilation message (stderr)

lozinke.cpp: In member function 'void trie::inse(int, int)':
lozinke.cpp:13:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (y==s[x].size())
             ~^~~~~~~~~~~~~
lozinke.cpp: In member function 'void trie::ans(int, int)':
lozinke.cpp:27:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (y==s[x].size()) return ;
             ~^~~~~~~~~~~~~
lozinke.cpp: In member function 'void trie::rep(int, int)':
lozinke.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (y==s[x].size()) return ;
             ~^~~~~~~~~~~~~
lozinke.cpp: In function 'int main()':
lozinke.cpp:50:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<s[i].size();j++) tr.ans(i,j);
                          ~^~~~~~~~~~~~
lozinke.cpp:51:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<s[i].size();j++) tr.rep(i,j);
                          ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...