Norvager

http://lerna.pro/contests/157/7

Oct 30th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.19 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <string>
  6. using namespace std;
  7. struct moniker {
  8.     string name;
  9.     bool gen;
  10. };
  11.  
  12. vector <moniker> nominal;
  13. vector <pair <string, string>> type;
  14. vector <vector <pair <string, string>>> rel;
  15. ///void Rel()
  16.  
  17. void Com_And_Fill(string n1, string rap, string n2)
  18. {
  19.     int ind1, ind2;
  20.     for (int i = 0; i < nominal.size(); i++)
  21.     {
  22.         if (n1 == nominal[i].name)
  23.         {
  24.             ind1 = i;
  25.         }
  26.         if (n2 == nominal[i].name)
  27.         {
  28.             ind2 = i;
  29.         }
  30.     }
  31.     rel[ind1].push_back(make_pair(n2, rap));
  32.     if (nominal[ind1].gen)
  33.     {
  34.         for ( int i = 0; i < 11; i++)
  35.             if (rap == type[i].first)
  36.             {
  37.                 if (i == 0)
  38.                     rel[ind2].push_back(make_pair(n1, type[0].second));
  39.                 else if (i == 1)
  40.                 {
  41.                     if (nominal[ind2].gen)
  42.                         rel[ind2].push_back(make_pair(n1, type[2].first));
  43.                     else rel[ind2].push_back(make_pair(n1, type[2].second));
  44.                 }
  45.                 else if (i == 2)
  46.                 {
  47.                     if (nominal[ind2].gen)
  48.                         rel[ind2].push_back(make_pair(n1, type[1].first));
  49.                     else rel[ind2].push_back(make_pair(n1, type[1].second));
  50.                 }
  51.                 else if (i == 3)
  52.                 {
  53.                     if(nominal[ind2].gen)
  54.                         rel[ind2].push_back(make_pair(n1, type[3].first));
  55.                     else rel[ind2].push_back(make_pair(n1, type[3].second));
  56.                 }
  57.                 else if (i == 4)
  58.                 {
  59.                     if (nominal[ind2].gen)
  60.                         rel[ind2].push_back(make_pair(n1, type[5].first));
  61.                     else rel[ind2].push_back(make_pair(n1, type[5].second));
  62.                 }
  63.                 else if (i == 5)
  64.                 {
  65.                     if (nominal[ind2].gen)
  66.                         rel[ind2].push_back(make_pair(n1, type[4].first));
  67.                     else rel[ind2].push_back(make_pair(n1, type[4].second));
  68.                 }
  69.                 else if (i == 6)
  70.                 {
  71.                     if (nominal[ind2].gen)
  72.                         rel[ind2].push_back(make_pair(n1, type[7].first));
  73.                     else rel[ind2].push_back(make_pair(n1, type[7].second));
  74.                 }
  75.                 else if (i == 7)
  76.                 {
  77.                     if (nominal[ind2].gen)
  78.                         rel[ind2].push_back(make_pair(n1, type[6].first));
  79.                     else rel[ind2].push_back(make_pair(n1, type[6].second));
  80.                 }
  81.                 else if (i == 8)
  82.                 {
  83.                     if (nominal[ind2].gen)
  84.                         rel[ind2].push_back(make_pair(n1, type[9].first));
  85.                     else rel[ind2].push_back(make_pair(n1, type[9].second));
  86.                 }
  87.                 else if (i == 9)
  88.                     rel[ind2].push_back(make_pair(n1, type[8].first));
  89.                 else if (i == 10)
  90.                     rel[ind2].push_back(make_pair(n1, type[8].second));
  91.                 break;
  92.             }
  93.     }
  94.     else
  95.     {
  96.         for (int i = 0; i < 11; i++)
  97.             if (rap == type[i].second)
  98.             {
  99.                 if (i == 0)
  100.                     rel[ind2].push_back(make_pair(n1, type[0].first));
  101.                 else if (i == 1)
  102.                 {
  103.                     if (nominal[ind2].gen)
  104.                         rel[ind2].push_back(make_pair(n1, type[2].first));
  105.                     else rel[ind2].push_back(make_pair(n1, type[2].second));
  106.                 }
  107.                 else if (i == 2)
  108.                 {
  109.                     if (nominal[ind2].gen)
  110.                         rel[ind2].push_back(make_pair(n1, type[1].first));
  111.                     else rel[ind2].push_back(make_pair(n1, type[1].second));
  112.                 }
  113.                 else if (i == 3)
  114.                 {
  115.                     if (nominal[ind2].gen)
  116.                         rel[ind2].push_back(make_pair(n1, type[3].first));
  117.                     else rel[ind2].push_back(make_pair(n1, type[3].second));
  118.                 }
  119.                 else if (i == 4)
  120.                 {
  121.                     if (nominal[ind2].gen)
  122.                         rel[ind2].push_back(make_pair(n1, type[5].first));
  123.                     else rel[ind2].push_back(make_pair(n1, type[5].second));
  124.                 }
  125.                 else if (i == 5)
  126.                 {
  127.                     if (nominal[ind2].gen)
  128.                         rel[ind2].push_back(make_pair(n1, type[4].first));
  129.                     else rel[ind2].push_back(make_pair(n1, type[4].second));
  130.                 }
  131.                 else if (i == 6)
  132.                 {
  133.                     if (nominal[ind2].gen)
  134.                         rel[ind2].push_back(make_pair(n1, type[7].first));
  135.                     else rel[ind2].push_back(make_pair(n1, type[7].second));
  136.                 }
  137.                 else if (i == 7)
  138.                 {
  139.                     if (nominal[ind2].gen)
  140.                         rel[ind2].push_back(make_pair(n1, type[6].first));
  141.                     else rel[ind2].push_back(make_pair(n1, type[6].second));
  142.                 }
  143.                 else if (i == 8)
  144.                 {
  145.                     if (nominal[ind2].gen)
  146.                         rel[ind2].push_back(make_pair(n1, type[9].first));
  147.                     else rel[ind2].push_back(make_pair(n1, type[9].second));
  148.                 }
  149.                 else if (i == 9)
  150.                     rel[ind2].push_back(make_pair(n1, type[8].first));
  151.                 else if (i == 10)
  152.                     rel[ind2].push_back(make_pair(n1, type[8].second));
  153.                 break;
  154.             }
  155.     }
  156. }
  157.  
  158. int main()
  159. {
  160.     type.push_back(make_pair("Husband", "Wife"));//0
  161.     type.push_back(make_pair("Father", "Mother"));//1
  162.     type.push_back(make_pair("Son", "Daughter"));//2
  163.     type.push_back(make_pair("Brother", "Sister"));//3
  164.     type.push_back(make_pair("Grandfather", "Grandmother"));//4
  165.     type.push_back(make_pair("Grandson", "Granddaughter"));//5
  166.     type.push_back(make_pair("Nephew", "Niece"));//6
  167.     type.push_back(make_pair("Uncle", "Aunt"));//7
  168.     type.push_back(make_pair("Son_In_Law", "Daughter_In_Law"));//8
  169.     type.push_back(make_pair("Father_In_Law_From_Wife", "Mother_In_Law_From_Wife"));//9
  170.     type.push_back(make_pair("Father_In_Law_From_Husband", "Mother_In_Law_From_Husband"));//10
  171.     int N;
  172.     scanf("%d", &N);
  173.     nominal.resize(N);
  174.     rel.resize(N);
  175.     string a, b, c;
  176.     for (int i = 0; i < N; ++i)
  177.     {
  178.         cin >> nominal[i].name >> a;
  179.         if (a[0] == 'M')
  180.             nominal[i].gen = true;
  181.         else nominal[i].gen = false;
  182.     }
  183.     int M;
  184.     scanf("%d", &M);
  185.     for (int i = 0; i < M; ++i)
  186.     {
  187.         cin >> a >> b >> c;
  188.         Com_And_Fill(a, b, c);
  189.     }
  190.     return 0;
  191. }
Add Comment
Please, Sign In to add comment