ACM: uva 1468 - Restaurant
来源:互联网 发布:网络延迟多少ms算正常 编辑:程序博客网 时间:2024/06/05 10:39
Restaurant
Mr. Kim is planning to open a new restaurant. His city is laidout as a grid withsize
Mr. Kim knows that the residents of the two apartmentsfrequently have a meeting. So, he thinks that the best location ofa new restaurant is halfway between two apartments. Consideringlease expenses and existing restaurants, however, he can't selectthe optimal location unconditionally. Hence he decides to regard alocation satisfying the following condition asa
A location
In the above figure, the location
Given
Input
Your program is to read the input from standard input. The inputconsists of
Output
Your program is to write to standard output. Print exactly oneline for each test case. Print the number of good places which canbe found in a given city map.
The following shows sample input and output for two testcases.
SampleInput
2
6 3
1 3
4 3
0 2
11 11
0 5
10 5
4 9
2 8
7 8
5 6
3 5
5 3
3 2
7 2
9 1
SampleOutput
2
16
题意:在一个M*M的矩形范围内, 有着A,B两间apartment, 有n-2间restaurant,现在要你新建一件restaurant,
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
#define MAX 60005
typedef long long ll;
const int INF = (1<<29);
int M, n;
int y[MAX], miny[MAX], maxy[MAX];
int xa, ya, xb, yb;
inline void swap(int &a, int&b)
{
}
int main()
{
//
}
- ACM: uva 1468 - Restaurant
- ACM: uva 1335 - Beijing Guards
- ACM: uva 10391 - Compound Words
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 11538 - Chess Queen
- ACM: uva 1073 - Glenbow Museum
- ACM: 数学题 uva 11300
- ACM: uva 11584 -
- ACM: uva 11464
- ACM: uva 3902
- ACM: uva 10382
- ACM: uva 11134
- ACM: uva 11174 - Stand in a Line
- ACM: uva 1276 - Network
- ACM: uva 1450 - Airport
- ACM: uva 1467 - Installations
- ACM: uva 10125 - Sumsets
- ACM: uva 1451 - Average
- ACM: uva 1451 - Average
- ACM: uva 1432 -&n…
- ACM: poj 2786 -&n…
- jquery 1.6 后 checkbox 使用attr("checked"),undefined.
- ACM: poj 3972 -&n…
- ACM: uva 1468 - Restaurant
- ACM: uva 11584 -
- ACM: uva 1424 - Salesmen
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 11538 - Chess Queen
- ACM: uva 11401 - Triangle Counti…
- ACM: uva 11375 - Matches
- ACM: uva 11174 - Stand in a Line
- ACM: uva 1362 -&n…