Contest Duration: - (local time) (120 minutes) Back to Home

Submission #170091

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

typedef tuple<int, int, int, int> I4;

#define X first
#define Y second

int W, H, N;
VPII robots;
map<I4, int> memo;

int dfs(I4 area) {
if (memo.count(area)) {
return memo[area];
}

int w = get<2>(area) - get<0>(area);
int h = get<3>(area) - get<1>(area);

VI res(1, 0);
for (auto &robot : robots) {
if (get<0>(area) <= robot.X && robot.X < get<2>(area) &&
get<1>(area) <= robot.Y && robot.Y < get<3>(area)) {

int tmp = w + h - 1;
tmp += dfs(make_tuple( get<0>(area), get<1>(area), robot.X,      robot.Y      ));
tmp += dfs(make_tuple( get<0>(area), robot.Y + 1,  robot.X,      get<3>(area) ));
tmp += dfs(make_tuple( robot.X + 1,  get<1>(area), get<2>(area), robot.Y      ));
tmp += dfs(make_tuple( robot.X + 1,  robot.Y + 1,  get<2>(area), get<3>(area  )));

res.push_back(tmp);
}
}

return memo[area] = *max_element(res.begin(), res.end());
}

int main(void) {
cin >> W >> H >> N;
robots = VPII(N);
for (auto &robot : robots) {
cin >> robot.X >> robot.Y;
robot.X--;
robot.Y--;
}

cout << dfs(make_tuple(0, 0, W, H)) << endl;

return 0;
}
```

#### Submission Info

Submission Time 2014-05-11 05:59:20+0900 D - 金塊ゲーム snakazawa C++11 (GCC 4.8.1) 100 1665 Byte AC 58 ms 1592 KB

#### Judge Result

Score / Max Score 0 / 0 80 / 80 19 / 19 1 / 1
Status
 AC × 3
 AC × 25
 AC × 50
 AC × 75
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 39 ms 864 KB
sample_02.txt AC 25 ms 916 KB
sample_03.txt AC 24 ms 816 KB
subtask1_01.txt AC 25 ms 920 KB
subtask1_02.txt AC 24 ms 916 KB
subtask1_03.txt AC 23 ms 868 KB
subtask1_04.txt AC 23 ms 920 KB
subtask1_05.txt AC 24 ms 912 KB
subtask1_06.txt AC 24 ms 864 KB
subtask1_07.txt AC 24 ms 916 KB
subtask1_08.txt AC 25 ms 920 KB
subtask1_09.txt AC 23 ms 812 KB
subtask1_10.txt AC 27 ms 928 KB
subtask1_11.txt AC 23 ms 816 KB
subtask1_12.txt AC 24 ms 844 KB
subtask1_13.txt AC 23 ms 820 KB
subtask1_14.txt AC 22 ms 912 KB
subtask1_15.txt AC 23 ms 916 KB
subtask1_16.txt AC 23 ms 936 KB
subtask1_17.txt AC 24 ms 804 KB
subtask1_18.txt AC 24 ms 916 KB
subtask1_19.txt AC 25 ms 916 KB
subtask1_20.txt AC 22 ms 912 KB
subtask1_21.txt AC 25 ms 864 KB
subtask1_22.txt AC 23 ms 920 KB
subtask1_23.txt AC 25 ms 888 KB
subtask1_24.txt AC 23 ms 956 KB
subtask1_25.txt AC 23 ms 916 KB
subtask2_01.txt AC 28 ms 1044 KB
subtask2_02.txt AC 26 ms 936 KB
subtask2_03.txt AC 28 ms 1060 KB
subtask2_04.txt AC 33 ms 1060 KB
subtask2_05.txt AC 39 ms 1132 KB
subtask2_06.txt AC 39 ms 1188 KB
subtask2_07.txt AC 41 ms 1280 KB
subtask2_08.txt AC 39 ms 1296 KB
subtask2_09.txt AC 54 ms 1444 KB
subtask2_10.txt AC 54 ms 1500 KB
subtask2_11.txt AC 52 ms 1444 KB
subtask2_12.txt AC 55 ms 1444 KB
subtask2_13.txt AC 39 ms 1188 KB
subtask2_14.txt AC 41 ms 1300 KB
subtask2_15.txt AC 25 ms 920 KB
subtask2_16.txt AC 38 ms 1188 KB
subtask2_17.txt AC 57 ms 1512 KB
subtask2_18.txt AC 57 ms 1444 KB
subtask2_19.txt AC 54 ms 1448 KB
subtask2_20.txt AC 54 ms 1448 KB
subtask2_21.txt AC 54 ms 1440 KB
subtask2_22.txt AC 54 ms 1440 KB
subtask2_23.txt AC 51 ms 1448 KB
subtask2_24.txt AC 54 ms 1444 KB
subtask2_25.txt AC 58 ms 1444 KB
subtask3_01.txt AC 23 ms 912 KB
subtask3_02.txt AC 25 ms 936 KB
subtask3_03.txt AC 26 ms 932 KB
subtask3_04.txt AC 27 ms 928 KB
subtask3_05.txt AC 34 ms 1024 KB
subtask3_06.txt AC 29 ms 1056 KB
subtask3_07.txt AC 30 ms 1064 KB
subtask3_08.txt AC 37 ms 1188 KB
subtask3_09.txt AC 40 ms 1192 KB
subtask3_10.txt AC 57 ms 1444 KB
subtask3_11.txt AC 52 ms 1448 KB
subtask3_12.txt AC 56 ms 1540 KB
subtask3_13.txt AC 58 ms 1512 KB
subtask3_14.txt AC 53 ms 1444 KB
subtask3_15.txt AC 54 ms 1536 KB
subtask3_16.txt AC 54 ms 1592 KB
subtask3_17.txt AC 53 ms 1440 KB
subtask3_18.txt AC 34 ms 1060 KB
subtask3_19.txt AC 53 ms 1440 KB
subtask3_20.txt AC 37 ms 1188 KB
subtask3_21.txt AC 57 ms 1448 KB
subtask3_22.txt AC 55 ms 1436 KB
subtask3_23.txt AC 54 ms 1436 KB
subtask3_24.txt AC 56 ms 1440 KB
subtask3_25.txt AC 51 ms 1448 KB