Submission #1093856

#TimeUsernameProblemLanguageResultExecution timeMemory
1093856lambd47Type Printer (IOI08_printer)C++14
0 / 100
45 ms54868 KiB
#include<bits/stdc++.h> using namespace std; const int MX=5e5+1; int trie[MX][27]; char letra[MX]; bool ultimo[MX]; int tempo=0; void add(string s, bool flag){ int idat=0; for(auto c: s){ int nat=c-'a'; if(trie[idat][nat]!=-1){ idat=trie[idat][nat]; } else{ trie[idat][nat]=++tempo; idat=tempo; letra[idat]=c; } if(flag)ultimo[idat]=1; } } int n; bool acabou=0; int cnt=0; void dfs(int node){ if(node!=0)cout<<letra[node]<<"\n"; int esp=-1; bool folha=1; for(int i=0;i<26;i++){ if(trie[node][i]==-1)continue; folha=0; if(ultimo[trie[node][i]]){ esp=trie[node][i]; continue; } dfs(trie[node][i]); } if(esp!=-1){ dfs(esp); } if(folha){cout<<"P\n";cnt++;} if(cnt!=n && !ultimo[node])cout<<"-\n"; } int main(){ cin>>n; for(int i=0;i<MX;i++){ for(int j=0;j<27;j++)trie[i][j]=-1; } vector<string> vec(n); int especial=0; int maior=0; for(int i=0;i<n;i++){cin>>vec[i]; if(maior<vec[i].size()){ maior=vec[i].size(); especial=i; } } for(int i=0;i<n;i++){ if(especial==i){ add(vec[i],1); } else{ add(vec[i],0); } } cout<<2*(tempo)-maior+n; dfs(0); }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:60:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if(maior<vec[i].size()){
      |            ~~~~~^~~~~~~~~~~~~~
#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...