Submission #115190

#TimeUsernameProblemLanguageResultExecution timeMemory
115190CaroLindaType Printer (IOI08_printer)C++14
80 / 100
1079 ms56932 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define lp(i,a,b) for(int i=a;i<b;i++) #define ll long long #define ff first #define ss second #define pb push_back const int MAXN = 25005; const int ALF= 30; using namespace std ; int n ; int trie[MAXN*20][ALF] , cnt ; int separa = 1 ; vector<char> ans ; bool marc[MAXN*20] ; void add( string str ) { int t = str.size() ; int cur = 0 ; lp(i,0,t) { int k = str[i] - 'a' ; if(trie[cur][k] == 0) trie[cur][k] = ++cnt ; cur = trie[cur][k] ; } marc[cur] =true; } bool comp(string s1, string s2) { return s1.size() > s2.size() ; } void dfs(int x) { if(marc[x]) ans.pb('P') ; int ok= -1 ; lp(i,0,27) { if( trie[x][i] == separa ) { ok = i+'a' ; continue ; } if(trie[x][i] == 0) continue ; ans.pb( i + 'a' ) ; dfs( trie[x][i] ) ; ans.pb('-') ; } if(ok!=-1) { ans.pb(ok) ; dfs(separa++) ; } } int main() { ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cin>>n ; string v[MAXN] ; cin>>v[0] ; lp(i,1,n) { cin>>v[i] ; if( v[i].size() >v[0].size() ) swap(v[0] , v[i]) ; } lp(i,0,n) add(v[i]) ; dfs(0) ; cout<<ans.size() <<endl ; lp(i,0,ans.size() ) cout<<ans[i]<<endl ; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:4:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define lp(i,a,b) for(int i=a;i<b;i++)
printer.cpp:92:5:
  lp(i,0,ans.size() ) cout<<ans[i]<<endl ;
     ~~~~~~~~~~~~~~              
printer.cpp:92:2: note: in expansion of macro 'lp'
  lp(i,0,ans.size() ) cout<<ans[i]<<endl ;
  ^~
#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...