176 lines
9.5 KiB
HTML
176 lines
9.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>BOJ 1948 - Offline</title>
|
|
<style>
|
|
:root {
|
|
--bg: #fafaf8;
|
|
--paper: #ffffff;
|
|
--ink: #1e1f24;
|
|
--muted: #6a6d75;
|
|
--line: #d8dce3;
|
|
--accent: #0d6e6e;
|
|
--code-bg: #f4f6fb;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
background:
|
|
radial-gradient(circle at 15% 0%, #f0efe9 0%, transparent 42%),
|
|
radial-gradient(circle at 85% 20%, #e7f1f2 0%, transparent 38%),
|
|
var(--bg);
|
|
color: var(--ink);
|
|
font-family: "Noto Sans KR", "Pretendard", "Apple SD Gothic Neo", sans-serif;
|
|
line-height: 1.65;
|
|
}
|
|
main {
|
|
max-width: 980px;
|
|
margin: 0 auto;
|
|
padding: 24px 16px 56px;
|
|
}
|
|
.header {
|
|
background: var(--paper);
|
|
border: 1px solid var(--line);
|
|
border-radius: 14px;
|
|
padding: 18px 20px;
|
|
margin-bottom: 18px;
|
|
}
|
|
.header h1 { margin: 0 0 6px; font-size: 1.5rem; }
|
|
.header p { margin: 0; color: var(--muted); font-size: 0.95rem; }
|
|
.header a { color: var(--accent); text-decoration: none; }
|
|
.section {
|
|
background: var(--paper);
|
|
border: 1px solid var(--line);
|
|
border-radius: 14px;
|
|
padding: 16px 18px;
|
|
margin-bottom: 14px;
|
|
overflow-x: auto;
|
|
}
|
|
h2 {
|
|
margin: 0 0 10px;
|
|
font-size: 1.05rem;
|
|
color: var(--accent);
|
|
border-bottom: 1px solid var(--line);
|
|
padding-bottom: 8px;
|
|
}
|
|
pre, code {
|
|
font-family: "JetBrains Mono", "Fira Code", monospace;
|
|
background: var(--code-bg);
|
|
}
|
|
pre {
|
|
padding: 12px;
|
|
border-radius: 10px;
|
|
border: 1px solid #e7ebf2;
|
|
overflow: auto;
|
|
}
|
|
blockquote {
|
|
margin: 14px 0;
|
|
padding: 16px 16px 14px 22px;
|
|
border-left: 4px solid var(--accent);
|
|
border-radius: 10px;
|
|
background: linear-gradient(90deg, #eef8f8 0%, #f9fdfd 100%);
|
|
color: #24313a;
|
|
font-weight: 600;
|
|
position: relative;
|
|
}
|
|
blockquote::before {
|
|
content: "“";
|
|
position: absolute;
|
|
left: 8px;
|
|
top: 2px;
|
|
font-size: 1.35rem;
|
|
line-height: 1;
|
|
color: #0b5f5f;
|
|
opacity: 0.7;
|
|
}
|
|
blockquote > :first-child { margin-top: 0; }
|
|
blockquote > :last-child { margin-bottom: 0; }
|
|
q {
|
|
color: #114f50;
|
|
font-weight: 700;
|
|
background: #edf8f8;
|
|
border-radius: 6px;
|
|
padding: 0 4px;
|
|
}
|
|
.math-inline math {
|
|
font-size: 1em;
|
|
vertical-align: middle;
|
|
}
|
|
.math-block {
|
|
margin: 10px 0;
|
|
padding: 8px 10px;
|
|
overflow-x: auto;
|
|
background: #f8fbff;
|
|
border: 1px solid #e2ecf8;
|
|
border-radius: 8px;
|
|
}
|
|
.math-block math {
|
|
font-size: 1.04em;
|
|
display: block;
|
|
}
|
|
table { border-collapse: collapse; width: 100%; }
|
|
th, td { border: 1px solid var(--line); padding: 6px 8px; }
|
|
img { max-width: 100%; height: auto; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<header class="header">
|
|
<h1>임계경로</h1>
|
|
</header>
|
|
<article class="section">
|
|
<h2>문제</h2>
|
|
<blockquote>
|
|
<p>모든 길은 <strong>로마</strong>로 통한다.</p>
|
|
</blockquote>
|
|
|
|
<blockquote>
|
|
<p>천 리 길도 <strong>한 걸음</strong>부터</p>
|
|
</blockquote>
|
|
|
|
<p>월드 나라는 정말 특이하게도 각 도시를 연결하는 모든 도로가 일방통행이며, 그 어떤 도시에서 출발해도 도로를 따라 출발한 도시로 돌아올 방법이 없다. 월드 나라의 가장 유명한 두 도시는 <strong>한걸음</strong>과 <strong>로마</strong>다. <strong>한걸음</strong>에서 출발하면 그 어떤 도시에도 갈 수 있고, 그 어떤 도시에서 출발해도 <strong>로마</strong>에 도착할 수 있기 때문이다.</p>
|
|
|
|
<p><strong>한걸음</strong>으로 들어오는 도로가 하나도 없고 <strong>로마</strong>에서 나갈 수 있는 도로 또한 하나도 없기 때문에 당장 도로를 더 만들어야 할 것 같지만, 어떤 이유인지 월드 나라의 국왕 최백준은 도로를 짓는 대신 월드 나라의 지도를 만들 것을 명하였다. 이에 <strong>한걸음</strong>에서 출발해 <strong>로마</strong>에 도착하는 모든 경로를 전부 탐색하기 위해 선택받은 사람들이 <strong>한걸음</strong>에 모두 모였다.</p>
|
|
|
|
<p>어떻게 왔는지는 잘 모르겠지만, 아무튼 <strong>한걸음</strong>에 모인 사람들은 각자 <strong>로마</strong>에 이르는 서로 다른 경로를 하나씩 배정 받았다. 모인 사람은 충분히 많아서 <strong>로마</strong>에 이르는 그 어떤 경로를 고르더라도 이를 배정 받은 사람이 있다. 이들은 모두 동시에 <strong>한걸음</strong>에서 출발해서 쉬지 않고 <strong>로마</strong>까지 달린다.</p>
|
|
|
|
<p>이들이 모두 <strong>로마</strong>에 도착하는 데에 얼마의 시간이 걸리는가?</p>
|
|
|
|
<p>완성된 지도에 감격한 국왕 최백준은 이들의 업적을 치하하여 가장 오래 달린 사람들이 달린 도로에 전부 황금을 칠할 것을 명하였다. 황금을 칠해야 할 도로의 수는 몇 개인가?</p>
|
|
</article>
|
|
<article class="section">
|
|
<h2>입력</h2>
|
|
<p>첫째 줄에 월드 나라의 도시의 개수 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>n</mi></mrow></math></span> (<span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn><mo>≤</mo><mi>n</mi><mo>≤</mo><mn>10</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span>)이 주어지고 둘째 줄에는 월드 나라의 도로의 개수 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>m</mi></mrow></math></span> (<span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn><mo>≤</mo><mi>m</mi><mo>≤</mo><mn>100</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span>)이 주어진다. 그리고 셋째 줄부터 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>m</mi><mo>+</mo><mn>2</mn></mrow></math></span>번째 줄까지 도로의 정보를 나타내는 세 정수 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>u</mi><mo>,</mo><mi>v</mi><mo>,</mo><mi>w</mi></mrow></math></span>가 공백으로 구분되어 주어진다. 이는 도시 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>u</mi></mrow></math></span>에서 도시 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>v</mi></mrow></math></span>로 향하는 일방통행 도로를 지나는데 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>w</mi></mrow></math></span>의 시간이 걸림을 의미한다. 모든 도로는 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn><mo>≤</mo><mi>u</mi><mo>≤</mo><mn>10</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span>, <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn><mo>≤</mo><mi>v</mi><mo>≤</mo><mn>10</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span>, <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn><mo>≤</mo><mi>w</mi><mo>≤</mo><mn>10</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span>을 만족한다. <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>m</mi><mo>+</mo><mn>3</mn></mrow></math></span>번째 줄에는 <strong>한걸음</strong>과 <strong>로마</strong>의 도시 번호가 공백으로 구분되어 주어지며 두 도시 번호는 모두 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>1</mn></mrow></math></span> 이상 <span class="math-inline"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mn>10</mn><mspace width="0.167em" /><mn>000</mn></mrow></math></span> 이하의 정수이다.</p>
|
|
</article>
|
|
<article class="section">
|
|
<h2>출력</h2>
|
|
<p>첫째 줄에는 선택받은 사람들이 모두 <strong>로마</strong>에 도착하는 데 걸리는 시간을, 둘째 줄에는 황금을 칠해야 할 도로의 수를 출력한다.</p>
|
|
</article>
|
|
<article class="section">
|
|
<h2>예제 입력 1 복사</h2>
|
|
<pre class="sampledata" id="sample-input-1">7
|
|
9
|
|
1 2 4
|
|
1 3 2
|
|
1 4 3
|
|
2 6 3
|
|
2 7 5
|
|
3 5 1
|
|
4 6 4
|
|
5 6 2
|
|
6 7 5
|
|
1 7
|
|
</pre>
|
|
</article>
|
|
<article class="section">
|
|
<h2>예제 출력 1 복사</h2>
|
|
<pre class="sampledata" id="sample-output-1">12
|
|
5
|
|
</pre>
|
|
</article>
|
|
</main>
|
|
</body>
|
|
</html>
|