oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

enclosure Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

enclosure.html

Problem Statement

Your task in this problem is to find out the minimum number of stones needed to place on an N-by-M rectangular grid (N horizontal line segments and M vertical line segments) to enclose at least K intersection points. An intersection point is enclosed if either of the following conditions is true:

  1. A stone is placed at the point.
  2. Starting from the point, we cannot trace a path along grid lines to reach an empty point on the grid border through empty intersection points only.

For example, to enclose 8 points on a 4x5 grid, we need at least 6 stones. One of many valid stone layouts is shown below. Enclosed points are marked with an "x".

Input

The first line of the input gives the number of test cases, T. T lines follow. Each test case is a line of three integers: N M K.

Output

For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the minimum number of stones needed.

Limits

1 ≤ T ≤ 100.
1 ≤ N.
1 ≤ M.
1 ≤ K ≤ N × M.

Small dataset

N × M ≤ 20.

Large dataset

N × M ≤ 1000.

Sample Input

2
4 5 8
3 5 11

Sample Output

Case #1: 6
Case #2: 8

stones.png

Tags

Google Code Jam 2014, Binary Search

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
13311s32MBMinimum
26711s32MBMinimum
3011s32MBMinimum

Judge Compile Command

g++-8 ans.cpp -o enclosure -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.