Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 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. int main()
  13. {
  14.  
  15. // game loop
  16. while (1) {
  17. int spaceX;
  18. int spaceY;
  19. string fire;
  20. int maxH=0;
  21. int n = 0;
  22. cin >> spaceX >> spaceY; cin.ignore();
  23. for (int i = 0; i < 8; i++) {
  24. int mountainH; // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
  25. cin >> mountainH; cin.ignore();
  26. if(maxH<mountainH){
  27. maxH=mountainH;
  28. n=i;
  29. }
  30. }
  31. cerr<<maxH<<" "<<spaceY<<" "<<spaceX<<" "<<n<<endl;
  32. if(spaceX==n){
  33. fire="FIRE";
  34. }else{
  35. fire="HOLD";
  36. }
  37.  
  38.  
  39. // Write an action using cout. DON'T FORGET THE "<< endl"
  40. // To debug: cerr << "Debug messages..." << endl;
  41.  
  42. cout << fire << endl; // either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing).
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement