Submission #1103984

#TimeUsernameProblemLanguageResultExecution timeMemory
1103984LeonidCukType Printer (IOI08_printer)C++17
100 / 100
137 ms98568 KiB
#include <bits/stdc++.h> using namespace std; struct trie { bool check=false; trie* a[26]; trie() { for(int i=0;i<26;i++)a[i]=nullptr; } }; string res=""; void peso(trie* m,bool check1,int j) { if(m->check)cout<<"P"<<"\n"; if(j==res.size()&&check1==false) { cout<<"-"<<"\n"; return; } else if(j==res.size())return; int t=res[j]-'a'; for(int i=0;i<26;i++) { if(i!=t&&m->a[i]!=nullptr) { cout<<char('a'+i)<<"\n"; peso(m->a[i],0,j+1); } } if(m->a[t]!=nullptr) { cout<<char('a'+t)<<"\n"; peso(m->a[t],check1,j+1); } if(!check1)cout<<"-"<<"\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,cnt=0,bb=0; cin>>n; string a; trie *root=new trie(); for(int i=0;i<n;i++) { cin>>a; trie *temp=root; if(a.size()>bb) { bb=a.size(); res=a; } for(int j=0;j<a.size();j++) { int t=a[j]-'a'; if(temp->a[t]==nullptr) { temp->a[t]=new trie(); cnt++; } temp=temp->a[t]; } temp->check=true; } cout<<2*cnt-bb+n<<"\n"; peso(root,1,0); return 0; }

Compilation message (stderr)

printer.cpp: In function 'void peso(trie*, bool, int)':
printer.cpp:16:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if(j==res.size()&&check1==false)
      |        ~^~~~~~~~~~~~
printer.cpp:21:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     else if(j==res.size())return;
      |             ~^~~~~~~~~~~~
printer.cpp: In function 'int main()':
printer.cpp:50:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |         if(a.size()>bb)
      |            ~~~~~~~~^~~
printer.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int j=0;j<a.size();j++)
      |                     ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...