ソースコード 拡げる

Copy
```#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define MINF 0xc0c0c0c0

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){

int W,H;
while(~scanf("%d %d",&W,&H)){

int res = 0;
vector<int> pos;
int N;
scanf("%d",&N);
for(int i=0;i<N;i++){
int x,y;
scanf("%d %d",&x,&y);
pos.push_back(y*(W+2)+x);
}

if(W > 80 || H > 80 || N > 8){
goto gameover;
}
sort(pos.begin(),pos.end());

do{
int stage[82][82];
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
if(y == 0 || x == 0 || y == H+1 || x == W+1){
stage[y][x] = 0;
}
else{
stage[y][x] = 1;
}
}
}
int tmp = pos.size();
for(int i=0;i<pos.size();i++){
int sx = pos[i] % (W+2);
int sy = pos[i] / (W+2);

for(int dir=0;dir<4;dir++){
for(int length = 1; length <= max(W,H) + 2;length++){
int dx = tx[dir]*length + sx;
int dy = ty[dir]*length + sy;
if(dx < 1 || dx > W || dy < 1 || dy > H) continue;
if(stage[dy][dx] == 0) break;
tmp++;
stage[dy][dx] = 0;
}
}
}
res = max(tmp,res);
}while(next_permutation(pos.begin(),pos.end()));

gameover:;
printf("%d\n",res);
}
}```

#### 提出情報

提出日時 2014-05-10 22:31:31+0900 D - 金塊ゲーム okaoka C++ (G++ 4.6.4) 80 1753 Byte WA 965 ms 932 KB

#### コンパイルエラー

```./Main.cpp: In function ‘int main()’:
./Main.cpp:43:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:46:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
```

#### ジャッジ結果

 AC × 3
 AC × 25
 AC × 25 WA × 25
 AC × 25 WA × 50
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 20 ms 796 KB
sample_02.txt AC 20 ms 928 KB
sample_03.txt AC 113 ms 808 KB
subtask1_01.txt AC 20 ms 800 KB
subtask1_02.txt AC 24 ms 808 KB
subtask1_03.txt AC 89 ms 920 KB
subtask1_04.txt AC 183 ms 932 KB
subtask1_05.txt AC 21 ms 800 KB
subtask1_06.txt AC 21 ms 804 KB
subtask1_07.txt AC 21 ms 932 KB
subtask1_08.txt AC 20 ms 804 KB
subtask1_09.txt AC 24 ms 804 KB
subtask1_10.txt AC 21 ms 928 KB
subtask1_11.txt AC 21 ms 808 KB
subtask1_12.txt AC 22 ms 804 KB
subtask1_13.txt AC 25 ms 804 KB
subtask1_14.txt AC 36 ms 928 KB
subtask1_15.txt AC 946 ms 796 KB
subtask1_16.txt AC 248 ms 932 KB
subtask1_17.txt AC 300 ms 924 KB
subtask1_18.txt AC 131 ms 928 KB
subtask1_19.txt AC 83 ms 804 KB
subtask1_20.txt AC 84 ms 796 KB
subtask1_21.txt AC 341 ms 928 KB
subtask1_22.txt AC 455 ms 928 KB
subtask1_23.txt AC 175 ms 804 KB
subtask1_24.txt AC 836 ms 924 KB
subtask1_25.txt AC 965 ms 804 KB
subtask2_01.txt WA 21 ms 752 KB
subtask2_02.txt WA 20 ms 928 KB
subtask2_03.txt WA 20 ms 924 KB
subtask2_04.txt WA 19 ms 928 KB
subtask2_05.txt WA 21 ms 752 KB
subtask2_06.txt WA 21 ms 800 KB
subtask2_07.txt WA 21 ms 932 KB
subtask2_08.txt WA 21 ms 932 KB
subtask2_09.txt WA 21 ms 928 KB
subtask2_10.txt WA 20 ms 924 KB
subtask2_11.txt WA 21 ms 924 KB
subtask2_12.txt WA 21 ms 928 KB
subtask2_13.txt WA 21 ms 924 KB
subtask2_14.txt WA 20 ms 928 KB
subtask2_15.txt WA 21 ms 928 KB
subtask2_16.txt WA 20 ms 932 KB
subtask2_17.txt WA 21 ms 924 KB
subtask2_18.txt WA 21 ms 932 KB
subtask2_19.txt WA 21 ms 924 KB
subtask2_20.txt WA 21 ms 924 KB
subtask2_21.txt WA 21 ms 928 KB
subtask2_22.txt WA 21 ms 804 KB
subtask2_23.txt WA 19 ms 924 KB
subtask2_24.txt WA 20 ms 924 KB
subtask2_25.txt WA 20 ms 796 KB
subtask3_01.txt WA 20 ms 928 KB
subtask3_02.txt WA 21 ms 928 KB
subtask3_03.txt WA 20 ms 932 KB
subtask3_04.txt WA 21 ms 928 KB
subtask3_05.txt WA 20 ms 804 KB
subtask3_06.txt WA 23 ms 932 KB
subtask3_07.txt WA 20 ms 920 KB
subtask3_08.txt WA 21 ms 808 KB
subtask3_09.txt WA 21 ms 804 KB
subtask3_10.txt WA 20 ms 928 KB
subtask3_11.txt WA 20 ms 928 KB
subtask3_12.txt WA 21 ms 928 KB
subtask3_13.txt WA 21 ms 932 KB
subtask3_14.txt WA 21 ms 928 KB
subtask3_15.txt WA 21 ms 924 KB
subtask3_16.txt WA 21 ms 928 KB
subtask3_17.txt WA 20 ms 928 KB
subtask3_18.txt WA 21 ms 932 KB
subtask3_19.txt WA 21 ms 928 KB
subtask3_20.txt WA 21 ms 932 KB
subtask3_21.txt WA 20 ms 932 KB
subtask3_22.txt WA 21 ms 932 KB
subtask3_23.txt WA 20 ms 932 KB
subtask3_24.txt WA 21 ms 804 KB
subtask3_25.txt WA 20 ms 756 KB