Submission #850698

#TimeUsernameProblemLanguageResultExecution timeMemory
850698abcvuitunggioType Printer (IOI08_printer)C++17
100 / 100
71 ms50776 KiB
#include <bits/stdc++.h> using namespace std; int n,id,ke[500001][26],d[500001],w[500001]; string s,t; void add(){ int cur=0; for (char c:s){ if (!ke[cur][c-'a']){ ke[cur][c-'a']=++id; d[id]=d[cur]+1; } cur=ke[cur][c-'a']; } w[cur]=1; } void dfs(int u, int b){ for (int i=0;i<26;i++) if (!(b&&i==t[d[u]]-'a')&&ke[u][i]){ cout << (char)(i+'a') << '\n'; dfs(ke[u][i],0); } if (w[u]) cout << "P\n"; if (b){ if (d[u]!=t.length()-1){ cout << t[d[u]] << '\n'; dfs(ke[u][t[d[u]]-'a'],1); } } else cout << "-\n"; } int main(){ ios_base::sync_with_stdio(NULL);cin.tie(nullptr); cin >> n; for (int i=0;i<n;i++){ cin >> s; add(); if (t.length()<s.length()) t=s; } cout << id*2-t.length()+n << '\n'; t+=' '; dfs(0,1); }

Compilation message (stderr)

printer.cpp: In function 'void dfs(int, int)':
printer.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if (d[u]!=t.length()-1){
      |             ~~~~^~~~~~~~~~~~~~
#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...