結果

問題 No.202 1円玉投げ
ユーザー 0w10w1
提出日時 2016-12-05 14:58:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 1,796 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 167,440 KB
実行使用メモリ 35,360 KB
最終ジャッジ日時 2023-08-23 23:30:32
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
28,848 KB
testcase_01 AC 47 ms
35,092 KB
testcase_02 AC 11 ms
20,292 KB
testcase_03 AC 11 ms
20,492 KB
testcase_04 AC 11 ms
20,384 KB
testcase_05 AC 17 ms
34,276 KB
testcase_06 AC 42 ms
35,192 KB
testcase_07 AC 46 ms
35,176 KB
testcase_08 AC 45 ms
35,164 KB
testcase_09 AC 35 ms
34,792 KB
testcase_10 AC 22 ms
34,780 KB
testcase_11 AC 29 ms
34,748 KB
testcase_12 AC 31 ms
34,676 KB
testcase_13 AC 24 ms
34,764 KB
testcase_14 AC 17 ms
34,604 KB
testcase_15 AC 33 ms
34,908 KB
testcase_16 AC 35 ms
33,492 KB
testcase_17 AC 35 ms
24,804 KB
testcase_18 AC 34 ms
24,972 KB
testcase_19 AC 32 ms
34,756 KB
testcase_20 AC 40 ms
34,760 KB
testcase_21 AC 32 ms
34,640 KB
testcase_22 AC 14 ms
33,148 KB
testcase_23 AC 14 ms
33,104 KB
testcase_24 AC 11 ms
20,628 KB
testcase_25 AC 10 ms
20,300 KB
testcase_26 AC 10 ms
20,304 KB
testcase_27 AC 11 ms
20,344 KB
testcase_28 AC 10 ms
20,484 KB
testcase_29 AC 11 ms
20,336 KB
testcase_30 AC 13 ms
33,192 KB
testcase_31 AC 11 ms
22,412 KB
testcase_32 AC 14 ms
33,120 KB
testcase_33 AC 10 ms
20,568 KB
testcase_34 AC 11 ms
20,708 KB
testcase_35 AC 34 ms
22,308 KB
testcase_36 AC 39 ms
33,820 KB
testcase_37 AC 48 ms
35,360 KB
testcase_38 AC 35 ms
24,768 KB
testcase_39 AC 11 ms
22,824 KB
testcase_40 AC 11 ms
22,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector< pii > vp;
typedef vector< vp > vvp;
typedef vector< string > vs;
typedef vector< double > vd;
typedef vector< vd > vvd;

template< class T1, class T2 >
int upmin( T1 &x, T2 v ){
  if( x > v ){
    x = v;
    return 1;
  }
  return 0;
}

template< class T1, class T2 >
int upmax( T1 &x, T2 v ){
  if( x < v ){
    x = v;
    return 1;
  }
  return 0;
}

const int INF = 0x3f3f3f3f;

int N;
vi X, Y;

void init(){
  cin >> N;
  X = Y = vi( N );
  for( int i = 0; i < N; ++i )
    cin >> X[ i ] >> Y[ i ];
}

int cx[ 2000 + 1 ][ 2000 + 1 ];
int cy[ 2000 + 1 ][ 2000 + 1 ];

int eu_dis2( int x, int y, int a, int b ){
  int dtx = x - a;
  int dty = y - b;
  return dtx * dtx + dty * dty;
}

void preprocess(){
  memset( cx, -1, sizeof( cx ) );
  for( int i = 0; i < N; ++i ){
    int x = X[ i ], y = Y[ i ];
    if( cx[ x / 10 ][ y / 10 ] != -1 ) continue;
    int ng = 0;
    for( int dx = -2; dx <= 2; ++dx ){
      for( int dy = -2; dy <= 2; ++dy ){
        int nx = x / 10 + dx;
        int ny = y / 10 + dy;
        if( nx < 0 or nx > 2000 or ny < 0 or ny > 2000 ) continue;
        if( cx[ nx ][ ny ] == -1 ) continue;
        if( eu_dis2( x, y, cx[ nx ][ ny ], cy[ nx ][ ny ] ) >= 400 ) continue;
        ng = 1;
      }
    }
    if( ng ) continue;
    cx[ x / 10 ][ y / 10 ] = x;
    cy[ x / 10 ][ y / 10 ] = y;
  }
}

void solve(){
  int ans = 0;
  for( int i = 0; i <= 2000; ++i )
    for( int j = 0; j <= 2000; ++j )
      ans += cx[ i ][ j ] != -1;
  cout << ans << endl;
}

signed main(){
  ios::sync_with_stdio( 0 );
  init();
  preprocess();
  solve();
  return 0;
}
0