# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
293580 | 2020-09-08T08:19:04 Z | kshitij_sodani | Type Printer (IOI08_printer) | C++14 | 795 ms | 37528 KB |
#include <bits/stdc++.h> using namespace std; #define a first #define b second #define pb push_back typedef long long llo; int n; int ma=0; vector<int> ss; int pre[500001][26]; int co=0; vector<pair<int,string>> adj[500001]; int endd[500001]; void insert(string s){ int cur=0; vector<int> kk; for(int i=0;i<s.size();i++){ if(pre[cur][s[i]-'a']==0){ co+=1; pre[cur][s[i]-'a']=co; string te=""; te+=s[i]; adj[cur].pb({co,te}); } kk.pb(cur); cur=pre[cur][s[i]-'a']; } endd[cur]=1; if(s.size()>ma){ ma=s.size(); ss=kk; } } int vis[5000001]; void dfs(int no,string tt=""){ if(no!=0){ cout<<tt<<endl; } if(endd[no]){ cout<<"P"<<endl; } for(auto j:adj[no]){ if(vis[j.a]==0){ dfs(j.a,j.b); } } for(auto j:adj[no]){ if(vis[j.a]==1){ dfs(j.a,j.b); } } if(vis[no]==0 and no!=0){ cout<<"-"<<endl; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; insert(s); } cout<<((co+co-ma+n))<<endl; for(auto j:ss){ vis[j]=1; } dfs(0); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12160 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12160 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12160 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 12160 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 12160 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 40 ms | 13184 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 132 ms | 16128 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 323 ms | 22084 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 795 ms | 37528 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 647 ms | 31992 KB | Expected EOF |
2 | Halted | 0 ms | 0 KB | - |