fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <stack>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <cstring>
  7. #include <cstdlib>
  8. #include <cmath>
  9. #include <map>
  10. using namespace std;
  11. int main() {
  12. ios::sync_with_stdio(false);
  13. cin.tie(NULL);
  14. cout.tie(NULL);
  15. int sx = -2000000001;
  16. int fx = 2000000001;
  17. int sy = -2000000001;
  18. int fy = 2000000001;
  19. int n;
  20. cin >> n;
  21. for (int i = 1; i <= n; i++) {
  22. int x, y;
  23. cin >> x >> y;
  24. char a;
  25. cin >> a;
  26. if (a == 'L' || a == 'R') {
  27. if(a=='R')sx = max(sx, x);
  28. else fx = min(fx, x);
  29. }
  30. else {
  31. if (a == 'U')sy = max(sy, y);
  32. else fy = min(fy, y);
  33. }
  34. }
  35. int d = 2000000001;
  36.  
  37.  
  38. if ((fx - sx - 1) == 0 || (fy - sy - 1) == 0) {
  39. cout << 0;
  40. return 0;
  41. }
  42. if (abs(sx) == d || abs(sy) == d || abs(fx) == d || abs(fy) ==d){
  43. cout << "Infinity";
  44. return 0;
  45. }
  46. unsigned long long a = (fx - sx - 1) * (fy - sy - 1);
  47. cout << a;
  48. return 0;
  49. }
Success #stdin #stdout 0.01s 5548KB
stdin
4
1000000000 1000000000 L
-1000000000 -1000000000 R
1000000000 1000000000 D
-1000000000 -1000000000 U
stdout
18446744072353011713