Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- struct Car
- {
- int x, y;
- int vx, vy;
- };
- //Įvestos mašinėlės koordinates ir pagreiti
- struct Wreck
- {
- int x, y;
- };
- //ivestos balos koordinates
- int main()
- {
- while (1) {
- int myScore;
- cin >> myScore; cin.ignore();
- int enemyScore1;
- cin >> enemyScore1; cin.ignore();
- int enemyScore2;
- cin >> enemyScore2; cin.ignore();
- int myRage;
- cin >> myRage; cin.ignore();
- int enemyRage1;
- cin >> enemyRage1; cin.ignore();
- int enemyRage2;
- cin >> enemyRage2; cin.ignore();
- int unitCount;
- Car reaper;
- Car destro;
- Car doof;
- Car reaper1;
- vector<Wreck> wreck;
- vector<Car> tanker;
- cin >> unitCount; cin.ignore();
- for (int i = 0; i < unitCount; i++) {
- int unitId;
- int unitType;
- int player;
- float mass;
- int radius;
- int x;
- int y;
- int vx;
- int vy;
- int extra;
- int extra2;
- cin >> unitId >> unitType >> player >> mass >> radius >> x >> y >> vx >> vy >> extra >> extra2; cin.ignore();
- //ciklas
- if(unitType == 0 && player == 0)
- {
- reaper.x = x;
- reaper.y = y;
- reaper.vx = vx;
- reaper.vy = vy;
- }
- //issaugoti savo masineles koordinates ir pagreiti
- if(unitType == 0 && player == 1)
- {
- reaper1.x = x;
- reaper1.y = y;
- reaper1.vx = vx;
- reaper1.vy = vy;
- }
- //issaugoti kitu zaideju koordinates ir pagreiti
- if(unitType == 1 && player == 0)
- {
- destro.x = x;
- destro.y = y;
- destro.vx = vx;
- destro.vy = vy;
- }
- //issaugoti destro koordinates ir pagreiti
- if(unitType == 2 && player == 0)
- {
- doof.x = x;
- doof.y = y;
- doof.vx = vx;
- doof.vy = vy;
- }
- //issaugoti doof koordinates ir pagreiti
- if(unitType == 3)
- {
- tanker.push_back({x,y,vx,vy});
- }
- //issaugoti tanker duomenis
- if(unitType == 4)
- {
- wreck.push_back({x,y});
- }
- }
- //issaugoti balos duomenis
- int distance = 1000000;
- int nr = -1;
- for(int i = 0; i < wreck.size(); i++)
- {
- int ats = sqrt(pow(reaper.x - wreck[i].x, 2)+pow(reaper.y - wreck[i].y, 2));
- if(distance > ats)
- {
- distance = ats;
- nr = i;
- }
- }
- //apskaiciuoti atstuma nuo reaper iki balos
- if(nr == -1)
- {
- cout << "WAIT" << endl;
- }
- else
- {
- cout << wreck[nr].x - reaper.vx << " " << wreck[nr].y - reaper.vy << " 300" << endl;
- }
- distance = 1000000;
- nr = -1;
- //jei atsumas geras galima judeti
- for(int i = 0; i < tanker.size(); i++)
- {
- int ats = sqrt(pow(destro.x - tanker[i].x, 2)+pow(destro.y - tanker[i].y, 2));
- if(distance > ats)
- {
- distance = ats;
- nr = i;
- }
- }
- //apskaiciuoti atstuma nuo destro iki tanker
- if(nr == -1)
- {
- cout << "WAIT" << endl;
- }
- else
- {
- cout << tanker[nr].x + tanker[nr].vx - destro.vx << " " << tanker[nr].y + tanker[nr].vy - destro.vy << " 300" << endl;
- }
- cout << reaper1.x + reaper1.vx << " " << reaper1.y + reaper1.vy << " 300" << endl;
- }
- //jei atsumas geras galima judeti
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement