Advertisement
fuadnafiz98

Untitled

Jun 14th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. /* Input format
  2.  
  3.   3 3
  4.   a b c
  5.   a b
  6.   b c
  7.   c a
  8.  
  9. */
  10. #include<bits/stdc++.h>
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15.   int node, edge;
  16.   cin >> node >> edge;
  17.   map<string, int>mp;
  18.   map<int, string>revMp;
  19.   for(int i = 0; i < node; i++) {
  20.     string in;
  21.     cin >> in;
  22.     mp[in] = i;
  23.     revMp[i] = in;
  24.   }
  25. /**
  26.   * converting string to number
  27.   */
  28.   for(int i = 0; i < edge; i++) {
  29.     string a, b;
  30.     cin >> a >> b;
  31.     cout << mp[a] << ' ' << mp[b] << endl;
  32.   }
  33. /**
  34.   * converting number to string
  35.   */
  36.   for(int i = 0; i < node; i++) cout << revMp[i] << ' ';
  37.   cout << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement