Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- /**
- * Save humans, destroy zombies!
- **/
- typedef struct human
- {
- int id;
- int x;
- int y;
- }HUMAN;
- typedef struct zombie
- {
- int id;
- int x;
- int y;
- int nx;
- int ny;
- }ZOMBIE;
- bool CanReachTime(int x, int y, HUMAN *h, int i, int d)
- {
- int moves, moves2;
- moves = (sqrt((h[i].x-x)*(h[i].x-x) + (h[i].y-y)*(h[i].y-y))-2000) / 1000;
- moves2 = d/400;
- cerr << "ASH: " << moves << " ZOMBIE: " << moves2 << " DISTANCE: " << d << endl;
- return moves<=moves2;
- }
- int CheckZombieCloseHuman(HUMAN *h, int hc, ZOMBIE *z, int zc, int x, int y)
- {
- int distance = 200000, d, id=0, auxid=-1, d2, moves, mindist=20000000;
- bool human = false;
- for(int i=0; i<zc; i++)
- {
- human = false;
- distance = sqrt((x-z[i].x)*(x-z[i].x) + (y-z[i].y)*(y-z[i].y));
- for(int j=0; j<hc; j++)
- {
- d = sqrt((h[j].x-z[i].x)*(h[j].x-z[i].x) + (h[j].y-z[i].y)*(h[j].y-z[i].y));
- if(d < distance)
- {
- distance = d;
- human = true;
- d2 = j;
- }
- }
- if(human && distance < mindist && CanReachTime(x,y,h,d2,distance))
- {
- mindist = distance;
- auxid=i;
- }
- }
- cerr << "FINAL CHOICE : " << auxid << endl;
- return auxid;
- }
- void ImTarget(HUMAN *h, int hc, ZOMBIE *z, int zc, int x, int y)
- {
- if(zc == 1)
- cout << z[0].x << " " << z[0].y << " C'm'ere" << endl;
- else
- {
- int mx=0, my=0;
- for (int i = 0; i < zc; i++)
- {
- mx +=z[i].x;
- my +=z[i].y;
- }
- mx/=zc;
- my/=zc;
- y=my-1000;
- x=mx;
- if(y<0)
- y=0;
- cout << x << " " << y << " Im Taget" << endl;
- }
- }
- int main()
- {
- int x;
- int y;
- int humanCount;
- int zombieCount;
- int zmx=20000,zmy=20000,zmax=0,zmay=0;
- HUMAN *humans;
- ZOMBIE *zombies;
- while (1)
- {
- cin >> x >> y; cin.ignore();
- cin >> humanCount; cin.ignore();
- humans = new HUMAN[humanCount];
- for (int i = 0; i < humanCount; i++)
- {
- cin >> humans[i].id >> humans[i].x >> humans[i].y; cin.ignore();
- }
- cin >> zombieCount; cin.ignore();
- zombies = new ZOMBIE[zombieCount];
- for (int i = 0; i < zombieCount; i++)
- {
- cin >> zombies[i].id >> zombies[i].x >> zombies[i].y >> zombies[i].nx >> zombies[i].ny; cin.ignore();
- }
- cerr << zmax <<endl;
- if(humanCount > 1)
- {
- int aux = CheckZombieCloseHuman(humans, humanCount, zombies, zombieCount,x,y);
- if(aux == -1)
- ImTarget(humans, humanCount, zombies, zombieCount,x,y);
- else
- cout << zombies[aux].x << " " << zombies[aux].y << " HOW TO GET COMBO? FU" << endl;
- }
- else
- cout << humans[0].x << " " << humans[0].y << " PROTECT SCARED HUMAN" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement