Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
solver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
adc2019
solver
Commits
32bc68e1
Commit
32bc68e1
authored
May 25, 2019
by
royus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
255f6279
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
31 deletions
+73
-31
a.out
a.out
+0
-0
io.c
io.c
+5
-19
io.h
io.h
+2
-6
main.c
main.c
+3
-3
solver.c
solver.c
+63
-3
No files found.
a.out
0 → 100755
View file @
32bc68e1
File added
io.c
View file @
32bc68e1
/* io.c */
/* Last Change: 2019/05/2
1 (Tue) 13:57:18
. */
/* Last Change: 2019/05/2
5 (Sat) 18:11:46
. */
#include<stdio.h>
#include<limits.h>
#include"io.h"
short
int
W
=
MAXW
,
H
=
MAXH
;
// (問題で設定された) 盤面サイズ上限
...
...
@@ -17,8 +16,8 @@ void reset_parameters(void){
for
(
j
=
0
;
j
<
5
;
j
++
)
for
(
k
=
0
;
k
<
3
;
k
++
)
block_data
[
i
][
j
][
k
]
=-
1
;
for
(
i
=
0
;
i
<
72
;
i
++
)
for
(
j
=
0
;
j
<
72
;
j
++
)
for
(
i
=
0
;
i
<
MAXW
;
i
++
)
for
(
j
=
0
;
j
<
MAXH
;
j
++
)
board_data
[
i
][
j
]
=
0
;
return
;
}
...
...
@@ -31,11 +30,11 @@ void read_problem(void){
char
c
,
str
[
32
];
// must be 20 or more
scanf
(
" %s"
,
str
);
//SIZE
scanf
(
" %hd"
,
&
W
);
if
(
W
>
72
||
W
<=
0
)
if
(
W
>
MAXW
||
W
<=
0
)
printf
(
"Error: width
\n
"
);
scanf
(
" %c"
,
&
c
);
//X
scanf
(
" %hd"
,
&
H
);
if
(
H
>
72
||
H
<=
0
)
if
(
H
>
MAXH
||
H
<=
0
)
printf
(
"Error: height
\n
"
);
scanf
(
" %s"
,
str
);
//BLOCK_NUM
scanf
(
" %hd"
,
&
blocks
);
...
...
@@ -92,19 +91,6 @@ void read_problem(void){
return
;
}
void
convert_answer
(
void
){
int
i
,
j
;
for
(
i
=
0
;
i
<
w
;
i
++
){
for
(
j
=
0
;
j
<
h
;
j
++
){
if
(
board_data
[
i
][
j
]
==
SHRT_MIN
)
board_data
[
i
][
j
]
=
0
;
else
if
(
board_data
[
i
][
j
]
<
0
)
board_data
[
i
][
j
]
=-
board_data
[
i
][
j
];
}
}
return
;
}
void
print_answer
(
void
){
printf
(
"
\n
--ANSWER--
\n
"
);
//comment out this row
int
i
,
j
;
...
...
io.h
View file @
32bc68e1
/* io.h */
/* Last Change: 2019/05/21 (Tue) 14:
01:43
. */
/* Last Change: 2019/05/21 (Tue) 14:
56:05
. */
#ifndef _IO_H_
#define _IO_H_
...
...
@@ -24,19 +24,15 @@ short int block_data[MAXBLOCK+1][5][3]; // ブロックの情報
// block_data[block#][1~4][1] マスの,左上マスからの相対位置 y方向
// block_data[block#][1~4][2] マスの端点情報 (数字がなければ0,モノミノで存在しない場合は-1)
short
int
board_data
[
72
][
72
];
// 盤面情報
short
int
board_data
[
MAXW
][
MAXH
];
// 盤面情報
// board_data[x][y] が (x,y) の盤面情報を表わす
// (0,0),(1,0),(2,0), ... ,(71,0)
// ...
// (0,71),(1,71), ... ,(71,71)
// 基本的には回答フォーマットに沿う形
// 負の数はconvert_answerでSHRT_MIN->0,その他は自然数に変換される
// (アルゴリズム的に必要であれば使ってください)
// (私は壁(端点ではないマス)をSHRT_MINで,配線を負の数で実装してます)
void
reset_parameters
(
void
);
// read_problem に内包
void
read_problem
(
void
);
void
convert_answer
(
void
);
void
print_answer
(
void
);
#endif // _IO_H_
main.c
View file @
32bc68e1
/* main.c */
/* Last Change: 2019/05/21 (Tue) 14:
03:16
. */
/* Last Change: 2019/05/21 (Tue) 14:
44:03
. */
#include"io.h"
#include"solver.h"
int
main
(
void
){
read_problem
();
// solver();
convert_answer
();
solver
();
print_answer
();
return
0
;
...
...
solver.c
View file @
32bc68e1
/* solver.c */
/* Last Change: 2019/05/21 (Tue) 1
4:03:02
. */
/* Last Change: 2019/05/21 (Tue) 1
8:09:17
. */
#include<stdio.h>
#include<limits.h>
#include"solver.h"
#include"io.h"
/* #include<stdio.h> */
/* #include<stdlib.h> */
/* #include<string.h> */
/* #include<limits.h> */
/* #include<math.h> */
/* #include<time.h> */
short
int
connected
[
MAXLINE
]
=
{
0
};
//if line connected:2, if one end:1, otherwize:0
short
int
board_beta
[
MAXSIZE
][
MAXSIZE
];
//big board data
//edge:1~MAXLINE, line:-1~-MAXLINE, none:0, wall:SHRT_MIN
short
int
rank
[
MAXBLOCK
+
1
];
void
reset_board
(
void
){
int
i
,
j
;
for
(
i
=
0
;
i
<
MAXSIZE
;
i
++
)
for
(
j
=
0
;
j
<
MAXSIZE
;
j
++
)
board_beta
[
i
][
j
]
=
0
;
return
;
}
void
read_data
(
void
){
return
;
}
void
translate
(
void
){
int
i
,
j
;
int
minw
=
MAXSIZE
-
1
,
maxw
=
0
,
minh
=
MAXSIZE
-
1
,
maxh
=
0
;
for
(
i
=
0
;
i
<
MAXSIZE
;
i
++
){
for
(
j
=
0
;
j
<
MAXSIZE
;
j
++
){
if
(
board_beta
[
i
][
j
]){
if
(
i
>
maxw
)
maxw
=
i
;
if
(
i
<
minw
)
minw
=
i
;
if
(
j
>
maxh
)
maxh
=
j
;
if
(
j
<
minh
)
minh
=
j
;
if
(
board_beta
[
i
][
j
]
==
SHRT_MIN
)
board_beta
[
i
][
j
]
=
0
;
else
if
(
board_beta
[
i
][
j
]
<
0
)
board_beta
[
i
][
j
]
=-
board_beta
[
i
][
j
];
}
}
}
for
(
i
=
1
;
i
<=
blocks
;
i
++
){
/* block_data[i][0]-=minw; */
/* block_data[i][1]-=minh; */
}
for
(
i
=
0
;
i
<
maxw
-
minw
;
i
++
){
for
(
j
=
0
;
j
<
maxh
-
minh
;
j
++
){
board_data
[
i
][
j
]
=
board_beta
[
i
+
minw
][
j
+
minh
];
}
}
return
;
}
void
solve
(
void
){
return
;
}
void
solver
(
void
){
read_data
();
solve
();
/* shape(); */
translate
();
return
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment