Advertisement
Imran2544

I

Dec 5th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // - - - - - - Data Types - - - - - - //
  5.  
  6. typedef long int LI;
  7. typedef long long LL;
  8.  
  9. // - - - - - - Vectors - - - - - - //
  10. typedef vector<int> VI;
  11. typedef vector<LL> VLL;
  12. typedef vector<string> VS;
  13. typedef vector<double> VD;
  14. typedef vector<VI> VVI;
  15.  
  16. #define scanVI(v, n)        for(int i=0; i<n; i++){ int x; cin >> x; v.PB(x); }
  17. #define scanVLLI(v, n)      for(int i=0; i<n; i++){ LLI x; cin >> x; v.PB(x); }
  18. #define scanVS(v, n)        for(int i=0; i<n; i++){ string x; cin >> x; v.PB(x); }
  19. #define scanVD(v, n)        for(int i=0; i<n; i++){ double x; cin >> x; v.PB(x); }
  20.  
  21. // - - - - - - Maps - - - - - - //
  22. typedef map<int, int> MII;
  23. typedef map<int, string> MIS;
  24. typedef map<int, char> MIC;
  25. typedef map<string, int> MSI;
  26. typedef map<char, int> MCI;
  27. typedef map<int, VI> MIVI;
  28.  
  29. // - - - - - - Pairs - - - - - - //
  30. typedef pair<int, int> PII;
  31. typedef pair<string, string> PSS;
  32. typedef pair<char, char> PCC;
  33. typedef pair<int, string> PIS;
  34. typedef pair<int, char> PIC;
  35. typedef pair<string, char> PSC;
  36.  
  37. // - - - - - - Sets - - - - - - //
  38. typedef set<int> SI;
  39. typedef set<LL> SLL;
  40. typedef set<string> SS;
  41. typedef set<char> SC;
  42. // - - - - - - - - - - - - - - - - - - //
  43.  
  44. #define PF                  printf
  45. #define SF                  scanf
  46. #define PB                  push_back
  47. #define POP                 pop_back()
  48. #define PP                  prev_permutation
  49. #define NP                  next_permutation
  50. #define MP                  make_pair
  51. #define CLRN(a, b)          memset(a, b, sizeof(a))
  52. #define CLR(a)              memset(a, 0, sizeof(a))
  53. #define ALL(a)              a.begin(), a.end()
  54. #define ALLN(a, n)          (a, a+n)
  55. #define BSRCN(a, n, x)      binary_search(ALLN(a, n), x)
  56. #define BSRC                binary_search
  57. #define MAX                 10000007
  58. #define MIN                 -10000007
  59. #define PI                  acos(-1)
  60. #define BR                  PF("\n")
  61. #define FastIO              ios_base::sync_with_stdio(false)
  62. #define READ()              freopen("input.txt", "r", stdin)
  63. #define WRITE()             freopen("output.txt", "w", stdout)
  64. #define len(a)              a.length()
  65. #define rsort(a)            sort(a.rbegin(), a.rend())
  66. #define pvec(v)             for(auto x: v) cout<<x<<" "
  67.  
  68. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
  69. /*----------------------Graph Moves----------------*/
  70. int ROW[]={+1,-1,+0,+0};
  71. int COL[]={+0,+0,+1,-1};
  72.  
  73. int X[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
  74. int Y[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
  75.  
  76. int KX[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
  77. int KY[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
  78. /*------------------------------------------------*/
  79.  
  80. LL GCD(LL a, LL b) { return b == 0 ? a : GCD(b , a % b); }
  81. int LCM(int a, int b) { return a * (b/GCD(a, b)); }
  82. bool CMP(int a, int b) { return a>b; }
  83.  
  84. // - - - - - - - - - - - - - - - - - - - - - - - - - - - END - - - - - - - - - - - - - - - - - - - - - - - - - //
  85.  
  86.  
  87. int main()
  88. {
  89.     // FastIO;
  90.     #ifdef VAMP
  91.      clock_t Start=clock();
  92.      freopen("in.txt", "r", stdin);
  93.      freopen("out.txt", "w", stdout);
  94.     #endif
  95.    
  96.     int t;
  97.     cin>>t;
  98.     while (t--) {
  99.         int n;
  100.         cin>>n;
  101.         string s;
  102.         // getchar();
  103.         map<string, string> mp;
  104.         vector<string> v;
  105.         // getchar();
  106.         for (int i=0; i<=n; i++) {
  107.             getline(cin, s);
  108.             stringstream ss(s);
  109.             string word, type, name, type1, type2, typed;
  110.             int count=0;
  111.             // cout<<"-->"<<i<<endl;
  112.             while (ss>>word) {
  113.                 count++;
  114.                 if (count==6) word.pop_back();
  115.                 else if (count==2 and word[len(word)-1]==';')
  116.                     word.pop_back();
  117.                 // cout<<count<<" "<<word<<endl;
  118.                 if (count==1) {
  119.                     type=word;
  120.                 }
  121.                 if (count==2) {
  122.                     // cout<<word<<endl;
  123.                     // if (word[len(word)-1]==';') {
  124.                     //     word.pop_back();
  125.                     // }
  126.                     name=word;
  127.                     // mp[name]=type;
  128.                     // cout<<"ok"<<" "<<name<<" "<<mp[name]<<endl;
  129.                 }
  130.  
  131.                 if (type!="auto") {
  132.                     // name.pop_back();
  133.                     // cout<<name<<endl;
  134.                     mp[name]=type;
  135.                     break;
  136.                 }
  137.  
  138.                 else {
  139.                     if (count==4) {
  140.                         type1=mp[word];
  141.                         // cout<<word<<" "<<type1<<endl;
  142.                     }
  143.                     else if (count==6) {
  144.                         word.pop_back();
  145.                         type2=mp[word];
  146.                         // cout<<type1<<" "<<type2<<endl;
  147.                         if (type2=="double" or type1=="double") {
  148.                             typed="double";
  149.                         }
  150.                         else if (type2=="float" or type1=="float") {
  151.                             typed="float";
  152.                         }
  153.                         else if (type2=="int" and type1=="int") {
  154.                             typed="int";
  155.                         }
  156.                         mp[name]=typed;
  157.                         v.push_back(name);
  158.                     }
  159.                 }
  160.                
  161.             }
  162.             for (int j=0; j<v.size(); j++) {
  163.                 cout<<mp[v[j]]<<" "<<v[j]<<endl;
  164.             }
  165.             // cout<<endl;
  166.         }
  167.     }
  168.    
  169.     END:
  170.     #ifdef VAMP
  171.      fprintf(stderr, "\n>>Runtime: %.10fs\n", (double) (clock() - Start) / CLOCKS_PER_SEC);
  172.     #endif
  173.     return 0;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement