Advertisement
Guest User

SkyNet Revolution - Episode 2

a guest
Jul 24th, 2019
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12.  
  13. int nodes1[500];
  14. int nodes2[500];
  15. int gateways[20];
  16.  
  17. int nodesgateway1[500];
  18. int nodesgateway2[500];
  19.  
  20. int nodesneargateway1[500];
  21. int nodesneargateway2[500];
  22.  
  23. int main()
  24. {
  25.    
  26.     for (int i; i < 500; i++)
  27.     {
  28.         nodes1[i] = -100;
  29.         nodes2[i] = -100;
  30.        
  31.         nodesgateway1[500] = -100;
  32.         nodesgateway2[500] = -100;
  33.  
  34.         nodesneargateway1[500] = -100;
  35.         nodesneargateway2[500] = -100;
  36.     }
  37.    
  38.     for (int i; i < 20; i++)
  39.     {
  40.         gateways[i] = -100;  
  41.     }
  42.    
  43.     int N; // the total number of nodes in the level, including the gateways
  44.     int L; // the number of links
  45.     int E; // the number of exit gateways
  46.     cin >> N >> L >> E; cin.ignore();
  47.     for (int i = 0; i < L; i++) {
  48.         int N1; // N1 and N2 defines a link between these nodes
  49.         int N2;
  50.         cin >> N1 >> N2; cin.ignore();
  51.         nodes1[i] = N1;
  52.         nodes2[i] = N2;
  53.     }
  54.     for (int i = 0; i < E; i++) {
  55.         int EI; // the index of a gateway node
  56.         cin >> EI; cin.ignore();
  57.     }
  58.  
  59.     // game loop
  60.     while (1) {
  61.         int SI; // The index of the node on which the Skynet agent is positioned this turn
  62.         cin >> SI; cin.ignore();
  63.        
  64.         for (int i; i < 500; i++)
  65.         {
  66.             if (nodes1[i] != -100 && nodes2[i] != -100)
  67.             {
  68.                 for (int i2; i2 < 20; i2++)
  69.                 {
  70.                     if (nodes1[i] == gateways[i2] || nodes2[i] == gateways[i2])
  71.                     {
  72.                         nodesgateway1[i] = nodes1[i];
  73.                         nodesgateway2[i] = nodes2[i];
  74.                     }
  75.                 }
  76.             }
  77.         }
  78.        
  79.         for (int i; i < 500; i++)
  80.         {
  81.             if (nodes1[i] != -100 && nodes2[i] != -100)
  82.             {
  83.                 if (nodes1[i] == nodesgateway1[i] || nodes2[i] == nodesgateway2[i] || nodes2[i] == nodesgateway1[i] || nodes1[i] == nodesgateway2[i])
  84.                 {
  85.                     nodesneargateway1[i] = nodes1[i];
  86.                     nodesneargateway2[i] = nodes2[i];
  87.                 }
  88.             }
  89.         }
  90.        
  91.        
  92.         for (int i; i < 500; i++)
  93.         {
  94.             if (nodesgateway1[i] == SI || nodesgateway2[i] == SI) cout<<nodesgateway1[i]<<" "<<nodesgateway2[i]<<endl;
  95.             else
  96.             {
  97.                 if (nodesneargateway1[i] == SI || nodesneargateway2[i] == SI)
  98.                 {
  99.                     for (int i2; i2 < 500; i2++)
  100.                     {
  101.                         if (nodesgateway2[i2] == nodesneargateway1[i] || nodesgateway1[i2] == nodesneargateway2[i] || nodesgateway1[i2] == nodesneargateway1[i] || nodesgateway2[i2] == nodesneargateway2[i])
  102.                         {
  103.                             cout<<nodesgateway1[i2]<<" "<<nodesgateway2[i2]<<endl;  
  104.                         }
  105.                     }
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement