Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dsprog
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Manuel Bucher
dsprog
Commits
f867228e
There was an error fetching the commit references. Please try again later.
Commit
f867228e
authored
6 years ago
by
Manuel Bucher
Browse files
Options
Downloads
Patches
Plain Diff
fixed oben/unten-Beziehung von Nachbarberechnung
parent
9c683cb2
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loesung2.c
+22
-10
22 additions, 10 deletions
loesung2.c
with
22 additions
and
10 deletions
loesung2.c
+
22
−
10
View file @
f867228e
...
...
@@ -178,25 +178,29 @@ int field_neighbours(Field *this) {
uint32_t
begin_line
=
1
;
// start der aktuellen Zeile
Tile
*
t
=
this
->
tiles
;
for
(
uint32_t
cur
=
2
;
cur
<
this
->
num_tiles
;
cur
++
)
{
// ermitteln der
ost/west
-Beziehung
// ermitteln der
x
-Beziehung
uint32_t
east
=
cur
-
1
;
if
(
t
[
cur
].
x
==
t
[
east
].
x
)
{
if
(
t
[
cur
].
y
==
t
[
east
].
y
)
{
if
(
t
[
cur
].
x
==
t
[
east
].
x
)
{
// gleiche Zeile
if
(
t
[
cur
].
y
==
t
[
east
].
y
)
{
// gleiche Spalte
return
1
;
// Doppelung
}
else
if
(
t
[
cur
].
y
-
1
==
t
[
east
].
y
)
{
t
[
cur
].
neigh
[
1
]
=
east
;
t
[
east
].
neigh
[
3
]
=
cur
;
}
}
else
{
top
=
begin_line
;
begin_line
=
cur
;
// neue Zeile
}
// ermitteln der
nord/sued
-Beziehung
if
(
t
[
top
].
x
<
t
[
cur
].
x
-
1
)
{
top
=
begin_line
;
// Luecke zwisch
en
z
eilen
// ermitteln der
Zeilen
-Beziehung
if
(
t
[
begin_line
].
x
!=
0
&&
t
[
top
].
x
<
t
[
begin_line
].
x
-
1
)
{
// Zeilensprung => Warten bis zur naechst
en
Z
eile
angekomme
n
}
else
if
(
t
[
top
].
x
==
t
[
cur
].
x
-
1
)
{
// finden, ob paar nach oben existiert O(n) fuer alle Nachbarn nach oben/unten.
for
(;
t
[
top
].
y
<
t
[
cur
].
y
&&
top
<
begin_line
;
top
++
);
if
(
t
[
top
].
y
==
t
[
cur
].
y
)
{
// aktuelle obere Kachel koennte benachbart sein
if
(
t
[
top
].
y
==
t
[
cur
].
y
)
{
// nicht auf naechste Zeile uebergegangen
// Neue Verbindung oben/unten gefunden
t
[
top
].
neigh
[
2
]
=
cur
;
t
[
cur
].
neigh
[
0
]
=
top
;
}
...
...
@@ -207,8 +211,16 @@ int field_neighbours(Field *this) {
void
field_print
(
Field
*
this
)
{
printf
(
"[
\n
"
);
Tile
*
t
=
this
->
tiles
;
for
(
uint32_t
i
=
1
;
i
<
this
->
num_tiles
;
i
++
){
printf
(
"
\t
(%u %u)
\n
"
,
this
->
tiles
[
i
].
x
,
this
->
tiles
[
i
].
y
);
printf
(
"
\t
(%u %u): {"
,
t
[
i
].
x
,
this
->
tiles
[
i
].
y
);
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
if
(
t
[
i
].
neigh
[
j
]
!=
0
)
{
Tile
*
neigh
=
&
t
[
t
[
i
].
neigh
[
j
]];
printf
(
" (%u %u)"
,
neigh
->
x
,
neigh
->
y
);
}
}
printf
(
" }
\n
"
);
}
printf
(
"]
\n
"
);
}
...
...
@@ -348,9 +360,9 @@ int main() {
fprintf
(
stderr
,
"Error: Duplicated entry
\n
"
);
// Duplikat exisitert
break
;
}
/*
if (f.num_tiles - f.num_odd == f.num_odd) {
if
(
f
.
num_tiles
-
f
.
num_odd
==
f
.
num_odd
)
{
printf
(
"None
\n
"
);
}
*/
}
hk
(
&
f
);
// Algorithmus von Hopcroft und Karp
result
=
EXIT_SUCCESS
;
break
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment