結果

提出番号 1291
提出者 zohen0
言語 C++
提出日時 2018-06-20 21:59:00
問題名 (62)SuperCon2018(独自テスト)
結果 AC
点数 2619000

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 410000 420ms 8432KB
2 AC 400000 413ms 7520KB
3 AC 390000 399ms 8160KB
4 AC 400000 403ms 8384KB
5 AC 400000 409ms 8416KB
6 AC 310000 314ms 8480KB
7 AC 300000 311ms 8192KB
8 AC 400000 406ms 7808KB
9 AC 400000 412ms 8192KB
10 AC 380000 391ms 8416KB
テストケース 結果 得点 実行時間 メモリ使用量
11 AC 270000 280ms 7984KB
12 AC 400000 403ms 7616KB
13 AC 200000 203ms 7824KB
14 AC 290000 298ms 8096KB
15 AC 250000 259ms 8688KB
16 AC 400000 405ms 8416KB
17 AC 290000 298ms 8272KB
18 AC 400000 406ms 8432KB
19 AC 400000 404ms 7248KB
20 AC 270000 278ms 8416KB
テストケース 結果 得点 実行時間 メモリ使用量
21 AC 360000 365ms 8416KB
22 AC 310000 318ms 8016KB
23 AC 170000 178ms 8432KB
24 AC 300000 302ms 7808KB
25 AC 350000 357ms 7232KB
26 AC 310000 314ms 8448KB
27 AC 360000 371ms 8240KB
28 AC 200000 203ms 8688KB
29 AC 250000 255ms 8416KB
30 AC 390000 401ms 8384KB
テストケース 結果 得点 実行時間 メモリ使用量
31 AC 160000 168ms 8432KB
32 AC 250000 259ms 7904KB
33 AC 340000 349ms 7920KB
34 AC 180000 191ms 8272KB
35 AC 250000 254ms 7952KB
36 AC 340000 344ms 8128KB
37 AC 320000 322ms 7808KB
38 AC 330000 335ms 7824KB
39 AC 310000 319ms 7984KB
40 AC 380000 387ms 8112KB
テストケース 結果 得点 実行時間 メモリ使用量
41 AC 390000 395ms 8128KB
42 AC 200000 213ms 8192KB
43 AC 280000 287ms 7936KB
44 AC 240000 242ms 7600KB
45 AC 250000 255ms 7792KB
46 AC 170000 177ms 7232KB
47 AC 280000 285ms 7904KB
48 AC 240000 252ms 7648KB
49 AC 200000 210ms 8432KB
50 AC 140000 146ms 7824KB
テストケース 結果 得点 実行時間 メモリ使用量
51 AC 70000 76ms 8720KB
52 AC 300000 302ms 8464KB
53 AC 330000 334ms 7232KB
54 AC 240000 249ms 8416KB
55 AC 280000 285ms 7520KB
56 AC 300000 304ms 7824KB
57 AC 250000 257ms 8048KB
58 AC 250000 257ms 8128KB
59 AC 150000 157ms 8128KB
60 AC 220000 228ms 8672KB
テストケース 結果 得点 実行時間 メモリ使用量
61 AC 140000 156ms 8704KB
62 AC 280000 289ms 8384KB
63 AC 380000 388ms 7824KB
64 AC 170000 178ms 8096KB
65 AC 210000 223ms 8448KB
66 AC 200000 209ms 8016KB
67 AC 210000 219ms 8416KB
68 AC 160000 162ms 7824KB
69 AC 120000 125ms 7248KB
70 AC 340000 345ms 7216KB
テストケース 結果 得点 実行時間 メモリ使用量
71 AC 60000 73ms 7968KB
72 AC 350000 357ms 8080KB
73 AC 370000 374ms 8176KB
74 AC 260000 268ms 7984KB
75 AC 70000 80ms 8240KB
76 AC 120000 123ms 8416KB
77 AC 200000 209ms 7920KB
78 AC 190000 195ms 8160KB
79 AC 190000 199ms 7968KB
80 AC 300000 310ms 8112KB
テストケース 結果 得点 実行時間 メモリ使用量
81 AC 220000 228ms 8272KB
82 AC 160000 168ms 8656KB
83 AC 240000 252ms 8112KB
84 AC 190000 199ms 8400KB
85 AC 260000 270ms 8400KB
86 AC 190000 196ms 7808KB
87 AC 200000 205ms 8432KB
88 AC 250000 256ms 8384KB
89 AC 130000 134ms 7808KB
90 AC 280000 284ms 7536KB
テストケース 結果 得点 実行時間 メモリ使用量
91 AC 220000 231ms 8064KB
92 AC 140000 145ms 8704KB
93 AC 290000 298ms 8304KB
94 AC 170000 175ms 7504KB
95 AC 80000 93ms 8688KB
96 AC 390000 395ms 7536KB
97 AC 150000 160ms 8336KB
98 AC 60000 68ms 8432KB
99 AC 280000 291ms 8672KB
100 AC 230000 234ms 8352KB

ソースコード

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