結果

提出番号 1250
提出者 zohen0
言語 C++
提出日時 2018-06-20 20:01:18
問題名 (62)SuperCon2018(独自テスト)
結果 AC
点数 2494000

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 370000 376ms 8112KB
2 AC 400000 403ms 8192KB
3 AC 380000 393ms 8400KB
4 AC 360000 373ms 8272KB
5 AC 390000 401ms 8448KB
6 AC 300000 313ms 8352KB
7 AC 200000 207ms 8400KB
8 AC 400000 405ms 8096KB
9 AC 260000 269ms 8352KB
10 AC 380000 390ms 8016KB
テストケース 結果 得点 実行時間 メモリ使用量
11 AC 250000 260ms 7232KB
12 AC 360000 366ms 8352KB
13 AC 200000 203ms 8416KB
14 AC 320000 326ms 7616KB
15 AC 380000 393ms 8032KB
16 AC 390000 400ms 7616KB
17 AC 300000 307ms 8128KB
18 AC 360000 371ms 7872KB
19 AC 260000 268ms 7888KB
20 AC 270000 278ms 8128KB
テストケース 結果 得点 実行時間 メモリ使用量
21 AC 360000 366ms 7968KB
22 AC 290000 295ms 8240KB
23 AC 140000 149ms 8720KB
24 AC 290000 298ms 8416KB
25 AC 360000 366ms 8320KB
26 AC 310000 315ms 8400KB
27 AC 390000 394ms 7248KB
28 AC 190000 195ms 8736KB
29 AC 160000 170ms 8704KB
30 AC 260000 265ms 8592KB
テストケース 結果 得点 実行時間 メモリ使用量
31 AC 160000 169ms 7952KB
32 AC 380000 388ms 8000KB
33 AC 350000 356ms 8400KB
34 AC 180000 183ms 8704KB
35 AC 240000 253ms 7552KB
36 AC 340000 343ms 8080KB
37 AC 210000 215ms 8704KB
38 AC 330000 334ms 7520KB
39 AC 280000 286ms 8208KB
40 AC 380000 386ms 7984KB
テストケース 結果 得点 実行時間 メモリ使用量
41 AC 260000 262ms 8480KB
42 AC 200000 206ms 7520KB
43 AC 280000 286ms 7904KB
44 AC 160000 166ms 8480KB
45 AC 250000 259ms 7824KB
46 AC 110000 115ms 8336KB
47 AC 310000 317ms 7920KB
48 AC 220000 227ms 8480KB
49 AC 200000 202ms 8096KB
50 AC 140000 144ms 7216KB
テストケース 結果 得点 実行時間 メモリ使用量
51 AC 100000 108ms 7952KB
52 AC 330000 337ms 7936KB
53 AC 330000 336ms 7808KB
54 AC 240000 250ms 7504KB
55 AC 280000 285ms 8448KB
56 AC 300000 312ms 8304KB
57 AC 250000 258ms 8448KB
58 AC 230000 237ms 7936KB
59 AC 150000 158ms 7984KB
60 AC 220000 227ms 8208KB
テストケース 結果 得点 実行時間 メモリ使用量
61 AC 140000 150ms 8464KB
62 AC 290000 297ms 8144KB
63 AC 360000 367ms 8400KB
64 AC 120000 127ms 8480KB
65 AC 180000 192ms 8688KB
66 AC 200000 209ms 7952KB
67 AC 220000 228ms 8384KB
68 AC 160000 165ms 8432KB
69 AC 120000 125ms 8416KB
70 AC 330000 335ms 7968KB
テストケース 結果 得点 実行時間 メモリ使用量
71 AC 60000 73ms 7952KB
72 AC 350000 357ms 7632KB
73 AC 360000 373ms 7840KB
74 AC 260000 268ms 7968KB
75 AC 110000 121ms 8432KB
76 AC 120000 123ms 8144KB
77 AC 200000 208ms 7504KB
78 AC 170000 176ms 7808KB
79 AC 190000 199ms 8432KB
80 AC 300000 316ms 8192KB
テストケース 結果 得点 実行時間 メモリ使用量
81 AC 240000 247ms 8432KB
82 AC 120000 125ms 8112KB
83 AC 240000 253ms 8416KB
84 AC 190000 198ms 7520KB
85 AC 240000 245ms 8704KB
86 AC 120000 128ms 8720KB
87 AC 200000 213ms 8016KB
88 AC 240000 253ms 8416KB
89 AC 120000 131ms 8320KB
90 AC 270000 283ms 7920KB
テストケース 結果 得点 実行時間 メモリ使用量
91 AC 220000 231ms 7872KB
92 AC 140000 145ms 7504KB
93 AC 300000 305ms 7504KB
94 AC 170000 175ms 8400KB
95 AC 130000 138ms 8000KB
96 AC 390000 396ms 8000KB
97 AC 240000 247ms 8064KB
98 AC 60000 68ms 8096KB
99 AC 210000 214ms 8272KB
100 AC 250000 259ms 8432KB

ソースコード

#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));
}using namespace std;

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

//他人用