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

Submission #169416

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int solve(int idx, deque<deque<bool> >& field, const vector<pair<int, int> >& p) {
const int N = (int)p.size();
const int W = (int)field[0].size();
const int H = (int)field.size();

if (idx >= N) {
int cnt = 0;
for (int i = 0; i < H; ++i) {
cnt += count(field[i].begin(), field[i].end(), false);
}
return cnt;
}

field[p[idx].second][p[idx].first] = false;
for (int d = 0; d < 4; ++d) {
int x = p[idx].first + dx[d];
int y = p[idx].second + dy[d];

while (0 <= x && x < W && 0 <= y && y < H && field[y][x]) {
field[y][x] = false;
x += dx[d];
y += dy[d];
}
}

return solve(idx+1, field, p);
}

int main() {
int W, H, N;
while (cin >> W >> H >> N) {
if (N > 8 || W > 80 || H > 80) {
cout << "0" << endl;
continue;
}

vector<pair<int, int> > p(N);
for (int i = 0; i < N; ++i) {
cin >> p[i].first >> p[i].second;
--p[i].first;
--p[i].second;
}
sort(p.begin(), p.end());

int ans = 0;
do {
deque<deque<bool> > field(H, deque<bool>(W, true));
ans = max(ans, solve(0, field, p));
} while (next_permutation(p.begin(), p.end()));

cout << ans << endl;
}
return 0;
}
```

Submission Info

Submission Time 2014-05-10 21:52:25+0900 D - 金塊ゲーム yuta1024 C++ (G++ 4.6.4) 80 1447 Byte WA 1940 ms 932 KB

Judge Result

Score / Max Score 0 / 0 80 / 80 0 / 19 0 / 1
Status
 AC × 3
 AC × 25
 AC × 25 WA × 3 RE × 22
 AC × 25 WA × 28 RE × 22
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 21 ms 928 KB
sample_02.txt AC 21 ms 924 KB
sample_03.txt AC 188 ms 928 KB
subtask1_01.txt AC 20 ms 804 KB
subtask1_02.txt AC 20 ms 800 KB
subtask1_03.txt AC 166 ms 928 KB
subtask1_04.txt AC 396 ms 808 KB
subtask1_05.txt AC 21 ms 932 KB
subtask1_06.txt AC 21 ms 924 KB
subtask1_07.txt AC 21 ms 796 KB
subtask1_08.txt AC 20 ms 812 KB
subtask1_09.txt AC 30 ms 800 KB
subtask1_10.txt AC 21 ms 804 KB
subtask1_11.txt AC 22 ms 924 KB
subtask1_12.txt AC 24 ms 920 KB
subtask1_13.txt AC 27 ms 804 KB
subtask1_14.txt AC 57 ms 760 KB
subtask1_15.txt AC 1940 ms 932 KB
subtask1_16.txt AC 563 ms 920 KB
subtask1_17.txt AC 548 ms 796 KB
subtask1_18.txt AC 293 ms 796 KB
subtask1_19.txt AC 144 ms 924 KB
subtask1_20.txt AC 143 ms 928 KB
subtask1_21.txt AC 740 ms 920 KB
subtask1_22.txt AC 1128 ms 928 KB
subtask1_23.txt AC 458 ms 792 KB
subtask1_24.txt AC 1759 ms 800 KB
subtask1_25.txt AC 1926 ms 924 KB
subtask2_01.txt RE 347 ms 800 KB
subtask2_02.txt RE 251 ms 808 KB
subtask2_03.txt RE 255 ms 924 KB
subtask2_04.txt RE 256 ms 924 KB
subtask2_05.txt RE 253 ms 796 KB
subtask2_06.txt RE 243 ms 800 KB
subtask2_07.txt RE 260 ms 800 KB
subtask2_08.txt RE 256 ms 800 KB
subtask2_09.txt RE 245 ms 800 KB
subtask2_10.txt RE 239 ms 800 KB
subtask2_11.txt RE 247 ms 736 KB
subtask2_12.txt RE 239 ms 792 KB
subtask2_13.txt WA 20 ms 800 KB
subtask2_14.txt RE 255 ms 920 KB
subtask2_15.txt WA 20 ms 916 KB
subtask2_16.txt RE 253 ms 924 KB
subtask2_17.txt RE 252 ms 784 KB
subtask2_18.txt RE 247 ms 928 KB
subtask2_19.txt WA 21 ms 800 KB
subtask2_20.txt RE 243 ms 932 KB
subtask2_21.txt RE 239 ms 920 KB
subtask2_22.txt RE 243 ms 800 KB
subtask2_23.txt RE 253 ms 796 KB
subtask2_24.txt RE 239 ms 924 KB
subtask2_25.txt RE 246 ms 796 KB
subtask3_01.txt WA 21 ms 800 KB
subtask3_02.txt WA 20 ms 924 KB
subtask3_03.txt WA 20 ms 796 KB
subtask3_04.txt WA 20 ms 800 KB
subtask3_05.txt WA 21 ms 928 KB
subtask3_06.txt WA 21 ms 804 KB
subtask3_07.txt WA 20 ms 928 KB
subtask3_08.txt WA 21 ms 796 KB
subtask3_09.txt WA 20 ms 800 KB
subtask3_10.txt WA 19 ms 796 KB
subtask3_11.txt WA 20 ms 924 KB
subtask3_12.txt WA 20 ms 800 KB
subtask3_13.txt WA 21 ms 796 KB
subtask3_14.txt WA 20 ms 796 KB
subtask3_15.txt WA 21 ms 796 KB
subtask3_16.txt WA 21 ms 676 KB
subtask3_17.txt WA 20 ms 924 KB
subtask3_18.txt WA 20 ms 920 KB
subtask3_19.txt WA 19 ms 924 KB
subtask3_20.txt WA 20 ms 928 KB
subtask3_21.txt WA 21 ms 800 KB
subtask3_22.txt WA 20 ms 928 KB
subtask3_23.txt WA 21 ms 928 KB
subtask3_24.txt WA 20 ms 792 KB
subtask3_25.txt WA 20 ms 796 KB