Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Advent of Code 2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Regler
Advent of Code 2024
Commits
e782c502
Commit
e782c502
authored
5 months ago
by
Max Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
day 23 max n
parent
7188ab35
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
day 023/day_23_max_n.cpp
+100
-0
100 additions, 0 deletions
day 023/day_23_max_n.cpp
with
100 additions
and
0 deletions
day 023/day_23_max_n.cpp
0 → 100644
+
100
−
0
View file @
e782c502
#include
<bits/stdc++.h>
#ifdef LOCAL
#include
"./cpp-dump/cpp-dump.hpp"
#define pr(x) cpp_dump(x)
#endif
using
namespace
std
;
#define Mod(x,y) (((x)%(y)+(y))%(y))
#define rep(i, a, b) for(ll (i) = (a); (i) < (b); ++(i))
#define all(x) begin(x), end(x)
#define pb push_back
#define gcd __gcd
#define sz(x) (ll)(x.size())
typedef
long
long
ll
;
typedef
unsigned
long
long
ull
;
typedef
pair
<
ll
,
ll
>
pii
;
typedef
vector
<
ll
>
vi
;
typedef
vector
<
pii
>
vii
;
const
bool
debug
=
false
;
set
<
string
>
alls
;
vector
<
string
>
alls_vector
;
map
<
string
,
set
<
string
>>
mp
;
set
<
vector
<
string
>>
st
;
set
<
string
>
cur
;
set
<
string
>
join_to_cur
(
int
i
)
{
if
(
i
==
alls_vector
.
size
())
{
return
cur
;
}
set
<
string
>
cur_res
=
join_to_cur
(
i
+
1
);
string
s
=
alls_vector
[
i
];
for
(
string
t
:
cur
)
if
(
mp
[
s
].
count
(
t
)
==
0
)
{
return
cur_res
;
}
cur
.
insert
(
s
);
set
<
string
>
cur_res2
=
join_to_cur
(
i
+
1
);
if
(
sz
(
cur_res2
)
>
sz
(
cur_res
))
{
cur_res
=
cur_res2
;
}
cur
.
erase
(
s
);
return
cur_res
;
}
void
solve
()
{
string
s1
,
s2
,
s3
;
while
(
cin
>>
s1
>>
s2
)
{
alls
.
insert
(
s1
);
alls
.
insert
(
s2
);
mp
[
s1
].
insert
(
s2
);
mp
[
s2
].
insert
(
s1
);
}
for
(
string
s
:
alls
)
alls_vector
.
pb
(
s
);
ll
ans
=
0
;
for
(
auto
s1
:
alls_vector
)
{
for
(
auto
s2
:
mp
[
s1
])
{
for
(
auto
s3
:
mp
[
s2
])
{
if
(
mp
[
s1
].
count
(
s3
))
{
vector
<
string
>
res
=
{
s1
,
s2
,
s3
};
sort
(
all
(
res
));
st
.
insert
(
res
);
}
}
}
}
for
(
auto
res
:
st
)
{
bool
ok
=
false
;
for
(
auto
s
:
res
)
if
(
s
[
0
]
==
't'
)
ok
=
true
;
if
(
ok
)
ans
++
;
}
pr
(
ans
);
set
<
string
>
ans2
=
join_to_cur
(
0
);
for
(
auto
s
:
ans2
)
cout
<<
s
<<
','
;
cout
<<
'\n'
;
}
int
main
()
{
ios
::
sync_with_stdio
(
0
);
cin
.
tie
(
0
);
cout
<<
setprecision
(
15
)
<<
fixed
;
#ifdef LOCAL
freopen
(
"input.txt"
,
"r"
,
stdin
);
#endif
solve
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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