結果

提出番号 1281
提出者 kotamanegi
言語 C++
提出日時 2018-06-20 21:52:05
問題名 (62)SuperCon2018(独自テスト)
結果 AC
点数 1190000

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 170000 176ms 7920KB
2 AC 170000 174ms 7232KB
3 AC 150000 156ms 8656KB
4 AC 170000 174ms 8064KB
5 AC 170000 175ms 7536KB
6 AC 150000 155ms 7936KB
7 AC 120000 132ms 7520KB
8 AC 170000 176ms 8144KB
9 AC 170000 176ms 7248KB
10 AC 150000 156ms 8448KB
テストケース 結果 得点 実行時間 メモリ使用量
11 AC 110000 121ms 7520KB
12 AC 170000 175ms 8192KB
13 AC 80000 84ms 8672KB
14 AC 140000 146ms 8400KB
15 AC 150000 156ms 8704KB
16 AC 170000 174ms 8432KB
17 AC 130000 137ms 8368KB
18 AC 170000 177ms 7200KB
19 AC 170000 176ms 8416KB
20 AC 110000 116ms 8704KB
テストケース 結果 得点 実行時間 メモリ使用量
21 AC 160000 162ms 7248KB
22 AC 120000 124ms 8272KB
23 AC 70000 76ms 8400KB
24 AC 110000 114ms 8304KB
25 AC 150000 155ms 8192KB
26 AC 120000 129ms 8272KB
27 AC 160000 172ms 7248KB
28 AC 120000 131ms 8016KB
29 AC 100000 109ms 8096KB
30 AC 170000 180ms 8352KB
テストケース 結果 得点 実行時間 メモリ使用量
31 AC 70000 79ms 7968KB
32 AC 160000 167ms 8448KB
33 AC 130000 139ms 8688KB
34 AC 80000 89ms 8080KB
35 AC 110000 118ms 8416KB
36 AC 140000 152ms 8432KB
37 AC 140000 146ms 8192KB
38 AC 140000 147ms 8416KB
39 AC 130000 141ms 8192KB
40 AC 150000 155ms 8704KB
テストケース 結果 得点 実行時間 メモリ使用量
41 AC 160000 173ms 8432KB
42 AC 80000 84ms 7792KB
43 AC 120000 130ms 7216KB
44 AC 100000 106ms 8096KB
45 AC 100000 103ms 7888KB
46 AC 80000 85ms 8240KB
47 AC 120000 130ms 7488KB
48 AC 100000 108ms 7504KB
49 AC 90000 99ms 7904KB
50 AC 50000 59ms 8704KB
テストケース 結果 得点 実行時間 メモリ使用量
51 AC 50000 55ms 8368KB
52 AC 140000 149ms 8416KB
53 AC 140000 150ms 8384KB
54 AC 100000 109ms 8432KB
55 AC 120000 127ms 8416KB
56 AC 120000 133ms 7216KB
57 AC 100000 112ms 7616KB
58 AC 90000 96ms 8400KB
59 AC 70000 77ms 8384KB
60 AC 130000 137ms 7904KB
テストケース 結果 得点 実行時間 メモリ使用量
61 AC 60000 69ms 8304KB
62 AC 100000 113ms 8688KB
63 AC 160000 163ms 8432KB
64 AC 90000 95ms 7920KB
65 AC 90000 96ms 8432KB
66 AC 90000 95ms 7936KB
67 AC 100000 105ms 8432KB
68 AC 60000 71ms 7936KB
69 AC 60000 64ms 7984KB
70 AC 140000 145ms 7968KB
テストケース 結果 得点 実行時間 メモリ使用量
71 AC 30000 36ms 8400KB
72 AC 150000 156ms 7520KB
73 AC 140000 148ms 8240KB
74 AC 100000 112ms 7520KB
75 AC 50000 59ms 8672KB
76 AC 40000 52ms 8704KB
77 AC 90000 100ms 8112KB
78 AC 80000 89ms 8400KB
79 AC 80000 93ms 8448KB
80 AC 130000 140ms 8416KB
テストケース 結果 得点 実行時間 メモリ使用量
81 AC 100000 104ms 8112KB
82 AC 70000 76ms 8480KB
83 AC 100000 106ms 8288KB
84 AC 80000 93ms 7520KB
85 AC 110000 122ms 8400KB
86 AC 80000 88ms 7808KB
87 AC 80000 89ms 8704KB
88 AC 100000 111ms 8400KB
89 AC 60000 68ms 8400KB
90 AC 100000 112ms 8256KB
テストケース 結果 得点 実行時間 メモリ使用量
91 AC 90000 95ms 7904KB
92 AC 80000 90ms 7504KB
93 AC 110000 116ms 8672KB
94 AC 80000 85ms 8016KB
95 AC 60000 65ms 7520KB
96 AC 160000 171ms 8448KB
97 AC 100000 108ms 8384KB
98 AC 40000 42ms 8160KB
99 AC 120000 132ms 8688KB
100 AC 110000 114ms 7936KB

ソースコード

//sc1.hの内容を一番上にコピペする
#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));
}
//ここまでsc1.hの内容
//sc1.hをincludeするとCompile Errorになります
#include "algorithm"

const int SIZE = 100;
using namespace std;
int main(){
	scInput();
	int griding[200][200] = {};
	int badding[200][200] = {};
	int dp[200][200] = {};
	int xe[4] = {0,0,1,-1};
	int ye[4] = {1,-1,0,0};
	int n = scN;
	int back_trace[100] = {};
	int now_itr = 0;
	for(int i = 0;i < scM;++i){
		if(abs(scB[0][i]) + abs(scB[1][i]) <= n){
			griding[scB[0][i]+SIZE][scB[1][i]+SIZE] = 1;
		}
	}
	for(int i = 0;i < 200;++i){
		for(int q = 0;q < 200;++q){
			badding[i][q] = abs(SIZE - i) + abs(SIZE - q);	//Do not change this,because dp part will be broken if something changed.
		}
	}
	for(int i = 0;i < 100;++i){
		back_trace[i] = -1;
	}
	griding[SIZE][SIZE] = 1;
	int now_x = SIZE;
	int now_y = SIZE;
	int ans = 0;
	while(true){
		int ok = 0;
			for(int q = back_trace[now_itr]+1;q < 4;++q){
				int go_x = now_x + xe[q];
				int go_y = now_y + ye[q];
				if(badding[go_x][go_y] <= n - now_itr - 1&&griding[go_x][go_y] == 0){
					griding[go_x][go_y] = 1;
					back_trace[now_itr] = q;
					now_x = go_x;
					now_y = go_y;
					now_itr++;
					ok = 1;
					break;
				}
			}
			if(badding[now_x][now_y] == n-now_itr){
				//dp able!
				ok = 0;
				griding[SIZE][SIZE] = 0;
				dp[1][1] = 1;
				if(now_x < SIZE&&now_y < SIZE){
					for(int i = now_x;i <= SIZE;++i){
						for(int q = now_y;q <= SIZE;++q){
							if(i != now_x||q != now_y){
								if(griding[i][q] == 1){
									dp[i-now_x+1][q-now_y+1] = 0;
								}else{
									dp[i - now_x + 1][q - now_y + 1] = dp[i-now_x][q - now_y + 1] + dp[i - now_x + 1][q - now_y];
								}
							}
						}
					}
					ans += dp[SIZE - now_x + 1][SIZE - now_y + 1];
				}else if(now_x >= SIZE&&now_y < SIZE){
					for(int i = now_x;i >= SIZE;--i){
						for(int q = now_y;q <= SIZE;++q){
							if(i != now_x||q != now_y){
								if(griding[i][q] == 1){
									dp[now_x - i + 1][q-now_y+1] = 0;
								}else{
									dp[now_x - i + 1][q - now_y + 1] = dp[now_x - i][q - now_y + 1] + dp[now_x - i + 1][q - now_y];
								}
							}
						}
					}
					ans += dp[now_x - SIZE + 1][SIZE - now_y + 1];
				}else if(now_x < SIZE&&now_y >= SIZE){
					for(int i = now_x;i <= SIZE;++i){
						for(int q = now_y;q >= SIZE;--q){
							if(i != now_x||q != now_y){
								if(griding[i][q] == 1){
									dp[i-now_x+1][now_y - q + 1] = 0;
								}else{
									dp[i - now_x + 1][now_y - q + 1] = dp[i-now_x][now_y - q + 1] + dp[i - now_x + 1][now_y - q];
								}
							}
						}
					}
					ans += dp[SIZE - now_x + 1][now_y - SIZE + 1];
				}else if(now_x >= SIZE&&now_y >= SIZE){
					for(int i = now_x;i >= SIZE;--i){
						for(int q = now_y;q >= SIZE;--q){
							if(i != now_x||q != now_y){
								if(griding[i][q] == 1){
									dp[now_x - i+1][now_y - q + 1] = 0;
								}else{
									dp[now_x - i + 1][now_y - q + 1] = dp[now_x - i][now_y - q + 1] + dp[now_x - i + 1][now_y - q];
								}
							}
						}
					}
					ans += dp[now_x - SIZE + 1][now_y - SIZE + 1];
				}
				griding[SIZE][SIZE] = 1;
			}
			if(ok == 0||(griding[SIZE-1][SIZE] == 1&&griding[SIZE+1][SIZE] == 1&&griding[SIZE][SIZE-1] == 1&&griding[SIZE][SIZE+1] == 1)){
				back_trace[now_itr] = -1;
				if(now_itr == 0){
					scOutput(ans);
					return 0;
				}
				now_itr--;
				griding[now_x][now_y] = 0;
				now_x -= xe[back_trace[now_itr]];
				now_y -= ye[back_trace[now_itr]];
			}
	}
	return 0;
}