Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. struct Car
  10. {
  11.     int x, y;
  12.     int vx, vy;
  13. };
  14. //Įvestos mašinėlės koordinates ir pagreiti
  15. struct Wreck
  16. {
  17.     int x, y;
  18. };
  19. //ivestos balos koordinates
  20. int main()
  21. {
  22.    
  23.     while (1) {
  24.        
  25.         int myScore;
  26.         cin >> myScore; cin.ignore();
  27.         int enemyScore1;
  28.         cin >> enemyScore1; cin.ignore();
  29.         int enemyScore2;
  30.         cin >> enemyScore2; cin.ignore();
  31.        
  32.         int myRage;
  33.         cin >> myRage; cin.ignore();
  34.         int enemyRage1;
  35.         cin >> enemyRage1; cin.ignore();
  36.         int enemyRage2;
  37.         cin >> enemyRage2; cin.ignore();
  38.        
  39.         int unitCount;
  40.        
  41.         Car reaper;
  42.         Car destro;
  43.         Car doof;
  44.         Car reaper1;
  45.        
  46.         vector<Wreck> wreck;
  47.         vector<Car> tanker;
  48.        
  49.         cin >> unitCount; cin.ignore();
  50.         for (int i = 0; i < unitCount; i++) {
  51.             int unitId;
  52.             int unitType;
  53.             int player;
  54.             float mass;
  55.             int radius;
  56.             int x;
  57.             int y;
  58.             int vx;
  59.             int vy;
  60.             int extra;
  61.             int extra2;
  62.             cin >> unitId >> unitType >> player >> mass >> radius >> x >> y >> vx >> vy >> extra >> extra2; cin.ignore();
  63. //ciklas
  64.             if(unitType == 0 && player == 0)
  65.             {
  66.                 reaper.x = x;
  67.                 reaper.y = y;
  68.                 reaper.vx = vx;
  69.                 reaper.vy = vy;
  70.             }
  71. //issaugoti savo masineles koordinates ir pagreiti
  72.             if(unitType == 0 && player == 1)
  73.             {
  74.                 reaper1.x = x;
  75.                 reaper1.y = y;
  76.                 reaper1.vx = vx;
  77.                 reaper1.vy = vy;
  78.             }
  79. //issaugoti kitu zaideju koordinates ir pagreiti          
  80.             if(unitType == 1 && player == 0)
  81.             {
  82.                 destro.x = x;
  83.                 destro.y = y;
  84.                 destro.vx = vx;
  85.                 destro.vy = vy;
  86.             }
  87. //issaugoti destro koordinates ir pagreiti          
  88.             if(unitType == 2 && player == 0)
  89.             {
  90.                 doof.x = x;
  91.                 doof.y = y;
  92.                 doof.vx = vx;
  93.                 doof.vy = vy;
  94.             }
  95. //issaugoti doof koordinates ir pagreiti            
  96.             if(unitType == 3)
  97.             {
  98.                 tanker.push_back({x,y,vx,vy});
  99.             }
  100. //issaugoti tanker duomenis          
  101.             if(unitType == 4)
  102.             {
  103.                 wreck.push_back({x,y});
  104.             }
  105.         }
  106. //issaugoti balos duomenis      
  107.         int distance = 1000000;
  108.         int nr = -1;
  109.        
  110.         for(int i = 0; i < wreck.size(); i++)
  111.         {
  112.             int ats = sqrt(pow(reaper.x - wreck[i].x, 2)+pow(reaper.y - wreck[i].y, 2));
  113.            
  114.             if(distance  > ats)
  115.             {
  116.                 distance = ats;
  117.                 nr = i;
  118.             }
  119.         }
  120. //apskaiciuoti atstuma nuo reaper iki balos
  121.         if(nr == -1)
  122.         {
  123.             cout << "WAIT" << endl;
  124.         }
  125.         else
  126.         {
  127.             cout << wreck[nr].x - reaper.vx << " " << wreck[nr].y - reaper.vy << " 300" << endl;
  128.         }
  129.        
  130.         distance = 1000000;
  131.         nr = -1;
  132. //jei atsumas geras galima judeti        
  133.         for(int i = 0; i < tanker.size(); i++)
  134.         {
  135.             int ats = sqrt(pow(destro.x - tanker[i].x, 2)+pow(destro.y - tanker[i].y, 2));
  136.            
  137.             if(distance  > ats)
  138.             {
  139.                 distance = ats;
  140.                 nr = i;
  141.             }
  142.         }
  143. //apskaiciuoti atstuma nuo destro iki tanker        
  144.         if(nr == -1)
  145.         {
  146.             cout << "WAIT" << endl;
  147.         }
  148.         else
  149.         {
  150.             cout << tanker[nr].x + tanker[nr].vx - destro.vx << " " << tanker[nr].y + tanker[nr].vy - destro.vy << " 300" << endl;
  151.         }
  152.        
  153.        
  154.         cout << reaper1.x + reaper1.vx << " " << reaper1.y + reaper1.vy << " 300" << endl;
  155.     }
  156. //jei atsumas geras galima judeti
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement