結果

問題 No.202 1円玉投げ
ユーザー siman
提出日時 2016-03-27 23:54:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 1,280 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 77,220 KB
実行使用メモリ 30,116 KB
最終ジャッジ日時 2024-12-22 10:10:20
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <time.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

struct Coord {
  int y;
  int x;
  
  Coord(int y = -1, int x = -1){
    this->y = y;
    this->x = x;
  }
};

vector<Coord> field[1001][1001];

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

  int x, y;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    cin >> x >> y;

    int cy = y/20;
    int cx = x/20;
    bool success = true;

    for(int curY = cy-1; curY <= cy+1 && success; curY++){
      for(int curX = cx-1; curX <= cx+1 && success; curX++){
        if(curY < 0 || 1001 <= curY || curX < 0 || 1001 <= curX) continue;
        int size = field[curY][curX].size();

        for(int j = 0; j < size; j++){
          Coord coord = field[curY][curX][j];

          int dy = coord.y - y;
          int dx = coord.x - x;
          int dist = dy*dy + dx*dx;

          if(dist < 400){
            success = false;
          }
        }
      }
    }

    if(success){
      field[cy][cx].push_back(Coord(y,x));
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
0