답안 #942544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942544 2024-03-10T20:37:13 Z vjudge1 Geometrija (COCI21_geometrija) C++17
0 / 110
18 ms 428 KB
#include <bits/stdc++.h>

using namespace std;

using ld = long double;
using ll = long long;

const ld eps = 1e-8;

#define int ll

#define sz(x) (int)x.size()

struct point {
    int x, y;
};

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<point> points(n);
    vector<int> x(n), y(n);
    for(int i=0; i<n; ++i){
        cin >> points[i].x >> points[i].y;
        x[i] = points[i].x;
        y[i] = points[i].y;
    }

    int ans = 0;

    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){

            // AB
            bool ok = 1;

            for(int k=0; k<n; ++k){
                if(k == j or k == i) continue;

                for(int l=k+1; l<n; ++l){
                    if(l == j or l == i) continue;

                    // CD

                    int xa = x[i];
                    int ya = y[i];
                    int xb = x[j];
                    int yb = y[j];

                    ld m1 = 1.0 * (ya - yb) / (xa - xb);

                    int xc = x[k];
                    int yc = y[k];
                    int xd = x[l];
                    int yd = y[l];

                    ld m2 = 1.0 * (yc - yd) / (xc - xd);

                    if(abs(m2 - m1) < eps){
                        continue;
                    }

                    ld x = 1.0 * (m1 * xa - m2 * xc + yc - ya) / (m1 - m2);
                    ld y = m1 * x - m1 * xa + ya;

                    
                    if(abs(xa - x) < eps && abs(ya - y) < eps){
                        continue;
                    }

                    if(abs(xb - x) < eps && abs(yb - y) < eps){
                        continue;
                    }

                    bool tmp = min(xa, xb) <= x && x <= max(xa, xb) && min(ya, yb) <= y && y <= max(ya, yb) && min(xc, xd) <= x && x <= max(xc, xd) && min(yc, yd) <= y && y <= max(yc, yd);

                    if(tmp){
                        // cerr << "el segmento: " << xa << ya << ' ' << xb << yb << endl;
                        // cerr << "choca con el segmento " << xc << yc << ' ' << xd << yd << endl;
                        // cerr << "en " << x << ' ' << y << endl;
                        ok = 0;
                    }

                }

            }

            ans += ok;

        }
    }

    cout << ans;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 348 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 18 ms 428 KB Output is correct
4 Incorrect 10 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 348 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 18 ms 428 KB Output is correct
4 Incorrect 10 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 348 KB Output is correct
2 Correct 17 ms 348 KB Output is correct
3 Correct 18 ms 428 KB Output is correct
4 Incorrect 10 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -