結果

提出番号 1297
提出者 zohen0
言語 C++
提出日時 2018-06-20 22:15:40
問題名 (62)SuperCon2018(独自テスト)
結果 AC
点数 2621000

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 400000 404ms 7632KB
2 AC 400000 402ms 8432KB
3 AC 380000 393ms 8432KB
4 AC 400000 403ms 7952KB
5 AC 390000 400ms 7984KB
6 AC 330000 338ms 8432KB
7 AC 300000 311ms 8176KB
8 AC 400000 406ms 8192KB
9 AC 400000 405ms 7984KB
10 AC 400000 406ms 7936KB
テストケース 結果 得点 実行時間 メモリ使用量
11 AC 250000 260ms 8400KB
12 AC 400000 403ms 7248KB
13 AC 200000 203ms 7920KB
14 AC 210000 215ms 8480KB
15 AC 380000 392ms 7632KB
16 AC 390000 400ms 7952KB
17 AC 290000 298ms 8432KB
18 AC 400000 406ms 8416KB
19 AC 370000 374ms 7808KB
20 AC 270000 277ms 7984KB
テストケース 結果 得点 実行時間 メモリ使用量
21 AC 360000 371ms 7520KB
22 AC 310000 317ms 8128KB
23 AC 160000 168ms 8448KB
24 AC 290000 297ms 8432KB
25 AC 350000 355ms 8112KB
26 AC 310000 314ms 8448KB
27 AC 400000 408ms 8416KB
28 AC 290000 294ms 8224KB
29 AC 260000 262ms 7248KB
30 AC 360000 372ms 8336KB
テストケース 結果 得点 実行時間 メモリ使用量
31 AC 160000 168ms 8016KB
32 AC 370000 381ms 8064KB
33 AC 340000 347ms 8416KB
34 AC 200000 203ms 8432KB
35 AC 220000 228ms 7904KB
36 AC 340000 343ms 8128KB
37 AC 320000 322ms 7824KB
38 AC 330000 335ms 8432KB
39 AC 310000 315ms 7984KB
40 AC 390000 398ms 8400KB
テストケース 結果 得点 実行時間 メモリ使用量
41 AC 390000 396ms 8048KB
42 AC 200000 205ms 7248KB
43 AC 280000 286ms 8384KB
44 AC 240000 253ms 8128KB
45 AC 260000 266ms 8144KB
46 AC 160000 171ms 8400KB
47 AC 310000 317ms 7936KB
48 AC 240000 252ms 8416KB
49 AC 190000 201ms 7920KB
50 AC 90000 95ms 8336KB
テストケース 結果 得点 実行時間 メモリ使用量
51 AC 100000 109ms 8432KB
52 AC 340000 345ms 8064KB
53 AC 330000 334ms 7520KB
54 AC 240000 250ms 8160KB
55 AC 280000 285ms 8448KB
56 AC 310000 314ms 8448KB
57 AC 250000 258ms 8144KB
58 AC 230000 237ms 7248KB
59 AC 150000 158ms 8240KB
60 AC 300000 308ms 8080KB
テストケース 結果 得点 実行時間 メモリ使用量
61 AC 160000 167ms 7984KB
62 AC 280000 288ms 8432KB
63 AC 360000 366ms 7984KB
64 AC 160000 172ms 7776KB
65 AC 200000 213ms 7824KB
66 AC 200000 208ms 8416KB
67 AC 210000 218ms 8400KB
68 AC 160000 162ms 8016KB
69 AC 100000 113ms 8672KB
70 AC 330000 334ms 7936KB
テストケース 結果 得点 実行時間 メモリ使用量
71 AC 60000 73ms 7904KB
72 AC 350000 358ms 8416KB
73 AC 370000 374ms 7952KB
74 AC 260000 268ms 8416KB
75 AC 120000 123ms 7248KB
76 AC 120000 124ms 8128KB
77 AC 200000 208ms 7984KB
78 AC 120000 131ms 8704KB
79 AC 170000 179ms 8672KB
80 AC 300000 307ms 8416KB
テストケース 結果 得点 実行時間 メモリ使用量
81 AC 160000 163ms 7520KB
82 AC 180000 186ms 8400KB
83 AC 240000 252ms 8400KB
84 AC 200000 213ms 8448KB
85 AC 240000 246ms 8400KB
86 AC 180000 191ms 8064KB
87 AC 130000 137ms 7776KB
88 AC 250000 254ms 8112KB
89 AC 140000 145ms 7936KB
90 AC 270000 274ms 7536KB
テストケース 結果 得点 実行時間 メモリ使用量
91 AC 220000 231ms 7792KB
92 AC 210000 217ms 8064KB
93 AC 290000 298ms 7824KB
94 AC 170000 175ms 8416KB
95 AC 120000 125ms 7824KB
96 AC 400000 408ms 8032KB
97 AC 230000 240ms 7936KB
98 AC 60000 68ms 7616KB
99 AC 320000 323ms 8128KB
100 AC 250000 260ms 8144KB

ソースコード

#include <bitset>
#include <complex>
#include<stdio.h>
#include<time.h>
using namespace std;

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