結果

問題 No.245 貫け!
ユーザー nanasili
提出日時 2015-07-28 16:04:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 2,639 bytes
コンパイル時間 1,257 ms
コンパイル使用メモリ 90,364 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 04:48:09
合計ジャッジ時間 2,210 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:86:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:90:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   90 |     scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>
#include <complex>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef double D; // doublelong double
typedef complex<D> P; // Point
typedef pair<P, P> L; // Line
typedef vector<P> VP;
const D EPS = 1e-9; //
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
//  dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
return (conj(a)*b).X;
}
//  cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
return (conj(a)*b).Y;
}
//
int ccw(P a, P b, P c) {
b -= a; c -= a;
if (cross(b,c) > EPS) return +1; // counter clockwise
if (cross(b,c) < -EPS) return -1; // clockwise
if (dot(b,c) < -EPS) return +2; // c--a--b on line
if (norm(b) < norm(c)) return -2; // a--b--c on line or a==b
return 0; // a--c--b on line or a==c or b==c
}
//
bool isecLP(P a1, P a2, P b) {
return abs(ccw(a1, a2, b)) != 1; // return EQ(cross(a2-a1, b-a1), 0);
}
//
bool isecLL(P a1, P a2, P b1, P b2) {
return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}
//
bool isecLS(P a1, P a2, P b1, P b2) {
return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}
//
bool isecSS(P a1, P a2, P b1, P b2) {
return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}
//
bool isecSP(P a1, P a2, P b) {
return !ccw(a1, a2, b);
}
int main() {
int n;
scanf("%d", &n);
P a[n], b[n];
for (int i = 0; i < n; i++) {
D x1, y1, x2, y2;
scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
a[i] = P(x1, y1);
b[i] = P(x2, y2);
}
P l[2*n];
for (int i = 0; i < n; i++) {
l[i] = a[i];
}
for (int i = n; i < 2*n; i++) {
l[i] = b[i-n];
}
int ans = 1;
for (int i = 0; i < 2*n; i++) {
P sp, ep;
for (int j = i+1; j < 2*n; j++) {
sp = l[i];
ep = l[j];
if (EQ(sp, ep)) continue;
int cnt = 0;
for (int k = 0; k < n; k++) {
cnt += isecLS(sp, ep, a[k], b[k]);
}
ans = max(ans, cnt);
}
}
printf("%d\n", ans);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0