Submission #169577


Source Code Expand

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+x);
    }

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

    do{
      int stage[82][82];
      fill((int*)stage,(int*)stage+82*82,1);
      
      int tmp = 0;

      for(int i=0;i<pos.size();i++){
	int sx = pos[i] % W;
	int sy = pos[i] / W;
	if(stage[sy][sx] == 1){
	  stage[sy][sx] = 0;
	  tmp++;
	}	
	for(int dir=0;dir<4;dir++){
	  for(int length = 1; length <= max(W,H);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);
  }
}

Submission Info

Submission Time
Task D - 金塊ゲーム
User okaoka
Language C++ (G++ 4.6.4)
Score 0
Code Size 1659 Byte
Status WA
Exec Time 418 ms
Memory 924 KB

Compile Error

./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]

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 80 0 / 19 0 / 1
Status
AC × 3
AC × 16
WA × 9
AC × 16
WA × 34
AC × 16
WA × 59
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt, subtask3_13.txt, subtask3_14.txt, subtask3_15.txt, subtask3_16.txt, subtask3_17.txt, subtask3_18.txt, subtask3_19.txt, subtask3_20.txt, subtask3_21.txt, subtask3_22.txt, subtask3_23.txt, subtask3_24.txt, subtask3_25.txt
Case Name Status Exec Time Memory
sample_01.txt AC 22 ms 916 KB
sample_02.txt AC 22 ms 916 KB
sample_03.txt AC 207 ms 924 KB
subtask1_01.txt WA 21 ms 920 KB
subtask1_02.txt AC 23 ms 820 KB
subtask1_03.txt WA 193 ms 808 KB
subtask1_04.txt AC 244 ms 812 KB
subtask1_05.txt AC 22 ms 920 KB
subtask1_06.txt WA 26 ms 728 KB
subtask1_07.txt WA 21 ms 920 KB
subtask1_08.txt AC 22 ms 808 KB
subtask1_09.txt AC 27 ms 844 KB
subtask1_10.txt AC 24 ms 916 KB
subtask1_11.txt AC 24 ms 924 KB
subtask1_12.txt WA 26 ms 804 KB
subtask1_13.txt AC 27 ms 808 KB
subtask1_14.txt AC 28 ms 804 KB
subtask1_15.txt AC 400 ms 924 KB
subtask1_16.txt AC 271 ms 808 KB
subtask1_17.txt AC 287 ms 916 KB
subtask1_18.txt WA 223 ms 920 KB
subtask1_19.txt WA 191 ms 916 KB
subtask1_20.txt WA 192 ms 920 KB
subtask1_21.txt AC 280 ms 908 KB
subtask1_22.txt AC 370 ms 908 KB
subtask1_23.txt WA 261 ms 916 KB
subtask1_24.txt AC 390 ms 916 KB
subtask1_25.txt AC 418 ms 920 KB
subtask2_01.txt WA 20 ms 920 KB
subtask2_02.txt WA 23 ms 920 KB
subtask2_03.txt WA 23 ms 920 KB
subtask2_04.txt WA 21 ms 796 KB
subtask2_05.txt WA 23 ms 800 KB
subtask2_06.txt WA 23 ms 796 KB
subtask2_07.txt WA 21 ms 796 KB
subtask2_08.txt WA 20 ms 912 KB
subtask2_09.txt WA 21 ms 920 KB
subtask2_10.txt WA 22 ms 912 KB
subtask2_11.txt WA 21 ms 908 KB
subtask2_12.txt WA 22 ms 920 KB
subtask2_13.txt WA 22 ms 924 KB
subtask2_14.txt WA 22 ms 916 KB
subtask2_15.txt WA 25 ms 920 KB
subtask2_16.txt WA 22 ms 924 KB
subtask2_17.txt WA 23 ms 912 KB
subtask2_18.txt WA 23 ms 916 KB
subtask2_19.txt WA 21 ms 924 KB
subtask2_20.txt WA 22 ms 808 KB
subtask2_21.txt WA 35 ms 912 KB
subtask2_22.txt WA 35 ms 792 KB
subtask2_23.txt WA 23 ms 816 KB
subtask2_24.txt WA 23 ms 920 KB
subtask2_25.txt WA 20 ms 912 KB
subtask3_01.txt WA 19 ms 916 KB
subtask3_02.txt WA 22 ms 912 KB
subtask3_03.txt WA 21 ms 812 KB
subtask3_04.txt WA 23 ms 840 KB
subtask3_05.txt WA 21 ms 920 KB
subtask3_06.txt WA 21 ms 920 KB
subtask3_07.txt WA 20 ms 916 KB
subtask3_08.txt WA 21 ms 920 KB
subtask3_09.txt WA 22 ms 816 KB
subtask3_10.txt WA 23 ms 804 KB
subtask3_11.txt WA 22 ms 792 KB
subtask3_12.txt WA 21 ms 912 KB
subtask3_13.txt WA 19 ms 920 KB
subtask3_14.txt WA 22 ms 848 KB
subtask3_15.txt WA 26 ms 796 KB
subtask3_16.txt WA 22 ms 892 KB
subtask3_17.txt WA 24 ms 920 KB
subtask3_18.txt WA 23 ms 920 KB
subtask3_19.txt WA 22 ms 804 KB
subtask3_20.txt WA 24 ms 808 KB
subtask3_21.txt WA 20 ms 804 KB
subtask3_22.txt WA 23 ms 792 KB
subtask3_23.txt WA 22 ms 920 KB
subtask3_24.txt WA 22 ms 812 KB
subtask3_25.txt WA 22 ms 916 KB