結果

問題 No.245 貫け!
ユーザー goodbatongoodbaton
提出日時 2015-07-28 19:13:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,691 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 72,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-24 12:28:15
合計ジャッジ時間 1,438 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100
#define EPS 1e-12


int n,x[2][SIZE],y[2][SIZE];
int ans=1;

bool cross(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
    int a,b;
    
    /*線分(x1,y1,x2,y2) と 直線(x3,y3,x4,y4)*/
    
    a=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
    b=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
    
    /*線分(x3,y3,x4,y4) と 直線(x1,y1,x2,y2)*/
    
    //c=(long long)(x1-x2)*(y3-y1)+(long long)(y1-y2)*(x1-x3);
    //d=(long long)(x1-x2)*(y4-y1)+(long long)(y1-y2)*(x1-x4);
    
    
    
    if(a*b<=0)
        return true;
    else
        return false;
}

int calc(int a,int ak,int b,int bk){
    if(x[ak][a]==x[bk][b] && y[ak][a]==y[bk][b]) return 0;
    
    int cc = 2;
    
    
    for(int i=0;i<n;i++){
        if(i==a || i==b) continue;
        
        if(cross(x[0][i],y[0][i],x[1][i],y[1][i],x[ak][a],y[ak][a],x[bk][b],y[bk][b]))
            cc++;
    }
    
    return cc;
}

int main(){
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&x[0][i],&y[0][i],&x[1][i],&y[1][i]);
    }
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            
            ans = max(ans,calc(i,0,j,0));
            ans = max(ans,calc(i,1,j,0));
            ans = max(ans,calc(i,0,j,1));
            ans = max(ans,calc(i,1,j,1));

        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}
0