結果

提出番号 1248
提出者 kotamanegi
言語 C++
提出日時 2018-06-20 19:46:16
問題名 (62)SuperCon2018(独自テスト)
結果 AC
点数 1128000

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 150000 160ms 8688KB
2 AC 150000 158ms 8688KB
3 AC 150000 156ms 8720KB
4 AC 170000 174ms 8400KB
5 AC 170000 175ms 7632KB
6 AC 130000 138ms 8736KB
7 AC 120000 126ms 8688KB
8 AC 170000 176ms 7824KB
9 AC 150000 160ms 8080KB
10 AC 160000 168ms 7648KB
テストケース 結果 得点 実行時間 メモリ使用量
11 AC 100000 109ms 8240KB
12 AC 170000 175ms 8048KB
13 AC 80000 92ms 8432KB
14 AC 140000 146ms 8416KB
15 AC 160000 171ms 8400KB
16 AC 170000 175ms 7536KB
17 AC 140000 147ms 8432KB
18 AC 170000 176ms 7952KB
19 AC 160000 163ms 8096KB
20 AC 120000 127ms 8032KB
テストケース 結果 得点 実行時間 メモリ使用量
21 AC 140000 147ms 8720KB
22 AC 130000 137ms 8416KB
23 AC 70000 79ms 7952KB
24 AC 110000 114ms 8336KB
25 AC 150000 157ms 7984KB
26 AC 120000 129ms 8336KB
27 AC 160000 171ms 8432KB
28 AC 120000 125ms 8160KB
29 AC 110000 116ms 8128KB
30 AC 150000 158ms 7872KB
テストケース 結果 得点 実行時間 メモリ使用量
31 AC 70000 78ms 7968KB
32 AC 160000 166ms 8384KB
33 AC 140000 153ms 8416KB
34 AC 90000 95ms 8400KB
35 AC 110000 118ms 8304KB
36 AC 130000 139ms 8256KB
37 AC 140000 146ms 8384KB
38 AC 140000 147ms 8192KB
39 AC 130000 138ms 7216KB
40 AC 150000 154ms 7808KB
テストケース 結果 得点 実行時間 メモリ使用量
41 AC 160000 173ms 8048KB
42 AC 80000 84ms 8416KB
43 AC 120000 130ms 8048KB
44 AC 100000 112ms 7632KB
45 AC 110000 114ms 8048KB
46 AC 70000 77ms 8704KB
47 AC 140000 143ms 8432KB
48 AC 110000 115ms 8048KB
49 AC 80000 89ms 8720KB
50 AC 60000 65ms 7648KB
テストケース 結果 得点 実行時間 メモリ使用量
51 AC 40000 51ms 8304KB
52 AC 140000 149ms 8192KB
53 AC 140000 154ms 8128KB
54 AC 100000 109ms 8048KB
55 AC 110000 114ms 8448KB
56 AC 120000 133ms 8112KB
57 AC 100000 112ms 7632KB
58 AC 100000 106ms 7504KB
59 AC 60000 73ms 8688KB
60 AC 130000 137ms 7824KB
テストケース 結果 得点 実行時間 メモリ使用量
61 AC 70000 76ms 8416KB
62 AC 100000 113ms 8320KB
63 AC 160000 162ms 7248KB
64 AC 80000 85ms 8336KB
65 AC 90000 96ms 8384KB
66 AC 80000 86ms 8304KB
67 AC 100000 107ms 8432KB
68 AC 60000 72ms 7824KB
69 AC 60000 64ms 7248KB
70 AC 140000 145ms 8416KB
テストケース 結果 得点 実行時間 メモリ使用量
71 AC 30000 36ms 8480KB
72 AC 150000 155ms 7632KB
73 AC 160000 163ms 7520KB
74 AC 120000 127ms 7824KB
75 AC 60000 63ms 8048KB
76 AC 50000 57ms 8416KB
77 AC 80000 90ms 8736KB
78 AC 70000 81ms 8688KB
79 AC 80000 93ms 7520KB
80 AC 120000 127ms 8640KB
テストケース 結果 得点 実行時間 メモリ使用量
81 AC 100000 104ms 7824KB
82 AC 80000 84ms 8192KB
83 AC 100000 112ms 7808KB
84 AC 80000 93ms 7200KB
85 AC 110000 121ms 8064KB
86 AC 80000 88ms 8048KB
87 AC 90000 98ms 7936KB
88 AC 100000 112ms 8416KB
89 AC 60000 68ms 8400KB
90 AC 110000 121ms 8160KB
テストケース 結果 得点 実行時間 メモリ使用量
91 AC 100000 105ms 8128KB
92 AC 90000 98ms 8400KB
93 AC 120000 128ms 8416KB
94 AC 80000 85ms 8064KB
95 AC 70000 74ms 8144KB
96 AC 170000 175ms 8128KB
97 AC 100000 108ms 7632KB
98 AC 40000 43ms 7952KB
99 AC 150000 159ms 7824KB
100 AC 100000 103ms 7904KB

ソースコード

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