Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
c6c67e0a
Commit
c6c67e0a
authored
Aug 27, 2018
by
royus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not done
parent
56a93b0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
solver.c
source/solver.c
+22
-9
No files found.
source/solver.c
View file @
c6c67e0a
/* solver.c */
/* solver.c */
/* Last Change: 2018/08/27 (Mon) 23:
01:56
. */
/* Last Change: 2018/08/27 (Mon) 23:
42:09
. */
#define MAX_ATTEMPS 10000
#define MAX_ATTEMPS 10000
...
@@ -19,6 +19,8 @@ int lines;
...
@@ -19,6 +19,8 @@ int lines;
int
dx
[
6
]
=
{
-
1
,
0
,
0
,
1
,
0
,
0
};
int
dx
[
6
]
=
{
-
1
,
0
,
0
,
1
,
0
,
0
};
int
dy
[
6
]
=
{
0
,
-
1
,
0
,
0
,
1
,
0
};
int
dy
[
6
]
=
{
0
,
-
1
,
0
,
0
,
1
,
0
};
int
dz
[
6
]
=
{
0
,
0
,
-
1
,
0
,
0
,
1
};
int
dz
[
6
]
=
{
0
,
0
,
-
1
,
0
,
0
,
1
};
int
history
[
8
*
72
*
72
];
int
searchorder
[
6
];
//x+-,y+-,z+-
//z,y,x
//z,y,x
void
read
(
void
){
//read problem
void
read
(
void
){
//read problem
...
@@ -77,12 +79,14 @@ void read(void){ //read problem
...
@@ -77,12 +79,14 @@ void read(void){ //read problem
}
}
int
available
(
int
z
,
int
y
,
int
x
){
//return 1 when (nowx,nowy,nowz) can be connected to goal
int
available
(
int
z
,
int
y
,
int
x
){
//return 1 when (nowx,nowy,nowz) can be connected to goal
int
i
,
src
=
0
,
contd
,
isbranch
;
int
i
,
j
,
t
,
src
=
0
,
contd
,
isbranch
;
int
history
[
8
*
72
*
72
],
index
=
0
;
int
index
=
0
;
int
nowx
=
x
,
nowy
=
y
,
nowz
=
z
;
int
nowx
=
x
,
nowy
=
y
,
nowz
=
z
;
int
searchorder
[
6
];
//x+-,y+-,z+-
/* for(i=0;i<6;i++) */
/* for(i=0;i<6;i++) */
/* printf("%d %d %d\n",dx[i],dy[i],dz[i]); */
/* printf("%d %d %d\n",dx[i],dy[i],dz[i]); */
for
(
i
=
0
;
i
<
8
*
72
*
72
;
i
++
)
history
[
i
]
=-
1
;
index
=
0
;
while
(
1
){
while
(
1
){
/* printf("%d %d %d\n",nowx,nowy,nowz); */
/* printf("%d %d %d\n",nowx,nowy,nowz); */
if
(
nowx
<
0
||
nowy
<
0
||
nowz
<
0
||
nowx
>=
width
||
nowy
>=
height
||
nowz
>=
depth
){
if
(
nowx
<
0
||
nowy
<
0
||
nowz
<
0
||
nowx
>=
width
||
nowy
>=
height
||
nowz
>=
depth
){
...
@@ -111,13 +115,17 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
...
@@ -111,13 +115,17 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
avail
[
nowz
][
nowy
][
nowx
]
=
0
;
avail
[
nowz
][
nowy
][
nowx
]
=
0
;
index
--
;
index
--
;
if
(
nowx
-
dx
[
history
[
index
]]
<
0
||
nowy
-
dy
[
history
[
index
]]
<
0
||
nowz
-
dx
[
history
[
index
]]
<
0
||
nowx
-
dz
[
history
[
index
]]
>=
width
||
nowy
-
dy
[
history
[
index
]]
>=
height
||
nowz
-
dz
[
history
[
index
]]
>=
depth
){
if
(
nowx
-
dx
[
history
[
index
]]
<
0
||
nowy
-
dy
[
history
[
index
]]
<
0
||
nowz
-
dx
[
history
[
index
]]
<
0
||
nowx
-
dz
[
history
[
index
]]
>=
width
||
nowy
-
dy
[
history
[
index
]]
>=
height
||
nowz
-
dz
[
history
[
index
]]
>=
depth
){
index
++
;
/* printf("something wrong\n"); */
/* printf("something wrong\n"); */
}
else
{
}
else
{
nowx
-=
dx
[
history
[
index
]];
nowx
-=
dx
[
history
[
index
]];
nowy
-=
dy
[
history
[
index
]];
nowy
-=
dy
[
history
[
index
]];
nowz
-=
dz
[
history
[
index
]];
nowz
-=
dz
[
history
[
index
]];
avail
[
nowz
][
nowy
][
nowx
]
=
1
;
avail
[
nowz
][
nowy
][
nowx
]
=
1
;
printf
(
"%d %d %d -
\n
"
,
nowx
,
nowy
,
nowz
);
/* printf("%d %d %d -%d %d\n",nowx,nowy,nowz,history[index],index); */
/* for(j=0;j<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
/* return 0;//goback */
/* return 0;//goback */
continue
;
continue
;
}
}
...
@@ -154,7 +162,6 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
...
@@ -154,7 +162,6 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
src
++
;
src
++
;
}
else
}
else
searchorder
[
src
]
=
5
;
searchorder
[
src
]
=
5
;
int
j
,
t
;
for
(
i
=
0
;
i
<
src
;
i
++
){
for
(
i
=
0
;
i
<
src
;
i
++
){
j
=
rand
()
%
(
src
);
j
=
rand
()
%
(
src
);
t
=
searchorder
[
i
];
t
=
searchorder
[
i
];
...
@@ -178,9 +185,11 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
...
@@ -178,9 +185,11 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
nowy
+=
dy
[
searchorder
[
i
]];
nowy
+=
dy
[
searchorder
[
i
]];
nowz
+=
dz
[
searchorder
[
i
]];
nowz
+=
dz
[
searchorder
[
i
]];
/* printf("%d %d %d\n",dx[searchorder[i]],dy[searchorder[i]],dz[searchorder[i]]); */
/* printf("%d %d %d\n",dx[searchorder[i]],dy[searchorder[i]],dz[searchorder[i]]); */
printf
(
"%d %d %d +
\n
"
,
nowx
,
nowy
,
nowz
);
history
[
index
]
=
searchorder
[
i
];
history
[
index
]
=
searchorder
[
i
];
/* printf("%d\n",index); */
/* printf("%d %d %d +%d %d\n",nowx,nowy,nowz,searchorder[i],index+1); */
/* for(j=0;j<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
index
++
;
index
++
;
}
}
}
}
...
@@ -190,13 +199,17 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
...
@@ -190,13 +199,17 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
avail
[
nowz
][
nowy
][
nowx
]
=
0
;
avail
[
nowz
][
nowy
][
nowx
]
=
0
;
index
--
;
index
--
;
if
(
nowx
-
dx
[
history
[
index
]]
<
0
||
nowy
-
dy
[
history
[
index
]]
<
0
||
nowz
-
dx
[
history
[
index
]]
<
0
||
nowx
-
dz
[
history
[
index
]]
>=
width
||
nowy
-
dy
[
history
[
index
]]
>=
height
||
nowz
-
dz
[
history
[
index
]]
>=
depth
){
if
(
nowx
-
dx
[
history
[
index
]]
<
0
||
nowy
-
dy
[
history
[
index
]]
<
0
||
nowz
-
dx
[
history
[
index
]]
<
0
||
nowx
-
dz
[
history
[
index
]]
>=
width
||
nowy
-
dy
[
history
[
index
]]
>=
height
||
nowz
-
dz
[
history
[
index
]]
>=
depth
){
index
++
;
/* printf("something wrong\n"); */
/* printf("something wrong\n"); */
}
else
{
}
else
{
nowx
-=
dx
[
history
[
index
]];
nowx
-=
dx
[
history
[
index
]];
nowy
-=
dy
[
history
[
index
]];
nowy
-=
dy
[
history
[
index
]];
nowz
-=
dz
[
history
[
index
]];
nowz
-=
dz
[
history
[
index
]];
avail
[
nowz
][
nowy
][
nowx
]
=
1
;
avail
[
nowz
][
nowy
][
nowx
]
=
1
;
printf
(
"%d %d %d -
\n
"
,
nowx
,
nowy
,
nowz
);
/* printf("%d %d %d -%d %d\n",nowx,nowy,nowz,history[index],index); */
/* for(j=0;j<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
/* printf("%d %d %d\n",dx[history[index]],dy[history[index]],dz[history[index]]); */
/* printf("%d %d %d\n",dx[history[index]],dy[history[index]],dz[history[index]]); */
continue
;
continue
;
}
}
...
...
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