Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- created: 2022-08-08-21.25.18
- ***/
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- template<typename U> using ordered_set=tree<U, null_type,less<U>,rb_tree_tag,tree_order_statistics_node_update>;
- #define ll long long
- #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
- #define get_lost_idiot return 0
- #define nl '\n'
- struct st
- {
- string p,v;
- } a[2220];
- bool cmp(st b,st c)
- {
- if(b.p.size()==c.p.size()) return b.p<c.p;
- else return b.p.size()<c.p.size();
- }
- set<string>x;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- string s;
- while(cin>>s && s!="12")
- {
- x.clear();
- ll n,m,i,j,k,l=0;
- n=0;
- while(s[1]!=')')
- {
- ll j=1;
- string p="",v="";
- while(s[j]!=',')
- {
- v+=s[j];
- j++;
- }
- while(s[j]!=')')
- {
- p+=s[j];
- j++;
- }
- a[n].p=p;
- a[n].v=v;
- n++;
- cin>>s;
- }
- sort(a,a+n,cmp);
- for(i=0; i<n; i++)
- {
- if(x.count(a[i].p))
- {
- l=1;
- break;
- }
- if(a[i].p.size()>1)
- {
- if(!x.count(a[i].p.substr(0,a[i].p.size()-1)))
- {
- l=1;
- break;
- }
- }
- x.insert(a[i].p);
- }
- if(l) cout<<"not complete"<<nl;
- else
- {
- for(i=0; i<n; i++)
- {
- cout<<a[i].v;
- if(i<n-1) cout<<" ";
- else cout<<nl;
- }
- }
- }
- get_lost_idiot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement