結果
| 問題 | No.321 (P,Q)-サンタと街の子供たち |
| コンテスト | |
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2016-09-27 19:30:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| コンパイル時間 | 719 ms |
| コンパイル使用メモリ | 75,420 KB |
| 実行使用メモリ | 159,104 KB |
| 最終ジャッジ日時 | 2024-11-21 07:21:44 |
| 合計ジャッジ時間 | 105,366 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 TLE * 33 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
int p, q, n;
int x[100001], y[100001];
int main(void){
cin >> p >> q >> n;
int lx = INF, rx = -INF, uy = -INF, sy = INF;
rep(i, n){
cin >> x[i] >> y[i];
lx = min(lx, x[i]);//左端
rx = max(rx, x[i]);//右端
uy = max(uy, y[i]);//上
sy = min(sy, y[i]);//下
}
int dx[] = {p, p, -p, -p, q, q, -q, -q};
int dy[] = {q, -q, q, -q, p, -p, p, -p};
set<pair<int, int> > s;
queue<pair<int, int> > q;
q.push(make_pair(0, 0));
while(!q.empty()){
auto now = q.front(); q.pop();
// printf("k %d %d\n", now.first, now.second);
rep(i, 8){
int ny = now.first + dy[i], nx = now.second + dx[i];
if(!(lx <= nx && nx <= rx && sy <= ny && ny <= uy)) continue;
if(s.count(make_pair(ny, nx)) != 0) continue;
// printf("%d %d\n", nx, ny);
s.insert(make_pair(ny, nx));
q.push(make_pair(ny, nx));
}
}
int ret = 0;
rep(i, n){
if(s.count(make_pair(y[i], x[i])) != 0){
ret++;
}
}
printf("%d\n", ret);
}
srup٩(๑`н´๑)۶