結果

問題 No.199 星を描こう
ユーザー h_nosonh_noson
提出日時 2016-04-08 21:34:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,740 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 64,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:45:34
合計ジャッジ時間 1,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

double dot(pair<double,double> p, pair<double,double> q) {
    return p.first * q.first + p.second * q.second;
}

double det(pair<double,double> p, pair<double,double> q) {
    return p.first * q.second - p.second * q.first;
}

pair<double,double> operator +(pair<double,double> p, pair<double,double> q) {
    return make_pair(p.first+q.first,p.second+q.second);
}

pair<double,double> operator -(pair<double,double> p, pair<double,double> q) {
    return make_pair(p.first-q.first,p.second-q.second);
}

pair<double,double> operator *(double s, pair<double,double> p) {
    return make_pair(p.first*s,p.second*s);
}

int main() {
    int i, j, k, l, cnt;
    pair<double,double> p[5];
    rep (i,5) {
        double x, y;
        cin >> x >> y;
        p[i] = make_pair(x,y);
    }
    cnt = 0;
    rep (i,4) REP (j,i+1,5) {
        int cross = 0;
        rep (k,5) REP (l,k+1,5) {
            if (k != i && k != j && l != i && l != j && det(p[j]-p[i],p[l]-p[k]) != 0) {
                double t = det(p[l]-p[k],p[k]-p[i])/det(p[l]-p[k],p[j]-p[i]);
                auto q = p[i] + t*(p[j]-p[i]);
                if (dot(p[i]-q,p[j]-q) < 0 && dot(p[k]-q,p[l]-q) < 0)
                    cross++;
            }
        }
        if (cross != 0 && cross != 2) {
            cout << "NO" << endl;
            return 0;
        }
        if (cross == 2) cnt++;
    }
    if (cnt == 5)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}
0