結果

提出番号 1288
提出者 zohen0
言語 C++
提出日時 2018-06-20 21:56:58
問題名 (62)SuperCon2018(独自テスト)
結果 CE
点数 0

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 CE 0 0ms 0KB
2 CE 0 0ms 0KB
3 CE 0 0ms 0KB
4 CE 0 0ms 0KB
5 CE 0 0ms 0KB
6 CE 0 0ms 0KB
7 CE 0 0ms 0KB
8 CE 0 0ms 0KB
9 CE 0 0ms 0KB
10 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
11 CE 0 0ms 0KB
12 CE 0 0ms 0KB
13 CE 0 0ms 0KB
14 CE 0 0ms 0KB
15 CE 0 0ms 0KB
16 CE 0 0ms 0KB
17 CE 0 0ms 0KB
18 CE 0 0ms 0KB
19 CE 0 0ms 0KB
20 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
21 CE 0 0ms 0KB
22 CE 0 0ms 0KB
23 CE 0 0ms 0KB
24 CE 0 0ms 0KB
25 CE 0 0ms 0KB
26 CE 0 0ms 0KB
27 CE 0 0ms 0KB
28 CE 0 0ms 0KB
29 CE 0 0ms 0KB
30 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
31 CE 0 0ms 0KB
32 CE 0 0ms 0KB
33 CE 0 0ms 0KB
34 CE 0 0ms 0KB
35 CE 0 0ms 0KB
36 CE 0 0ms 0KB
37 CE 0 0ms 0KB
38 CE 0 0ms 0KB
39 CE 0 0ms 0KB
40 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
41 CE 0 0ms 0KB
42 CE 0 0ms 0KB
43 CE 0 0ms 0KB
44 CE 0 0ms 0KB
45 CE 0 0ms 0KB
46 CE 0 0ms 0KB
47 CE 0 0ms 0KB
48 CE 0 0ms 0KB
49 CE 0 0ms 0KB
50 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
51 CE 0 0ms 0KB
52 CE 0 0ms 0KB
53 CE 0 0ms 0KB
54 CE 0 0ms 0KB
55 CE 0 0ms 0KB
56 CE 0 0ms 0KB
57 CE 0 0ms 0KB
58 CE 0 0ms 0KB
59 CE 0 0ms 0KB
60 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
61 CE 0 0ms 0KB
62 CE 0 0ms 0KB
63 CE 0 0ms 0KB
64 CE 0 0ms 0KB
65 CE 0 0ms 0KB
66 CE 0 0ms 0KB
67 CE 0 0ms 0KB
68 CE 0 0ms 0KB
69 CE 0 0ms 0KB
70 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
71 CE 0 0ms 0KB
72 CE 0 0ms 0KB
73 CE 0 0ms 0KB
74 CE 0 0ms 0KB
75 CE 0 0ms 0KB
76 CE 0 0ms 0KB
77 CE 0 0ms 0KB
78 CE 0 0ms 0KB
79 CE 0 0ms 0KB
80 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
81 CE 0 0ms 0KB
82 CE 0 0ms 0KB
83 CE 0 0ms 0KB
84 CE 0 0ms 0KB
85 CE 0 0ms 0KB
86 CE 0 0ms 0KB
87 CE 0 0ms 0KB
88 CE 0 0ms 0KB
89 CE 0 0ms 0KB
90 CE 0 0ms 0KB
テストケース 結果 得点 実行時間 メモリ使用量
91 CE 0 0ms 0KB
92 CE 0 0ms 0KB
93 CE 0 0ms 0KB
94 CE 0 0ms 0KB
95 CE 0 0ms 0KB
96 CE 0 0ms 0KB
97 CE 0 0ms 0KB
98 CE 0 0ms 0KB
99 CE 0 0ms 0KB
100 CE 0 0ms 0KB

ソースコード

#include <bitset>
#include <complex>
#include<stdio.h>
#include<time.h>

int scN,scM;
int scB[2][10];
clock_t scStartTime,scEndTime;
void scInput(){
	int i;
	scanf("%d%d",&scN,&scM);
	for(i=0;i<scM;++i){scanf("%d%d",&scB[0][i],&scB[1][i]);}
	scStartTime=clock();
}
void scOutput(int s){
	scEndTime=clock();
	printf("Ans= %d, time=%d\n",s,(int)(scEndTime-scStartTime));
}

int dfs1(bitset<441> route, const int depth, int x, int y);
int dfs2(bitset<441> route, const int depth, int x, int y);
int dfs3(bitset<441> route, const int depth, int x, int y);
int dfs4(bitset<441> route, const int depth, int x, int y);

int dfs1(bitset<441> route, const int depth, int x, int y) {
  if(route[x * 21 + y] || (x == 10 && y == 10)) return 0;

  route[x * 21 + y] = true;

  int tx = abs(x - 10), ty = abs(y - 10);

  int s = (scN - depth) - (tx + ty);

  if(s < 0) return 0;
  if(depth == scN - 1) {
    if(y == 9) return 2;
    return 1;
  }
  if(s == 0) {
    int kx = x - 10, ky = y - 10, ktx = 10, kty = 10;
    int kh[32][32] = {};
    kh[x][y] = 1;
    int xk = 1, yk = 1;
    if(kx > 0) xk = -1;
    if(ky > 0) yk = -1;

    for(int i = 0; i <= tx; i++) {
      for(int j = 0; j <= ty; j++) {
        if(route[(x + i * xk) * 21 + y + j * yk] || !i && !j) continue;
        kh[x + i * xk][y + j * yk] = kh[x + i * xk - xk][y + j * yk] + kh[x + i * xk][y + j * yk - yk];
      }
    }

    return kh[10][10] + kh[10][9];
  }

  return dfs1(route, depth + 1, x + 1, y) + dfs2(route, depth + 1, x, y + 1) + dfs4(route, depth + 1, x, y - 1);
}

int dfs2(bitset<441> route, const int depth, int x, int y) {
  if(route[x * 21 + y] || (x == 10 && y == 10)) return 0;

  route[x * 21 + y] = true;

  int tx = abs(x - 10), ty = abs(y - 10);

  int s = (scN - depth) - (tx + ty);

  if(s < 0) return 0;
  if(depth == scN - 1) {
    if(y == 9) return 2;
    return 1;
  }
  if(s == 0) {
    int kx = x - 10, ky = y - 10, ktx = 10, kty = 10;
    int kh[32][32] = {};
    kh[x][y] = 1;
    int xk = 1, yk = 1;
    if(kx > 0) xk = -1;
    if(ky > 0) yk = -1;

    for(int i = 0; i <= tx; i++) {
      for(int j = 0; j <= ty; j++) {
        if(route[(x + i * xk) * 21 + y + j * yk] || !i && !j) continue;
        kh[x + i * xk][y + j * yk] = kh[x + i * xk - xk][y + j * yk] + kh[x + i * xk][y + j * yk - yk];
      }
    }

    return kh[10][10] + kh[10][9];
  }

  return dfs1(route, depth + 1, x + 1, y) + dfs2(route, depth + 1, x, y + 1) + dfs3(route, depth + 1, x - 1, y);
}

int dfs3(bitset<441> route, const int depth, int x, int y) {
  if(route[x * 21 + y] || (x == 10 && y == 10)) return 0;

  route[x * 21 + y] = true;

  int tx = abs(x - 10), ty = abs(y - 10);

  int s = (scN - depth) - (tx + ty);

  if(s < 0) return 0;
  if(depth == scN - 1) {
    if(y == 9) return 2;
    return 1;
  }
  if(s == 0) {
    int kx = x - 10, ky = y - 10, ktx = 10, kty = 10;
    int kh[32][32] = {};
    kh[x][y] = 1;
    int xk = 1, yk = 1;
    if(kx > 0) xk = -1;
    if(ky > 0) yk = -1;

    for(int i = 0; i <= tx; i++) {
      for(int j = 0; j <= ty; j++) {
        if(route[(x + i * xk) * 21 + y + j * yk] || !i && !j) continue;
        kh[x + i * xk][y + j * yk] = kh[x + i * xk - xk][y + j * yk] + kh[x + i * xk][y + j * yk - yk];
      }
    }

    return kh[10][10] + kh[10][9];
  }

  return dfs2(route, depth + 1, x, y + 1) + dfs3(route, depth + 1, x - 1, y) + dfs4(route, depth + 1, x, y - 1);
}

int dfs4(bitset<441> route, const int depth, int x, int y) {
  if(route[x * 21 + y] || (x == 10 && y == 10)) return 0;

  route[x * 21 + y] = true;

  int tx = abs(x - 10), ty = abs(y - 10);

  int s = (scN - depth) - (tx + ty);

  if(s < 0) return 0;
  if(depth == scN - 1) {
    if(y == 9) return 2;
    return 1;
  }
  if(s == 0) {
    int kx = x - 10, ky = y - 10, ktx = 10, kty = 10;
    int kh[32][32] = {};
    kh[x][y] = 1;
    int xk = 1, yk = 1;
    if(kx > 0) xk = -1;
    if(ky > 0) yk = -1;

    for(int i = 0; i <= tx; i++) {
      for(int j = 0; j <= ty; j++) {
        if(route[(x + i * xk) * 21 + y + j * yk] || !i && !j) continue;
        kh[x + i * xk][y + j * yk] = kh[x + i * xk - xk][y + j * yk] + kh[x + i * xk][y + j * yk - yk];
      }
    }

    return kh[10][10] + kh[10][9];
  }

  return dfs1(route, depth + 1, x + 1, y) + dfs3(route, depth + 1, x - 1, y) + dfs4(route, depth + 1, x, y - 1);
}

int main(void) {
  int ans;
  bitset<441> route;

  scInput();

  for(int i = 0; i < scM; i++) {
    if(scB[0][i] <= 10 && scB[0][i] >= -10 && scB[1][i] <= 10 && scB[1][i] >= -10) {
      route[(scB[0][i] + 10) * 21 + scB[1][i] + 10] = true;
    }
  }

  ans = dfs1(route, 1, 11, 10) + dfs2(route, 1, 10, 11) + dfs3(route, 1, 9, 10);

  scOutput(ans);
}