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
53f063b7
Commit
53f063b7
authored
Jul 09, 2018
by
royus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
halfway done (need func connectable and actuallyconnect)
parent
96cd20b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
162 additions
and
0 deletions
+162
-0
solver.c
source/solver.c
+162
-0
No files found.
source/solver.c
0 → 100644
View file @
53f063b7
/* solver.c */
/* Last Change: 2018/07/09 (Mon) 15:54:41. */
#include<stdio.h>
/* #include<stdlib.h> */
#include<string.h>
/* #include<limits.h> */
/* #include<math.h> */
/* #include<time.h> */
int
board
[
8
][
72
][
72
];
int
depth
,
height
,
width
;
int
lines
;
//z,y,x
void
reset
(
void
){
int
i
,
j
,
k
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
j
=
0
;
j
<
height
;
j
++
)
for
(
k
=
0
;
k
<
width
;
k
++
)
board
[
i
][
j
][
k
]
=
0
;
return
;
}
void
read
(
void
){
int
x
,
y
,
z
,
i
;
char
c
,
str
[
8
];
scanf
(
" %s"
,
str
);
//SIZE
scanf
(
" %d"
,
&
width
);
if
(
width
>
72
||
width
<=
0
)
printf
(
"Error: width
\n
"
);
scanf
(
" %c"
,
&
c
);
//X
scanf
(
" %d"
,
&
height
);
if
(
height
>
72
||
height
<=
0
)
printf
(
"Error: height
\n
"
);
scanf
(
" %c"
,
&
c
);
//X
scanf
(
" %d"
,
&
depth
);
if
(
depth
>
8
||
depth
<=
0
)
printf
(
"Error: depth
\n
"
);
scanf
(
" %s"
,
str
);
//LINE_NUM
scanf
(
" %d"
,
&
lines
);
if
(
lines
<=
0
)
printf
(
"Error: lines
\n
"
);
for
(
i
=
1
;
i
<=
lines
;
i
++
){
scanf
(
" %s"
,
str
);
//LINE#X
scanf
(
" %c"
,
&
c
);
//(
scanf
(
" %d"
,
&
x
);
if
(
x
>=
72
||
x
<
0
)
printf
(
"Error: x
\n
"
);
scanf
(
" %c"
,
&
c
);
//,
scanf
(
" %d"
,
&
y
);
if
(
y
>=
72
||
y
<
0
)
printf
(
"Error: y
\n
"
);
scanf
(
" %c"
,
&
c
);
//,
scanf
(
" %d"
,
&
z
);
if
(
z
>=
72
||
z
<
0
)
printf
(
"Error: z
\n
"
);
scanf
(
" %c"
,
&
c
);
//)
board
[
z
-
1
][
y
][
x
]
=-
i
;
scanf
(
"%c"
,
&
c
);
//)
/* scanf(" %[ -]",&c); //space or - */
scanf
(
" %c"
,
&
c
);
//(
scanf
(
" %d"
,
&
x
);
if
(
x
>=
72
||
x
<
0
)
printf
(
"Error: x
\n
"
);
scanf
(
" %c"
,
&
c
);
//,
scanf
(
" %d"
,
&
y
);
if
(
y
>=
72
||
y
<
0
)
printf
(
"Error: y
\n
"
);
scanf
(
" %c"
,
&
c
);
//,
scanf
(
" %d"
,
&
z
);
if
(
z
>=
72
||
z
<
0
)
printf
(
"Error: z
\n
"
);
scanf
(
" %c"
,
&
c
);
//)
board
[
z
-
1
][
y
][
x
]
=-
i
;
}
return
;
}
int
order
(
int
num
){
//1-lines -> 1-lines
return
num
;
}
int
connected
(
int
line
){
int
i
,
j
,
k
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
j
=
0
;
j
<
height
;
j
++
)
for
(
k
=
0
;
k
<
width
;
k
++
)
if
(
board
[
i
][
j
][
k
]
==
line
)
return
1
;
return
0
;
}
int
connectable
(
int
linea
,
int
lineb
){
//REQUIRED
return
0
;
}
void
actuallyconnect
(
int
num
){
//REQUIRED
return
;
}
void
delete
(
int
line
){
int
i
,
j
,
k
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
j
=
0
;
j
<
height
;
j
++
)
for
(
k
=
0
;
k
<
width
;
k
++
)
if
(
board
[
i
][
j
][
k
]
==
line
)
board
[
i
][
j
][
k
]
=
0
;
return
;
}
void
connect
(
int
num
){
int
i
;
if
(
connectable
(
order
(
num
),
0
))
actuallyconnect
(
order
(
num
));
else
for
(
i
=
num
-
1
;
i
>=
1
;
i
--
)
if
(
connectable
(
order
(
num
),
order
(
i
))){
delete
(
order
(
i
));
actuallyconnect
(
order
(
num
));
connect
(
i
);
}
return
;
}
void
solve
(
void
){
int
i
;
for
(
i
=
1
;
i
<=
lines
;
i
++
)
connect
(
i
);
return
;
}
void
write
(
void
){
int
i
,
j
,
k
;
printf
(
"SIZE %dX%dX%d
\n
"
,
width
,
height
,
depth
);
for
(
k
=
0
;
k
<
depth
;
k
++
){
printf
(
"LAYER %d
\n
"
,
k
+
1
);
for
(
j
=
0
;
j
<
height
;
j
++
){
for
(
i
=
0
;
i
<
width
-
1
;
i
++
){
if
(
board
[
k
][
j
][
i
]
<
0
)
board
[
k
][
j
][
i
]
=-
board
[
k
][
j
][
i
];
printf
(
"%d,"
,
board
[
k
][
j
][
i
]);
}
if
(
board
[
k
][
j
][
i
]
<
0
)
board
[
k
][
j
][
i
]
=-
board
[
k
][
j
][
i
];
printf
(
"%d"
,
board
[
k
][
j
][
i
]);
printf
(
"
\n
"
);
}
}
return
;
}
int
main
(
void
){
reset
();
read
();
solve
();
write
();
return
0
;
}
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