fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. class ExplodingRobots
  4. {
  5. public:
  6. string canExplode(int x1, int y1, int x2, int y2, string a)
  7. {
  8. int u=0,r=0,d=0,l=0,i,len=a.length();
  9. for(i=0;i<len;i++)
  10. {
  11. if(a[i]=='U') u++;
  12. else if(a[i]=='L') l++;
  13. else if(a[i]=='D') d++;
  14. else r++;
  15. }
  16. if(x2>x1)
  17. {
  18. if(x2-l>x1+r) return "Safe";
  19. if(y2>y1)
  20. {
  21. if(y2-d>y1+u) return "Safe";
  22. return "Explosion";
  23. }
  24. else
  25. {
  26. if(y2+u<y1-d) return "Safe";
  27. return "Explosion";
  28. }
  29. }
  30. else
  31. {
  32. if(x1-l>x2+r) return "Safe";
  33. if(y2>y1)
  34. {
  35. if(y2-d>y1+u) return "Safe";
  36. return "Explosion";
  37. }
  38. else
  39. {
  40. if(y2+u<y1-d) return "Safe";
  41. return "Explosion";
  42. }
  43. }
  44. }
  45. };
  46.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty