結果

問題 No.202 1円玉投げ
ユーザー yuppe19 😺yuppe19 😺
提出日時 2020-01-18 11:11:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,380 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 206,788 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-08-24 00:06:05
合計ジャッジ時間 5,221 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
13,536 KB
testcase_01 AC 58 ms
15,412 KB
testcase_02 AC 10 ms
11,708 KB
testcase_03 AC 9 ms
11,500 KB
testcase_04 AC 10 ms
11,696 KB
testcase_05 AC 13 ms
12,380 KB
testcase_06 AC 53 ms
14,312 KB
testcase_07 AC 57 ms
14,884 KB
testcase_08 AC 60 ms
14,848 KB
testcase_09 AC 35 ms
13,664 KB
testcase_10 AC 20 ms
12,836 KB
testcase_11 AC 29 ms
13,468 KB
testcase_12 AC 30 ms
13,504 KB
testcase_13 AC 21 ms
12,864 KB
testcase_14 AC 13 ms
12,436 KB
testcase_15 AC 35 ms
13,664 KB
testcase_16 AC 39 ms
13,900 KB
testcase_17 AC 41 ms
13,940 KB
testcase_18 AC 40 ms
13,900 KB
testcase_19 AC 33 ms
13,524 KB
testcase_20 AC 48 ms
14,220 KB
testcase_21 AC 34 ms
13,788 KB
testcase_22 AC 10 ms
12,204 KB
testcase_23 AC 11 ms
12,172 KB
testcase_24 AC 10 ms
11,768 KB
testcase_25 AC 10 ms
11,648 KB
testcase_26 AC 10 ms
12,472 KB
testcase_27 AC 10 ms
12,428 KB
testcase_28 AC 10 ms
11,496 KB
testcase_29 AC 10 ms
11,804 KB
testcase_30 AC 10 ms
12,212 KB
testcase_31 AC 10 ms
11,552 KB
testcase_32 AC 10 ms
12,284 KB
testcase_33 AC 10 ms
12,252 KB
testcase_34 AC 10 ms
12,220 KB
testcase_35 AC 40 ms
13,744 KB
testcase_36 AC 42 ms
13,756 KB
testcase_37 AC 64 ms
14,692 KB
testcase_38 AC 41 ms
13,592 KB
testcase_39 AC 10 ms
11,500 KB
testcase_40 AC 10 ms
11,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Point = pair<int, int>;

int main(void) {
  const int M = 20001;
  const int LEN = 33;
  const int CNT = M / LEN;
  int res = 0;
  // 33 x 33の長さの正方形で区画を作る
  // 区画それぞれはvector<Point>にしておいて、点を追加できるようにする
  // vector<Point>の二次元配列なので、vector<vector<vector<Point>>>になる
  vector<vector<vector<Point>>> blocks(CNT+1, vector<vector<Point>>(CNT+1));
  int n; scanf("%d", &n);
  for(int i=0; i<n; i++) {
    int x, y; scanf("%d%d", &x, &y);
    int px = x / LEN, py = y / LEN;
    bool ok = true;
    // 区画とその周囲だけをチェックする
    for(int xx=-1; xx<=1; xx++) {
      for(int yy=-1; yy<=1; yy++) {
        int nx = px + xx;
        int ny = py + yy;
        if(nx < 0 || CNT < nx || ny < 0 || CNT < ny) { continue; }
        for(size_t k=0; k<blocks[nx][ny].size(); k++) {
          Point p = blocks[nx][ny][k];
          // 重なっていたらフラグを折って抜ける
          if((p.first-x)*(p.first-x) + (p.second-y)*(p.second-y) < 400) {
            ok = false;
            break;
          }
        }
      }
    }
    if(ok) {
      res++;
      // 区画の点リスト(vector<Point>)に点を入れる
      blocks[px][py].push_back(Point(x, y));
    }
  }
  printf("%d\n", res);
  return 0;
}
0