fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. map<string,string> a,b;
  5. int main() {
  6. /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  7. string str,inpu,outp;
  8. int n;
  9. cin>>n;
  10. int nu = n;
  11. while(nu--){
  12. cin>>str>>inpu>>outp;
  13. a[inpu]=str;
  14. b[inpu]=outp;
  15. }
  16. stack<string> st;
  17. st.push(a["inp"]);
  18. string tmp = b["inp"];
  19. for(int i=0;i<n-1;i++){
  20. st.push(a[tmp]);
  21. tmp = b[tmp];
  22. }
  23. while(!st.empty()){
  24. cout<<st.top();
  25. st.pop();
  26. if(!st.empty())
  27. cout<<".";
  28. }
  29. cout<<endl;
  30. return 0;
  31. }
Time limit exceeded #stdin #stdout 5s 2884KB
stdin
Standard input is empty
stdout
Standard output is empty