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

Submission #169964

Source Code Expand

Copy
```#include <iostream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

unsigned W, H, N;

typedef std::vector<bool>     FieldRow;
typedef std::vector<FieldRow> Field;

typedef std::pair<int, int> Point2D;
std::vector<Point2D> M;

unsigned count(const std::vector<unsigned>& v) {
Field field = Field(H);
for(unsigned h=0; h<H; ++h) {
field[h] = FieldRow(W);
std::fill(field[h].begin(), field[h].end(), false);
}

for(unsigned n=0; n<N; ++n) {
Point2D p = M[ v[n] ];

field[p.second][p.first] = true;
for(int x=p.first+1, y=p.second; (x< W && !field[y][x]); ++x) field[y][x]=true;
for(int x=p.first-1, y=p.second; (x>=0 && !field[y][x]); --x) field[y][x]=true;
for(int x=p.first, y=p.second+1; (y< H && !field[y][x]); ++y) field[y][x]=true;
for(int x=p.first, y=p.second-1; (y>=0 && !field[y][x]); --y) field[y][x]=true;
}

unsigned c = 0;
for(unsigned y=0; y<H; ++y) {
for(unsigned x=0; x<W; ++x) {
if(field[y][x]) ++c;
}
}
return c;
}

int main(void) {
std::cin >> W >> H >> N;

for(unsigned n=0; n<N; ++n) {
unsigned x, y;
std::cin >> x >> y;
M.push_back( Point2D(x-1, y-1) );
}

std::vector<unsigned> array(N);
for(unsigned n=0; n<N; ++n) array[n] = n;

unsigned max = 0;
do {
unsigned ret = count(array);
if(ret > max) max = ret;
} while( std::next_permutation(array.begin(), array.end()) );

std::cout << max << std::endl;

return 0;
}```

Submission Info

Submission Time 2014-05-11 00:07:08+0900 D - 金塊ゲーム material C++11 (GCC 4.8.1) 80 1635 Byte MLE 4046 ms 1048576 KB

Judge Result

Score / Max Score 0 / 0 80 / 80 0 / 19 0 / 1
Status
 AC × 3
 AC × 25
 AC × 25 TLE × 25
 AC × 25 TLE × 37 MLE × 13
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 20 ms 800 KB
sample_02.txt AC 20 ms 800 KB
sample_03.txt AC 82 ms 796 KB
subtask1_01.txt AC 21 ms 932 KB
subtask1_02.txt AC 20 ms 796 KB
subtask1_03.txt AC 69 ms 804 KB
subtask1_04.txt AC 188 ms 796 KB
subtask1_05.txt AC 21 ms 928 KB
subtask1_06.txt AC 21 ms 924 KB
subtask1_07.txt AC 21 ms 800 KB
subtask1_08.txt AC 20 ms 800 KB
subtask1_09.txt AC 28 ms 748 KB
subtask1_10.txt AC 22 ms 920 KB
subtask1_11.txt AC 20 ms 928 KB
subtask1_12.txt AC 22 ms 928 KB
subtask1_13.txt AC 26 ms 756 KB
subtask1_14.txt AC 46 ms 804 KB
subtask1_15.txt AC 1488 ms 792 KB
subtask1_16.txt AC 296 ms 676 KB
subtask1_17.txt AC 299 ms 804 KB
subtask1_18.txt AC 110 ms 804 KB
subtask1_19.txt AC 61 ms 804 KB
subtask1_20.txt AC 63 ms 804 KB
subtask1_21.txt AC 438 ms 808 KB
subtask1_22.txt AC 661 ms 796 KB
subtask1_23.txt AC 200 ms 796 KB
subtask1_24.txt AC 1320 ms 804 KB
subtask1_25.txt AC 1484 ms 800 KB
subtask2_01.txt TLE 4029 ms 796 KB
subtask2_02.txt TLE 4029 ms 816 KB
subtask2_03.txt TLE 4029 ms 920 KB
subtask2_04.txt TLE 4029 ms 804 KB
subtask2_05.txt TLE 4029 ms 800 KB
subtask2_06.txt TLE 4029 ms 808 KB
subtask2_07.txt TLE 4029 ms 804 KB
subtask2_08.txt TLE 4029 ms 804 KB
subtask2_09.txt TLE 4029 ms 932 KB
subtask2_10.txt TLE 4029 ms 884 KB
subtask2_11.txt TLE 4028 ms 800 KB
subtask2_12.txt TLE 4037 ms 928 KB
subtask2_13.txt TLE 4040 ms 296 KB
subtask2_14.txt TLE 4028 ms 804 KB
subtask2_15.txt TLE 4029 ms 804 KB
subtask2_16.txt TLE 4029 ms 812 KB
subtask2_17.txt TLE 4029 ms 808 KB
subtask2_18.txt TLE 4029 ms 800 KB
subtask2_19.txt TLE 4030 ms 812 KB
subtask2_20.txt TLE 4029 ms 808 KB
subtask2_21.txt TLE 4030 ms 924 KB
subtask2_22.txt TLE 4029 ms 800 KB
subtask2_23.txt TLE 4029 ms 808 KB
subtask2_24.txt TLE 4028 ms 928 KB
subtask2_25.txt TLE 4030 ms 860 KB
subtask3_01.txt MLE 1682 ms 1048576 KB
subtask3_02.txt MLE 1698 ms 1048576 KB
subtask3_03.txt TLE 4038 ms 71204 KB
subtask3_04.txt TLE 4029 ms 812 KB
subtask3_05.txt TLE 4030 ms 920 KB
subtask3_06.txt MLE 1684 ms 1048576 KB
subtask3_07.txt TLE 4038 ms 71136 KB
subtask3_08.txt TLE 4030 ms 5160 KB
subtask3_09.txt MLE 1670 ms 1048576 KB
subtask3_10.txt TLE 4038 ms 71168 KB
subtask3_11.txt MLE 1714 ms 1048576 KB
subtask3_12.txt TLE 4029 ms 3236 KB
subtask3_13.txt MLE 1700 ms 1048576 KB
subtask3_14.txt TLE 4029 ms 6936 KB
subtask3_15.txt TLE 4036 ms 71204 KB
subtask3_16.txt TLE 4030 ms 5740 KB
subtask3_17.txt MLE 1696 ms 1048576 KB
subtask3_18.txt TLE 4037 ms 71128 KB
subtask3_19.txt MLE 1710 ms 1048576 KB
subtask3_20.txt TLE 4046 ms 71132 KB
subtask3_21.txt MLE 1750 ms 1048576 KB
subtask3_22.txt MLE 1729 ms 1048576 KB
subtask3_23.txt MLE 1690 ms 1048576 KB
subtask3_24.txt MLE 1700 ms 1048576 KB
subtask3_25.txt MLE 1699 ms 1048576 KB