結果

問題 No.202 1円玉投げ
ユーザー tnakao0123tnakao0123
提出日時 2016-03-27 15:30:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 1,564 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 6,160 KB
最終ジャッジ日時 2023-08-23 23:19:31
合計ジャッジ時間 3,672 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
5,536 KB
testcase_01 AC 70 ms
6,160 KB
testcase_02 AC 3 ms
4,396 KB
testcase_03 AC 3 ms
4,392 KB
testcase_04 AC 2 ms
4,504 KB
testcase_05 AC 7 ms
4,580 KB
testcase_06 AC 60 ms
5,740 KB
testcase_07 AC 66 ms
5,860 KB
testcase_08 AC 68 ms
5,884 KB
testcase_09 AC 38 ms
5,496 KB
testcase_10 AC 16 ms
4,968 KB
testcase_11 AC 31 ms
5,268 KB
testcase_12 AC 32 ms
5,268 KB
testcase_13 AC 18 ms
4,932 KB
testcase_14 AC 7 ms
4,620 KB
testcase_15 AC 37 ms
5,364 KB
testcase_16 AC 65 ms
5,568 KB
testcase_17 AC 66 ms
5,604 KB
testcase_18 AC 66 ms
5,608 KB
testcase_19 AC 34 ms
5,424 KB
testcase_20 AC 54 ms
5,640 KB
testcase_21 AC 34 ms
5,312 KB
testcase_22 AC 3 ms
4,532 KB
testcase_23 AC 3 ms
4,432 KB
testcase_24 AC 3 ms
4,396 KB
testcase_25 AC 3 ms
4,512 KB
testcase_26 AC 3 ms
4,532 KB
testcase_27 AC 3 ms
4,420 KB
testcase_28 AC 2 ms
4,432 KB
testcase_29 AC 3 ms
4,532 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 3 ms
4,412 KB
testcase_32 AC 3 ms
4,400 KB
testcase_33 AC 3 ms
4,452 KB
testcase_34 AC 3 ms
4,424 KB
testcase_35 AC 69 ms
5,504 KB
testcase_36 AC 74 ms
5,548 KB
testcase_37 AC 73 ms
5,872 KB
testcase_38 AC 73 ms
5,452 KB
testcase_39 AC 2 ms
4,436 KB
testcase_40 AC 3 ms
4,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 202.cc: No.202 1円玉投げ - 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 = 100000;
const int MAX_X = 20000;
const int MAX_Y = 20000;
const int DX = 100;
const int DY = 100;
const int MAX_GX = MAX_X / DX;
const int MAX_GY = MAX_Y / DY;
const int RR = 20 * 20;

/* typedef */

struct Pt {
  int x, y;
  Pt() {}
  Pt(int _x, int _y): x(_x), y(_y) {}

  int d2(const Pt &p) const {
    int dx = x - p.x, dy = y - p.y;
    return dx * dx + dy * dy;
  }
};

typedef vector<Pt> vpt;

/* global variables */

Pt pts[MAX_N];
vpt gps[MAX_GY + 1][MAX_GX + 1];

/* subroutines */

/* main */

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

  int pn = 0;
  for (int i = 0; i < n; i++) {
    Pt p;
    cin >> p.x >> p.y;
    int gpx = p.x / DX, gpy = p.y / DY;
    bool ok = true;

    for (int gy = gpy - 1; ok && gy <= gpy + 1; gy++) {
      if (gy < 0 || gy > MAX_GY) continue;
      for (int gx = gpx - 1; ok && gx <= gpx + 1; gx++) {
	if (gx < 0 || gx > MAX_GX) continue;

	vpt &gv = gps[gy][gx];
	for (vpt::iterator vit = gv.begin(); vit != gv.end(); vit++)
	  if (p.d2(*vit) < RR) ok = false;
      }
    }

    if (ok) {
      pn++;
      gps[gpy][gpx].push_back(p);
    }
  }

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