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;
- // Struktūrų apsirašymas
- struct Car
- {
- int x, y;
- int vx, vy;
- };
- struct Wreck
- {
- int x, y;
- };
- int main()
- {
- // game loop
- while (1) {
- // Gaunam informaciją iš žaidimo
- 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;
- // Apsirašom mašinėles
- Car reaper;
- Car destro;
- Car doof;
- Car reaper1;
- // Apsirašom balų ir tankerių sarašus
- vector<Wreck> wreck;
- vector<Car> tanker;
- cin >> unitCount; cin.ignore();
- // Pereinam per visus unit ir susirenkam informaciją
- 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();
- if(unitType == 0 && player == 0) // Susirandam savo reaper ir jo koordinates, pagreitį
- {
- reaper.x = x;
- reaper.y = y;
- reaper.vx = vx;
- reaper.vy = vy;
- }
- if(unitType == 0 && player == 1) // Susirandam priešininko reaper ir jo koordinates, pagreitį
- {
- reaper1.x = x;
- reaper1.y = y;
- reaper1.vx = vx;
- reaper1.vy = vy;
- }
- if(unitType == 1 && player == 0) // Susirandam savo destroyer ir jo koordinates, pagreitį
- {
- destro.x = x;
- destro.y = y;
- destro.vx = vx;
- destro.vy = vy;
- }
- if(unitType == 2 && player == 0) // Susirandam savo doof ir jo koordinates, pagreitį
- {
- doof.x = x;
- doof.y = y;
- doof.vx = vx;
- doof.vy = vy;
- }
- if(unitType == 3) // Sudedam visus tanker bei jų koordinates, pagreitį į balų vector
- {
- tanker.push_back({x,y,vx,vy});
- }
- if(unitType == 4) // Sudedam visas balas bei jų koordinates, pagreitį į balų vector
- {
- wreck.push_back({x,y});
- }
- }
- int distance = 1000000;
- int nr = -1;
- // Susirandam arčiausią balą ir pasižymim jos numerį
- 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;
- }
- }
- // Jeigu radom balą važiuojam link jos su reaper, kitu atveju laukiam
- if(nr == -1)
- {
- cout << "WAIT" << endl;
- }
- else
- {
- cout << wreck[nr].x - reaper.vx << " " << wreck[nr].y - reaper.vy << " 300" << endl;
- }
- distance = 1000000;
- nr = -1;
- // Susirandam arčiausią tanker ir pasižymim jo numerį
- 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;
- }
- }
- // Jeigu radom tanker važiuojam link jo su destroyer, kitu atveju laukiam
- 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;
- }
- // Su doof važiuojam link priešininko, kad jam trugdytume
- cout << reaper1.x + reaper1.vx << " " << reaper1.y + reaper1.vy << " 300" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement