結果

問題 No.94 圏外です。(EASY)
ユーザー tnakao0123tnakao0123
提出日時 2016-03-12 23:29:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,718 bytes
コンパイル時間 1,128 ms
コンパイル使用メモリ 92,492 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:16:00
合計ジャッジ時間 2,492 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 AC 5 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 94.cc: No.94 圏外です。(EASY) - 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 = 1000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

int xs[MAX_N], ys[MAX_N];
vi nbrs[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> xs[i] >> ys[i];

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int dx = xs[j] - xs[i], dy = ys[j] - ys[i];
      if (dx * dx + dy * dy <= 100) {
	nbrs[i].push_back(j);
	nbrs[j].push_back(i);
      }
    }

  if (n <= 1) {
    printf("%.9lf\n", (n == 0) ? 1.0 : 2.0);
    return 0;
  }
  
  int maxd2 = 0;
  
  for (int i = 0; i < n; i++)
    if (! used[i]) {
      used[i] = true;
      qi q;
      q.push(i);
      vi ps;
      ps.push_back(i);

      while (! q.empty()) {
	int u = q.front(); q.pop();
	vi &nbru = nbrs[u];
	for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	  int &v = *vit;
	  if (! used[v]) {
	    used[v] = true;
	    q.push(v);
	    ps.push_back(v);
	  }
	}
      }

      int pn = ps.size();
      for (int j = 0; j < pn; j++)
	for (int k = j + 1; k < pn; k++) {
	  int dx = xs[k] - xs[j], dy = ys[k] - ys[j];
	  int d2 = dx * dx + dy * dy;
	  if (maxd2 < d2) maxd2 = d2;
	}
    }

  printf("%.9lf\n", sqrt((double)maxd2) + 2.0);
  return 0;
}
0