시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 3311 1500 1288 46.888%

문제

코레스코 콘도미니엄 8층은 학생들이 3끼의 식사를 해결하는 공간이다. 그러나 몇몇 비양심적인 학생들의 만행으로 음식물이 통로 중간 중간에 떨어져 있다. 이러한 음식물들은 근처에 있는 것끼리 뭉치게 돼서 큰 음식물 쓰레기가 된다. 

이 문제를 출제한 선생님은 개인적으로 이러한 음식물을 실내화에 묻히는 것을 정말 진정으로 싫어한다. 참고로 우리가 구해야 할 답은 이 문제를 낸 조교를 맞추는 것이 아니다. 

통로에 떨어진 음식물을 피해가기란 쉬운 일이 아니다. 따라서 선생님은 떨어진 음식물 중에 제일 큰 음식물만은 피해 가려고 한다. 

선생님을 도와 제일 큰 음식물의 크기를 구해서 “10ra"를 외치지 않게 도와주자.

입력

첫째 줄에 통로의 세로 길이 N(1 ≤ N ≤ 100)과 가로 길이 M(1 ≤ M ≤ 100) 그리고 음식물 쓰레기의 개수 K(1 ≤ K ≤ 10,000)이 주어진다.  그리고 다음 K개의 줄에 음식물이 떨어진 좌표 (r, c)가 주어진다.

좌표 (r, c)의 r은 위에서부터, c는 왼쪽에서부터가 기준이다.

출력

첫째 줄에 음식물 중 가장 큰 음식물의 크기를 출력하라.

예제 입력 1

3 4 5
3 2
2 2
3 1
2 3
1 1

예제 출력 1

4

힌트

# . . .
  . # # .
  # # . .
위와 같이 음식물이 떨어져있고 제일큰 음식물의 크기는 4가 된다. (인접한 것은 붙어서 크게 된다고 나와 있음. 대각선으로는 음식물 끼리 붙을수 없고 상하좌우로만 붙을수 있다.)

W3sicHJvYmxlbV9pZCI6IjE3NDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM3NGNcdWMyZGRcdWJiM2MgXHVkNTNjXHVkNTU4XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWNmNTRcdWI4MDhcdWMyYTRcdWNmNTQgXHVjZjU4XHViM2M0XHViYmY4XHViMmM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NwYWNlLXNlcGFyYXRlZCBpbnRlZ2VyczogTiwgTSwgYW5kIEs8XC9wPlxyXG5cclxuPHA+KiBMaW5lcyAyLi5LKzE6IExpbmUgaSsxIGRlc2NyaWJlcyBvbmUgc3VibWVyZ2VkIGxvY2F0aW9uIHdpdGggdHdvIHNwYWNlIHNlcGFyYXRlZCBpbnRlZ2VycyB0aGF0IGFyZSBpdHMgcm93IGFuZCBjb2x1bW46IFIgYW5kIEM8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD4qIExpbmUgMTogVGhlIG51bWJlciBvZiBjZWxscyB0aGF0IHRoZSBsYXJnZXN0IGxha2UgY29udGFpbnMuPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Olympiad > USA Computing Olympiad > 2007-2008 Season > USACO November 2007 Contest > Bronze 3번

  • 문제를 번역한 사람: author9
  • 문제의 오타를 찾은 사람: eric00513