fork download
  1. struct Point {
  2. int x, y;
  3. Point operator-(Point p) {
  4. return {x - p.x, y - p.y};
  5. }
  6. };
  7.  
  8. int CrossProd(Point p, Point q) {
  9. return p.x * q.y - p.y * q.x;
  10. }
  11.  
  12.  
  13.  
  14. class TrianglePainting {
  15. public:
  16. #undef int
  17. double expectedArea(vector <int> x1, vector <int> y1, vector <int> x2, vector <int> y2, vector <int> Prob) {
  18. #define int long long
  19. vector<pair<Point, Point>> pts;
  20. int n = SZ(x1);
  21. vector<LD> pr(n);
  22. LD res = 0;
  23. REP (i, n) {
  24. pts.PB({{x1[i], y1[i]}, {x2[i], y2[i]}});
  25. auto& p = pts.back();
  26. if (CrossProd(p.st, p.nd) < 0) {
  27. swap(p.st, p.nd);
  28. }
  29. pr[i] = Prob[i] * .01;
  30. res += pr[i] * CrossProd(p.st, p.nd) / 2;
  31. Point diff = p.st - p.nd;
  32. REP (j, i) {
  33. Point old[3] = {pts[j].nd, pts[j].st - pts[j].nd, {-pts[j].st.x, -pts[j].st.y}};
  34. REP (tr, 3) {
  35. if (CrossProd(old[tr], p.nd) > 0 && CrossProd(diff, old[tr]) > 0) {
  36. res += pr[i] * pr[j] * CrossProd(old[tr], p.nd);
  37. }
  38. if (CrossProd(old[tr], p.st) > 0 && CrossProd(diff, old[tr]) <= 0) {
  39. res += pr[i] * pr[j] * CrossProd(old[tr], p.st);
  40. }
  41. }
  42. }
  43. }
  44.  
  45.  
  46. return res;
  47. }
  48.  
  49. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:23: error: 'vector' has not been declared
   double expectedArea(vector <int> x1, vector <int> y1, vector <int> x2, vector <int> y2, vector <int> Prob) {
                       ^
prog.cpp:17:30: error: expected ',' or '...' before '<' token
   double expectedArea(vector <int> x1, vector <int> y1, vector <int> x2, vector <int> y2, vector <int> Prob) {
                              ^
prog.cpp: In member function 'double TrianglePainting::expectedArea(int)':
prog.cpp:19:5: error: 'vector' was not declared in this scope
     vector<pair<Point, Point>> pts;
     ^
prog.cpp:19:12: error: 'pair' was not declared in this scope
     vector<pair<Point, Point>> pts;
            ^
prog.cpp:19:22: error: expected primary-expression before ',' token
     vector<pair<Point, Point>> pts;
                      ^
prog.cpp:19:29: error: expected primary-expression before '>>' token
     vector<pair<Point, Point>> pts;
                             ^
prog.cpp:19:32: error: 'pts' was not declared in this scope
     vector<pair<Point, Point>> pts;
                                ^
prog.cpp:20:16: error: 'x1' was not declared in this scope
     int n = SZ(x1);
                ^
prog.cpp:20:18: error: 'SZ' was not declared in this scope
     int n = SZ(x1);
                  ^
prog.cpp:21:12: error: 'LD' was not declared in this scope
     vector<LD> pr(n);
            ^
prog.cpp:21:20: error: 'pr' was not declared in this scope
     vector<LD> pr(n);
                    ^
prog.cpp:22:8: error: expected ';' before 'res'
     LD res = 0;
        ^
prog.cpp:23:10: error: 'i' was not declared in this scope
     REP (i, n) {
          ^
prog.cpp:23:14: error: 'REP' was not declared in this scope
     REP (i, n) {
              ^
prog.cpp:46:12: error: 'res' was not declared in this scope
     return res;
            ^
stdout
Standard output is empty