Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nszw-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
nszw-solver
Commits
ad6fb437
Commit
ad6fb437
authored
Jul 24, 2019
by
makoto.nishizawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made grid
parent
d0218176
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
55 deletions
+74
-55
main.cpp
main.cpp
+2
-2
solve
solve
+0
-0
solver.cpp
solver.cpp
+72
-53
No files found.
main.cpp
View file @
ad6fb437
...
...
@@ -5,8 +5,8 @@
int
main
(
void
){
read_problem
();
H
=
2
0
;
W
=
2
0
;
H
=
4
0
;
W
=
4
0
;
solver
();
print_answer
();
...
...
solve
View file @
ad6fb437
No preview for this file type
solver.cpp
View file @
ad6fb437
...
...
@@ -109,10 +109,10 @@ void del_mino(int mino){
int
check_put_mino
(
int
i
,
int
x
,
int
y
){
// check block#i can put on x,y
for
(
int
j
=
1
;
j
<
5
;
j
++
){
if
(
x
+
block_data
[
i
][
j
][
0
]
>
19
){
if
(
x
+
block_data
[
i
][
j
][
0
]
>
W
-
1
){
return
0
;
}
if
(
y
+
block_data
[
i
][
j
][
1
]
>
19
){
if
(
y
+
block_data
[
i
][
j
][
1
]
>
H
-
1
){
return
0
;
}
if
(
board_data
[
x
+
block_data
[
i
][
j
][
0
]][
y
+
block_data
[
i
][
j
][
1
]]
!=
0
){
...
...
@@ -127,7 +127,7 @@ int check_put_mino(int i,int x, int y){// check block#i can put on x,y
void
data_mino
(
int
i
,
int
x
,
int
y
){
std
::
cout
<<
"put mino "
<<
i
<<
std
::
endl
;
std
::
cout
<<
"put mino "
<<
i
<<
"on"
<<
x
<<
" "
<<
y
<<
std
::
endl
;
for
(
int
j
=
0
;
j
<
100
;
j
++
){
if
(
check_put_mino
(
i
,
x
,
y
)){
for
(
int
l
=
1
;
l
<
5
;
l
++
){
...
...
@@ -167,22 +167,38 @@ void put_mino(){
int
index
=
0
;
int
next
=
0
;
int
x
=
0
;
int
another
=
0
;
auto
itr
=
order_w
.
begin
();
while
(
true
){
another
=
0
;
for
(
index
=
order_w
.
size
()
-
1
;
index
>=
0
;
index
--
){
// find next block
if
(
done_block
[
order_w
[
index
]]
==
0
){
next
=
order_w
[
index
];
another
=
1
;
//done_block[next]=1;
//check_block[next]=1;
break
;
}
}
if
(
index
==-
1
){
for
(
index
=
blocks
;
index
>
0
;
index
--
){
if
(
done_block
[
index
]
==
0
){
next
=
index
;
break
;
}
}
if
(
index
==
0
)
break
;
// if all blocks are searched
}
if
(
index
==-
1
)
break
;
// if all blocks are searched
itr
=
order_w
.
begin
();
for
(
int
i
=
0
;
i
<
index
;
i
++
){
//remove index itretor
itr
++
;
if
(
another
){
itr
=
order_w
.
begin
();
for
(
int
i
=
0
;
i
<
index
;
i
++
){
//remove index itretor
itr
++
;
}
order_w
.
erase
(
itr
);
}
else
{
itr
=
order_w
.
end
();
}
order_w
.
erase
(
itr
);
std
::
cout
<<
"block#"
<<
next
<<
std
::
endl
;
//make block order
if
(
block_data
[
next
][
1
][
0
]
==
block_data
[
next
][
2
][
0
]){
...
...
@@ -290,20 +306,36 @@ void put_mino(){
next
=
0
;
itr
=
order_h
.
begin
();
order_h
.
push_back
(
1
);
another
=
0
;
while
(
true
){
//start of while true for height
another
=
0
;
for
(
index
=
order_h
.
size
()
-
1
;
index
>=
0
;
index
--
){
// find next block
if
(
done_block
[
order_h
[
index
]]
==
0
){
next
=
order_h
[
index
];
another
=
1
;
break
;
}
}
if
(
index
==-
1
){
std
::
cout
<<
"left block search"
<<
std
::
endl
;
for
(
index
=
blocks
;
index
>
0
;
index
--
){
if
(
done_block
[
index
]
==
0
){
next
=
index
;
break
;
}
}
if
(
index
==
0
)
break
;
// if all blocks are searched
}
//std::cout << "now" << std::endl;
if
(
index
==-
1
)
break
;
// if all blocks are searched
itr
=
order_h
.
begin
();
for
(
int
i
=
0
;
i
<
index
;
i
++
){
//remove index itretor
itr
++
;
if
(
another
==
1
){
itr
=
order_h
.
begin
();
for
(
int
i
=
0
;
i
<
index
;
i
++
){
//remove index itretor
itr
++
;
}
order_h
.
erase
(
itr
);
}
else
{
itr
=
order_h
.
end
();
}
order_h
.
erase
(
itr
);
std
::
cout
<<
"block#"
<<
next
<<
std
::
endl
;
for
(
int
k
=
1
;
k
<=
4
;
k
++
){
std
::
cout
<<
block_data
[
next
][
k
][
0
];
...
...
@@ -412,47 +444,34 @@ void put_mino(){
printf
(
"
\n
"
);
int
put_block
[
100
];
int
h
ight_c
=
1
,
width_c
=
1
;
int
h
eight_c
=
0
,
width_c
=
1
;
int
next_put
=
1
;
int
max_w
=
0
;
int
max_h
=
0
;
for
(
int
i
=
0
;
i
<
blocks
;
i
++
){
h
ight_c
=
1
;
width_c
=
1
;
if
(
i
%
2
){
for
(
int
j
=
0
;
j
<
blocks
;
j
++
){
if
(
put_block
[
order_w
[
j
]]
==
0
){
next_put
=
order_w
[
j
];
break
;
}
width_c
++
;
h
eight_c
=
height_c
+
SPACE
;
width_c
=
SPACE
;
max_w
=
0
;
max_h
=
0
;
next_put
=
order_h
[
i
];
for
(
int
j
=
0
;
j
<
blocks
;
j
++
){
if
(
order_w
[
j
]
==
next_put
)
break
;
for
(
k
=
1
;
k
<
5
;
k
++
){
if
(
block_data
[
order_w
[
j
]][
k
][
0
]
>
max_w
)
max_w
=
block_data
[
order_w
[
j
]][
k
][
0
];
}
for
(
int
j
=
0
;
j
<
blocks
;
j
++
){
if
(
order_h
[
j
]
==
next_put
){
break
;
}
hight_c
++
;
}
data_mino
(
next_put
,
width_c
,
hight_c
);
mino_order
.
push_back
(
next_put
);
}
else
{
for
(
int
j
=
0
;
j
<
blocks
;
j
++
){
if
(
put_block
[
order_h
[
j
]]
==
0
){
next_put
=
order_h
[
j
];
break
;
}
hight_c
++
;
}
for
(
int
j
=
0
;
j
<
blocks
;
j
++
){
if
(
order_w
[
j
]
==
next_put
){
break
;
}
width_c
++
;
}
data_mino
(
next_put
,
width_c
,
hight_c
);
mino_order
.
push_back
(
next_put
);
//std::cout<< "add " << order_w[j] << " mino " << max_w << std::endl;
width_c
+=
max_w
+
SPACE
;
}
//std::cout << width_c << std::endl;
//std::cout << height_c << std::endl;
if
(
max_w
==
0
)
data_mino
(
next_put
,
width_c
,
height_c
);
else
data_mino
(
next_put
,
width_c
+
SPACE
,
height_c
);
for
(
int
k
=
1
;
k
<
5
;
k
++
){
if
(
block_data
[
next_put
][
k
][
1
]
>
max_h
)
max_h
=
block_data
[
next_put
][
k
][
1
];
}
put_block
[
next_put
]
=
1
;
print_answer
();
height_c
+=
max_h
+
1
;
}
print_answer
();
//int next;
int
mino_x
,
mino_y
;
/*for(int i=0;i<blocks;i++){
...
...
@@ -485,7 +504,7 @@ void make_board_str(int size_x,int size_y){
for
(
int
y
=
0
;
y
<
size_y
;
y
++
)
{
for
(
int
x
=
0
;
x
<
size_x
;
x
++
)
{
int
idx
=
y
*
size_x
+
x
;
board_str
[
idx
]
=
board_data
[
y
][
x
];
board_str
[
idx
]
=
board_data
[
x
][
y
];
}
}
}
...
...
@@ -493,22 +512,22 @@ void fix_to_board(int size_x, int size_y){
for
(
int
y
=
0
;
y
<
size_y
;
y
++
)
{
for
(
int
x
=
0
;
x
<
size_x
;
x
++
)
{
int
idx
=
y
*
size_x
+
x
;
board_data
[
y
][
x
]
=
board_str
[
idx
];
board_data
[
x
][
y
]
=
board_str
[
idx
];
}
}
}
void
line
(){
make_board_str
(
20
,
20
);
make_board_str
(
W
,
H
);
std
::
cout
<<
lfsr
<<
std
::
endl
;
int
status
=
router
(
20
,
20
,
line_num
,
board_str
);
int
status
=
router
(
W
,
H
,
line_num
,
board_str
);
if
(
status
){
std
::
cout
<<
"success to line"
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"failed to line"
<<
std
::
endl
;
}
fix_to_board
(
20
,
20
);
fix_to_board
(
W
,
H
);
}
void
solve
(
void
){
...
...
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