結果

問題 No.245 貫け!
ユーザー machymachy
提出日時 2015-07-18 00:15:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,720 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 88,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 18:37:05
合計ジャッジ時間 14,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <sys/time.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <random>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>

using namespace std;

struct Point{
    int x;
    int y;
    Point(){}
    Point(int x_, int y_):x(x_),y(y_){}
};

int side(const Point& a1, const Point& a2, const Point& p){
    return (a2.x - a1.x) * (p.y - a1.y) - (a2.y - a1.y) * (p.x - a1.x);
}

bool cross(const Point& a1, const Point& a2, const Point& b1, const Point& b2){
    int s1 = side(a1, a2, b1) * side(a1, a2, b2);
    int s2 = side(b1, b2, a1) * side(b1, b2, a2);
    if(s1 <= 0 || s2 <= 0){
        return true;
    }
    return false;
}


int main(){
    int N;
    cin >> N;
    vector<pair<Point,Point> > line(N);
    for(int i = 0; i < N; i++){
        cin >> line[i].first.x;
        cin >> line[i].first.y;
        cin >> line[i].second.x;
        cin >> line[i].second.y;
    }
    int ans = 0;
    for(int dx = 0; dx <= 100; dx++){
        for(int sx = 0; sx <= 100; sx++){
            for(int sy = 0; sy <= 100; sy++){
                int cnt = 0;
                Point ps(sx, sy);
                Point pe(sx + dx, sy + 100);
                Point pe2(sx + 100, sy + dx);
                for(int i = 0; i < N; i++){
                    if(cross(line[i].first, line[i].second, ps, pe)) cnt++;
                }
                ans = max(ans, cnt);
                cnt = 0;
                for(int i = 0; i < N; i++){
                    if(cross(line[i].first, line[i].second, ps, pe2)) cnt++;
                }
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << endl;
    return 0;

}
0