結果

問題 No.1121 Social Distancing in Cinema
ユーザー LayCurseLayCurse
提出日時 2020-07-22 23:09:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,634 bytes
コンパイル時間 2,806 ms
コンパイル使用メモリ 220,876 KB
実行使用メモリ 19,172 KB
最終ジャッジ日時 2023-09-05 03:58:01
合計ジャッジ時間 13,505 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,624 KB
testcase_01 AC 3 ms
11,528 KB
testcase_02 AC 3 ms
11,520 KB
testcase_03 AC 3 ms
11,784 KB
testcase_04 AC 3 ms
11,596 KB
testcase_05 AC 3 ms
11,512 KB
testcase_06 AC 4 ms
11,584 KB
testcase_07 AC 3 ms
11,536 KB
testcase_08 AC 3 ms
11,568 KB
testcase_09 AC 3 ms
11,536 KB
testcase_10 AC 3 ms
11,564 KB
testcase_11 AC 3 ms
11,624 KB
testcase_12 AC 3 ms
11,516 KB
testcase_13 AC 4 ms
11,556 KB
testcase_14 AC 3 ms
11,756 KB
testcase_15 AC 5 ms
13,616 KB
testcase_16 AC 13 ms
13,804 KB
testcase_17 AC 121 ms
16,760 KB
testcase_18 AC 398 ms
18,972 KB
testcase_19 AC 543 ms
19,020 KB
testcase_20 AC 5 ms
13,620 KB
testcase_21 AC 5 ms
13,664 KB
testcase_22 AC 4 ms
13,776 KB
testcase_23 AC 3 ms
11,544 KB
testcase_24 AC 4 ms
11,640 KB
testcase_25 AC 117 ms
14,076 KB
testcase_26 AC 156 ms
14,324 KB
testcase_27 AC 5 ms
11,712 KB
testcase_28 AC 459 ms
19,036 KB
testcase_29 AC 146 ms
14,264 KB
testcase_30 AC 42 ms
14,172 KB
testcase_31 AC 543 ms
18,980 KB
testcase_32 AC 313 ms
19,172 KB
testcase_33 AC 67 ms
14,256 KB
testcase_34 AC 68 ms
14,196 KB
testcase_35 AC 360 ms
18,968 KB
testcase_36 AC 505 ms
18,972 KB
testcase_37 AC 39 ms
14,176 KB
testcase_38 AC 89 ms
14,404 KB
testcase_39 AC 437 ms
19,100 KB
testcase_40 AC 35 ms
14,192 KB
testcase_41 AC 7 ms
13,828 KB
testcase_42 AC 501 ms
18,992 KB
testcase_43 AC 496 ms
18,980 KB
testcase_44 AC 491 ms
19,012 KB
testcase_45 AC 493 ms
19,008 KB
testcase_46 WA -
testcase_47 AC 3 ms
11,508 KB
testcase_48 AC 3 ms
11,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){
  int i;
  pair<T1, pair<T2, T3> > *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second.first = b[i];
    arr[i].second.second = c[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second.first;
    c[i] = arr[i].second.second;
  }
}
template<class T1, class T2, class T3, class T4> void sortA_L(int N, T1 a[], T2 b[], T3 c[], T4 d[], void *mem = wmem){
  int i;
  pair<pair<T1, T2>, pair<T3, T4> > *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first.first = a[i];
    arr[i].first.second = b[i];
    arr[i].second.first = c[i];
    arr[i].second.second = d[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first.first;
    b[i] = arr[i].first.second;
    c[i] = arr[i].second.first;
    d[i] = arr[i].second.second;
  }
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
int N;
int X[300000];
int Y[300000];
int ind[300000];
long long val[300000];
int ress;
int res[300000];
bool ok(int i, int j){
  return (pow2_L((X[i]-X[j])))+(pow2_L((Y[i]-Y[j])))>= 100;
}
int main(){
  int i;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    ind[i] = i;
  }
  for(i=(0);i<(N);i++){
    val[i] =min_L(min_L(min_L(X[i], Y[i]), 501-X[i]), 501-Y[i]);
  }
  sortA_L(N, val, X, Y, ind);
  for(i=(0);i<(N);i++){
    int j;
    for(j=(0);j<(ress);j++){
      if(!ok(i,res[j])){
        goto WYIGIcGE;
      }
    }
    res[ress++] = i;
    WYIGIcGE:;
  }
  for(i=(0);i<(ress);i++){
    res[i] = ind[res[i]];
  }
  sortA_L(ress,res);
  wt_L(ress);
  wt_L('\n');
  {
    int hCmBdyQB;
    if(ress==0){
      wt_L('\n');
    }
    else{
      for(hCmBdyQB=(0);hCmBdyQB<(ress-1);hCmBdyQB++){
        wt_L(res[hCmBdyQB]+1);
        wt_L(' ');
      }
      wt_L(res[hCmBdyQB]+1);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N, X[3d5], Y[3d5], ind[3d5];
// ll val[3d5];
// int ress, res[3d5];
// 
// bool ok(int i, int j){
//   return (X[i]-X[j])**2 + (Y[i]-Y[j])**2 >= 100;
// }
// 
// {
//   rd(N,(X,Y)(N));
// 
// //  N = 0;
// //  rep(i,500) rep(j,500) arrInsert(N,N,X,i,Y,j);
// 
//   rep(i,N) ind[i] = i;
//   rep(i,N) val[i] = min(X[i], Y[i], 501-X[i], 501-Y[i]);
//   sortA(N, val, X, Y, ind);
//   rep(i,N){
//     rep(j,ress) if(!ok(i,res[j])) break_continue;
//     res[ress++] = i;
// //    if(ress*90 >= N) break;
//   }
//   rep(i,ress) res[i] = ind[res[i]];
//   sortA(ress,res);
//   wt(ress);
//   wt(res(ress)+1);
// }
0