結果

問題 No.245 貫け!
ユーザー h_nosonh_noson
提出日時 2016-05-18 15:52:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,891 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 63,548 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 22:54:42
合計ジャッジ時間 2,035 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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,(int)(n)-1,0)
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP(i,0,(int)(n)-1)
#define INF 100000000

typedef long long ll;

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

double dot(pair<double,double> p, pair<double,double> q) {
    return 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-(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) {
    p.first *= s; p.second *= s;
    return p;
}

int main() {
    int i, j, k, ib, jb, n, ans;
    pair<int,int> cor[100][2];
    cin >> n;
    ans = 0;
    rep (i,n) cin >> cor[i][0].first >> cor[i][0].second >> cor[i][1].first >> cor[i][1].second;
    rep (i,n) rep (j,n) rep (ib,2) rep (jb,2) if (cor[i][ib] != cor[j][jb]) {
        int cnt = 0;
        rep (k,n) if ((cor[k][0] != cor[i][ib] || cor[k][1] != cor[j][jb]) && (cor[k][0] != cor[j][jb] || cor[k][1] != cor[i][ib])) {
            double a = det(cor[k][0]-cor[k][1],cor[k][0]-cor[j][jb]);
            double b = det(cor[k][0]-cor[k][1],cor[i][ib]-cor[j][jb]);
            if (b == 0) {
                if (a == 0)
                    cnt++;
            }
            else {
                auto p = cor[j][jb] + a/b * (cor[i][ib] - cor[j][jb]);
                if (dot(cor[i][ib]-p,cor[j][jb]-p) <= 0 && dot(cor[k][0]-p,cor[k][1]-p) <= 0)
                    cnt++;
            }
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}
0