RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00337

Jabuke

Unrated 레이팅 미적용
난이도
2s
시간 제한
128MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(5^{th}\) round, January \(17^{th}\) 2015
It is often heard that the apple doesn’t fall far from the tree. But is that really so?
The National Statistics Department has tracked the falling of apples in a fruit garden for \(G\) consecutive
years. The fruit garden can be represented as a matrix with dimensions \(R \cdot S\). Each field of the matrix
can contain more than one apple tree.
Interestingly enough, each year there was exactly one apple fall, so the Department decided to write
down \(G\) pairs of numbers (\(r@@RISE_MATH_BLOCK_0@@1 - r\)2)^{2} + (\(s\)\(1 - s\)2)^{2}

제약

In test cases worth 30% of total points, it will hold \(G\) ⩽500.
\(5^{th}\) round, January \(17^{th}\) 2015

입력 형식

The first line of input contains two integers, \(R\) and \(S\) (1 ⩽R, S ⩽500), the number of rows and
columns of the matrix.
Each of the following \(R\) lines contains \(S\) characters ’x’ or ’.’. The character ’.’ denotes an empty field,
and the character ’x’ denotes a field with at least one tree.
The fruit garden will initially contain at least one tree.
After that, an integer \(G\) (1 ⩽\(G\)\(10^{5}\)) follows, the number of years the fruit garden has been under
observation.
Each of the following \(G\) lines describes the falls of the apples. Each line contains a pair of integers
(\(r\)\(i\), s\(i\)) that denote the row and column of the location where the apple fell in the \(i\)^{th} year.

출력 형식

Output \(G\) numbers, the required squared distances from the task, each in its own line.

예제 1
입력
3 3
x..
...
...
3
1 3
1 1
3 2
5 5
..x..
....x
.....
.....
.....
4
3 1
5 3
4 5
3 5
출력
output
4
0
5
8
8
4
1
설명

Clarification of the first example: The closest apple to the one that fell in the first year is the apple in
the field (1,1). The apple that fell in the second year fell on the exact field where the tree is located, so the
squared distance is 0. The apple that fell in the third year is equally distant to all three existing trees in the
fruit garden.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2014/2015 Contest 5

평가 및 의견

Jabuke

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Jabuke

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8