結果

問題 No.245 貫け!
ユーザー tnakao0123tnakao0123
提出日時 2016-04-12 18:14:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,832 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 84,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 00:43:12
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 245.cc: No.245 貫け! - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_N2 = MAX_N * 2;

/* typedef */

typedef long long ll;

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
};

typedef Pt<int> pt;

/* global variables */

pt pts[MAX_N * 2];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;

  if (n == 1) {
    puts("1");
    return 0;
  }

  int n2 = n * 2;
  for (int i = 0; i < n2; i++) cin >> pts[i].x >> pts[i].y;

  int maxc = 0;

  for (int i = 0; i < n2; i++) {
    pt &pi = pts[i];
    for (int j = i + 1; j < n2; j++) {
      pt &pj = pts[j];
      if (pi == pj) continue;

      pt v = pj - pi;
      int c = 0;

      for (int k = 0; k < n; k++) {
	pt &pk0 = pts[k * 2], &pk1 = pts[k * 2 + 1];
	if (v.cross(pk0 - pi) * v.cross(pk1 - pi) <= 0) c++;
      }

      if (maxc < c) maxc = c;
    }
  }
  printf("%d\n", maxc);
  return 0;
}
0