結果

問題 No.1121 Social Distancing in Cinema
ユーザー tnakao0123tnakao0123
提出日時 2020-07-24 19:16:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,962 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 101,256 KB
実行使用メモリ 6,896 KB
最終ジャッジ日時 2023-09-08 00:22:45
合計ジャッジ時間 10,513 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 42 ms
4,472 KB
testcase_26 AC 56 ms
6,524 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 144 ms
6,636 KB
testcase_29 AC 53 ms
6,656 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 22 ms
4,380 KB
testcase_38 AC 42 ms
6,584 KB
testcase_39 WA -
testcase_40 AC 18 ms
4,376 KB
testcase_41 AC 5 ms
4,380 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1121.cc:  No.1121 Social Distancing in Cinema - 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 = 250000;
const int D = 10;
const int DD = D * D;

/* typedef */

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

  bool operator<(const Pt &p) const {
    return y < p.y || (y == p.y && x < p.x);
  }

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

  void print() { printf("(%d,%d,%d)\n", y, x, i); }
};
typedef set<Pt> spt;

/* global variables */

Pt ps[MAX_N];
spt pset;
bool used[MAX_N];
int vs[MAX_N];

/* subroutines */

bool cmpptx(const Pt &p, const Pt &q) {
  return p.x < q.x || (p.x == q.x && p.y < q.y);
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    scanf("%d%d", &ps[i].x, &ps[i].y), ps[i].i = i;
  sort(ps, ps + n, cmpptx);

  int k = 0;
  for (int i = 0, j = 0; i < n; i++) {
    Pt pi = ps[i];
    //printf("i=%d: ", i), pi.print();
    
    while (j < i && ps[j].x < pi.x - D) {
      if (used[j]) pset.erase(ps[j]);
      j++;
    }
    //printf("  %lu\n", pset.size());

    bool ok = true;
    spt::iterator sit =
	       lower_bound(pset.begin(), pset.end(), Pt(pi.y - D, -1, -1));
    for(; sit != pset.end() && sit->y - pi.y <= D; sit++) {
      if (sit->d2(pi) <= DD) {
	ok = false;
	break;
      }
    }

    if (ok) {
      used[i] = true;
      vs[k++] = ps[i].i;
      pset.insert(pi);
    }
  }

  printf("%d\n", k);
  for (int i = 0; i < k; i++) {
    printf("%d", vs[i] + 1);
    putchar(i + 1 < k ? ' ' : '\n');
  }
  return 0;
}
0