id
stringlengths 6
6
| slug_name
stringlengths 1
105
| pretty_content
stringlengths 1
27.2k
| test_cases
sequencelengths 1
1
|
---|---|---|---|
p00400 | ASCII Characters | <h1>ã¢ã¹ããŒæå</h1>
ã
<p>
ã³ã³ãã¥ãŒã¿ã®å
éšã§ã¯ãã¹ãŠã®æ
å ±ãæ°å€ãšããŠæ±ãããŠããŸããããšãã°ãã¢ã¹ããŒã³ãŒãã§ã¯ãã¢ã«ãã¡ãããã®å€§æåAã«æ°å€ã®65ãå²ãåœãŠãããŠããŸããåæ§ã«ã¢ã«ãã¡ãããã®å€§æåBã«66ãCã«67ãšããããã«ãAããZã«ã¯é£ç¶ããŠãããã65ãã90ãå²ãåœãŠãããŠããŸãããŸããã¢ã¹ããŒã³ãŒãã§ã¯ãã¢ã«ãã¡ãããã®å°æåaã«97ãå²ãåœãŠãããŠããŸããåæ§ã«ã¢ã«ãã¡ãããã®å°æåbã«98ãcã«99ãšããããã«ãaããzã«ã¯é£ç¶ããŠãããã97ãã122ãå²ãåœãŠãããŠããŸãã
</p>
<p>
äžããããã¢ã¹ããŒã³ãŒãã®æ°å€ããã¢ã«ãã¡ãããã®å€§æåãšå°æåã®ã©ã¡ããè¡šããå€å®ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>$N$
</pre>
<p>
ïŒè¡ã«æ°å€$N$ ($0 \leq N \leq 127$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
倧æåãªãã1ãããå°æåãªãã2ããããã以å€ãªãã0ããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
67
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
110
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
32
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
0
</pre>
| [
[
"67\n",
"67\n"
]
] |
p00401 | Power of Two | <h1>ïŒã®çŽ¯ä¹</h1>
ã
<p>
äžããããæ°ãããã以äžã®æ°ã®äžã§æ倧ã®$2$ã®çŽ¯ä¹ã«å€æããŠãã ãããããšãã°ã$2$ã$3$ãªãã°$2^1=2$ã«å€æããŠãã ãããåæ§ã«$4$,$5$,$6$,$7$ãªãã°$2^2=4$ã«ã$8$,$9$,$10$,$11$,...,$15$ãªãã°$2^3=8$ã«å€æããŠãã ããã
</p>
<p>
äžããããæ°ãããã®æ°ä»¥äžã®æ°ã®äžã§æ倧ã®$2$ã®çŽ¯ä¹ã«å€æããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
</pre>
<p>
ïŒè¡ã«æ°$N$ ($2 \leq N \leq 10^6$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
å€æããæ°ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
54
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
32
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
1024
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1024
</pre>
| [
[
"54\n",
"54\n"
]
] |
p00402 | Meeting Place | <h1>éäŒæ</h1>
ã
<p>
ã€ã
ã¢æã®äœæ°ã¯æã«éäŒæã建ãŠãããšã«ããŸããããã®æã§ã¯æ±è¥¿ã«äžçŽç·ã«äŒžã³ãéè·¯ã«æ²¿ã£ãŠå»ºç©ã建ãŠãããå°ç¹ã決ãŸã£ãŠããŸããæã西ã®å°ç¹ãïŒçªç®ã®å°ç¹ãšããŠãããããçééã«æ±ã«åãã£ãŠïŒçªç®ãïŒçªç®ãâŠãšå°ç¹çªå·ãäžããããŠããŸããæ人ã®å®¶ãšéäŒæã建ãŠãããšãã§ããã®ã¯ããããã®å°ç¹ã ãã§ããå家ã«ã¯ïŒäººä»¥äžã®æ人ãäœãã§ããŸããã©ã®æ人ãé£ã®å°ç¹ãŸã§ïŒåéã§ç§»åã§ããŸãã
</p>
<p>
éäŒãéãã®ã«äŸ¿å©ãªããã«ãããæå»ã«äžæã«å
šãŠã®æ人ãèªåã®å®¶ããéäŒæã«åãã£ããšããå
šå¡ãéãŸãã®ã«å¿
èŠãªæéãæå°ã«ãªããããªå Žæã«ãéäŒæã建ãŠãããšã«ããŸããã
</p>
<p>
家ã®å»ºã£ãŠããå°ç¹ã®çªå·ãäžãããããšãã«ãå
šãŠã®æ人ãéäŒæã«éãŸãã®ã«å¿
èŠãªæéã®æå°å€ãèšç®ããããã°ã©ã ãäœæããããã ããéäŒæã®å°ç¹çªå·ã家ã®å°ç¹çªå·ãšéè€ããŠããããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$x_1$ $x_2$ ... $x_N$
</pre>
<p>
ïŒè¡ç®ã«å®¶ã®æ°$N$ ($1 \leq N \leq 1000$)ãäžãããããïŒè¡ç®ã«å®¶ã®å»ºã£ãŠããå°ç¹çªå·$x_i$ ($0 \leq x_i \leq 2000$)ãäžããããããã ãã家ã®å°ç¹çªå·ã¯å
šãŠç°ãªã($i \ne j$ã«ã€ããŠ$x_i \ne x_j$ã§ãã)ã
</p>
<h2>åºå</h2>
<p>
éäŒæã«éãŸãã®ã«å¿
èŠãªæå°ã®æéãååäœã§ïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3
4 0 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
2
1 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
| [
[
"3\n4 0 1\n",
"3\n4 0 1\n"
]
] |
p00403 | Cave for Cats | <h1>ããã®ããª</h1>
<p>ã
ããªãã®å®¶ã®è¿æã«ã¯å€ãã®ç«ãåºå
¥ããã暪穎ããããŸããäžã¯è¡ãæ¢ãŸãã§éãæããããšã¯ã§ããŸããããè¿æã®ç«ãå
šéšå
¥ãããããã®å¥¥è¡ãããããŸããç©Žã®å¹
ã¯ç«ãã¡ããã©åãŸãããããªã®ã§ãå
ã«å
¥ã£ãç«ãåŸããå
¥ã£ãç«ãæŒãã®ããŠå¥¥ã«åããããšã¯ã§ããŸããããŸããå
ã«å
¥ã£ãç«ããåŸããå
¥ã£ãŠããç«ãæŒãã®ããŠåºå£ããåºãããšãã§ããŸããã
</p>
<p>
ç«å¥œãã®ããªãã¯æšªç©Žã«åºå
¥ãããç«ãé çªã«èšé²ããŠãããŸãããèšé²ãã¯ããããšãã¯æšªç©Žã®äžã«ã¯äžå¹ãç«ã¯ããŸããã§ãããããããŠç«ãã¡ã¯æšªç©Žãžã®åºå
¥ããå§ããŸãããåãç«ãäœåºŠãåºå
¥ãããããšããããŸããã
</p>
<p>
èšé²ãçµããããªãã¯ãæ£ããèšé²ã§ãããããã°ã©ã ãæžããŠãã§ãã¯ããããšã«ããŸããã
</p>
<p>
暪穎ã«åºå
¥ãããç«ã®ãªã¹ããäžããããããªã¹ããå
é ããé ã«èŠãŠãã£ããšããããããåŸããèŠãªããŠã誀ããšå€æã§ããæåã®äœçœ®ãæ±ããããã°ã©ã ãäœæããããã ããç«ã¯100å¹ããŠã1ãã100ãŸã§ã®çªå·ãäžããããŠãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$L$
$c_1$ $c_2$ ... $c_L$
</pre>
<p>
ïŒè¡ç®ã«æšªç©Žã«åºå
¥ãããç«ã®ãªã¹ãã®é·ã$L$ ($1 \leq L \leq 1000$)ãäžãããããç¶ãïŒè¡ã«ã$i$çªç®ã«æšªç©Žã«åºå
¥ãããç«ã®æ
å ±$c_i$ ($-100 \leq c_i \leq 100$, ãã ã$c_iâ 0$)ãäžããããããã ãã$i$çªç®ã«åºå
¥ãããç«ã®çªå·ã$a$ã§ããã®ç«ã暪穎ã«å
¥ã£ããšãã¯$c_i=a$ã暪穎ããåºããšãã¯$c_i=-a$ã§ããã
</p>
<h2>åºå</h2>
<p>
ãªã¹ããå
é ããé ã«èŠãŠãã£ããšããããããåŸããèŠãªããŠã誀ããšå€æã§ããæåã®äœçœ®ãïŒè¡ã«åºåããã誀ãããªãå Žåã¯ããOKããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
4
1 2 -3 -1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
3
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
6
2 1 2 -2 -1 -2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
3
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
5
2 1 -1 3 -3
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
OK
</pre>
| [
[
"4\n1 2 -3 -1\n",
"4\n1 2 -3 -1\n"
]
] |
p00404 | Floor | <h1>åº</h1>
ã
<p>
ãããšå士ã®å®¶ã®åºã«ã¯æ£æ¹åœ¢ã®ã¿ã€ã«ãæ·ãã€ããããŠããŸããèžè¡ã«é è©£ãæ·±ããããšå士ã¯ãèµ€ãé»ãéã®å¡æã䜿ã£ãŠã¿ã€ã«ã«è²ãå¡ãããšã«ããŸãããã¯ããã«éšå±ã®é©åœãªã¿ã€ã«ãã²ãšã€éžã³ã以äžã®æ¹æ³ã§è²ãå¡ã£ãŠãããŸãã
</p>
<ul>
<li>ã¿ã€ã«ãå¡ãè²ããèµ€ïŒå³ã®çªå·ïŒïŒãé»ïŒå³ã®çªå·ïŒïŒãéïŒå³ã®çªå·ïŒïŒã®é ã«å€ããŠãããéã®æ¬¡ã¯ãŸãèµ€ããå§ããã</li>
<li>ãã§ã«è²ãå¡ã£ãé åã®é£ã«æ£æ¹åœ¢ãè¿œå ããããã«è²ãå¡ããããããåãããé åãé·æ¹åœ¢ã«ãªãããã«ãããæ£æ¹åœ¢ãè¿œå ããæ¹åã¯ãæ±ãåã西ãåã®é ã«å€ããŠãããåã®æ¬¡ã¯ãŸãæ±ããå§ããïŒå³ã§ã¯ãäžæ¹åãåãå³æ¹åãæ±ã§ããïŒã</li>
</ul>
<br/>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/PCK2019_floor" width="800"/>
</center>
<br/><br/>
<p>
æåã«èµ€ãå¡ã£ãã¿ã€ã«ããæ±è¥¿æ¹åã«$x$åãååæ¹åã«$y$å移åãããšããã«ããã¿ã€ã«ã¯ãäœè²ã«å¡ãããŠããã§ããããããã ããæ±ã®æ¹åã$x$ã®æ£ã®æ¹åãåã®æ¹åã$y$ã®æ£ã®æ¹åãšããŸãã
</p>
<p>
$x$ãš$y$ãå
¥åããã¿ã€ã«ã®è²ãåºåããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$x$ $y$
</pre>
<p>
ïŒè¡ã«$x$ãš$y$ ($-10^6 \leq x,y \leq 10^6$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
ã¿ã€ã«ã®è²ãèµ€ã®ãšã1ãé»ã®ãšã2ãéã®ãšã3ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
0 0
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
-4 5
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
8 -14
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
3
</pre>
| [
[
"0 0\n",
"0 0\n"
]
] |
p00405 | Akabeko 20 | <h1>ã¢ã«ãã³ïŒïŒ</h1>
ã
<p>
ãã¢ã«ãã³ïŒïŒãã¯ãã€ã
ã¢å°æ¹ã®å°çšåå Žã§å
¬æŒãéå¬ããŠããã°ã«ãŒãã§ããã¢ã«ãã³ïŒïŒã®ããããã®ã¡ã³ããŒã¯ãããäžå®ã®æ¥æ°ããšã«å
¬æŒã«åå ããããšã«ãªã£ãŠããŸãã
</p>
<p>
ä»æ¥ã®å
¬æŒã§ã¯ã¡ã³ããŒãå
šå¡åå ããŠããŸããããããã¥ãŒãµãŒã§ããããªãã¯ãã¡ã³ããŒãããä»åŸã®å
¬æŒã®ã¡ã³ããŒã®çµã¿åãããæããŠã»ããããšé ŒãŸããŸãããããªãã¯ãå
¬æŒã«åå ããã¡ã³ããŒã®çµã¿åãããããã€ããã®ããæ°ããããšã«ããŸããã
</p>
<p>
ã¢ã«ãã³ïŒïŒã®ã¡ã³ããŒæ°ãšãããããã®ã¡ã³ããŒãå
¬æŒã«åå ããåšæãïŒæ¥åäœã§äžãããããšããåå ããã¡ã³ããŒã®çµã¿åãããäœéãããããæ°ããããã°ã©ã ãäœæããããã®ãšããã°ã«ãŒãã¯åãã¡ã³ããŒã§æ°žé ã«åç¶ãããšä»®å®ããããã ããã ããåå ããªãå Žåã¯çµã¿åããã«å«ããªãããšãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$p_1$ $p_2$ ... $p_N$
</pre>
<p>
ïŒè¡ç®ã«ã¢ã«ãã³ïŒïŒã®ã¡ã³ããŒæ°$N$ ($1 \leq N \leq 20$)ãäžãããããç¶ãïŒè¡ã«ãããããã®ã¡ã³ããŒãå
¬æŒã«åå ããåšæ$p_i$ ($1 \leq p_i \leq 40$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
åå ããã¡ã³ããŒã®çµã¿åããã®æ°ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3
3 5 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
7
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
3
2 3 6
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
3
</pre>
<p>
åšæãïŒæ¥ã®ã¡ã³ããŒã®ã¿ãåå ããå
¬æŒïŒåšæãïŒæ¥ã®ã¡ã³ããŒã®ã¿ãåå ããå
¬æŒïŒåšæãïŒæ¥ãïŒæ¥ãïŒæ¥ã®ã¡ã³ããŒãåå ããå
¬æŒã®ïŒéããšãªãã
</p>
| [
[
"3\n3 5 2\n",
"3\n3 5 2\n"
]
] |
p00406 | Arrows | <h1>ç¢å°</h1>
ã<p>
$L$åã®ãã¹ãå·Šå³ã«äžåã«äžŠãã§ããŸããããã€ãã®ãã¹ã®äžã«é§ã眮ããŠãããŸããé§ã«ã¯å·Šåããå³åãã®ç¢å°ãæžããŠãããŸãããªããäžã€ã®ãã¹ã«äºã€ä»¥äžã®é§ã眮ãããšã¯ã§ããŸããã
</p>
<p>
ã©ã®ãã¹ã«ããé§ããé§ã眮ãããŠããªããã¹ã«åããããšãã§ããŸãããã ããäžåºŠã«åããã®ã¯é£ã®ãã¹ãŸã§ã§ãäžåºŠã«åãããã®ã¯äžã€ã®é§ã ãã§ããé§ã¯ãç¢å°ã®åãã«ããããããå·Šã«ãå³ã«ãåããããšãã§ããŸãããã ããé§ãç¢å°ã®æ¹åã«äžååãããšç¹æ°ãïŒç¹ããããŸãããç¢å°ãšã¯éæ¹åã«äžååãããšïŒç¹æžç¹ãããŠããŸããŸãããªããã©ã®ãããªç¶æ³ããå§ãããšããŠããåŸãããç¹æ°ã«ã¯å¿
ãæ倧å€ãããããšãããã£ãŠããŸãã
</p>
<p>
ãã¹ã®åæ°ãšé§ã®ç¶æ³ãäžãããããšããåŸãããæ倧ã®ç¹æ°ãèšç®ããããã°ã©ã ãäœæããããã ãããã¹ã«ã¯åã®å·Šç«¯ããé çªã«1ãã$L$ãŸã§ã®çªå·ãå²ãåœãŠãããŠãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $L$
$p_1$ $d_1$
$p_2$ $d_2$
:
$p_N$ $d_N$
</pre>
<p>
ïŒè¡ç®ã«é§ã®æ°$N$ ($1 \leq N \leq 10^5$)ãšãã¹ã®æ°$L$ ($N \leq L \leq 10^9$)ãäžãããããç¶ã$N$è¡ã«é§ã眮ããããã¹ã®çªå·$p_i$ ($1 \leq p_i \leq L$)ãšé§ã«æžãããç¢å°ã®åã$d_i$ (0ãŸãã¯1)ãäžããããããã ãã$d_i$ã0ã®ãšãã¯ç¢å°ãå·Šåãã1ã®ãšãã¯å³åããè¡šããåããã¹ã®çªå·ã¯äžããããªãïŒ$i \ne j$ã«ã€ããŠã$p_i \ne p_j$ïŒã
</p>
<h2>åºå</h2>
<p>
åŸãããæ倧ã®ç¹æ°ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
2 10
3 0
6 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
6
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
2 8
2 1
8 0
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
5
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
2 8
1 0
8 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
0
</pre>
| [
[
"2 10\n3 0\n6 1\n",
"2 10\n3 0\n6 1\n"
]
] |
p00407 | Castle in the Sky | <h1>倩空ã®åãã«ã¬</h1>
ã<p>
倩空ã®åãã«ã¬ã¯ã¢ã€ã
åœã®äžç©ºã«æµ®ããã§ãããã¢ã€ã
åœã§ã¯ã倩空ã®åãã«ã¬ã«ãã£ãŠæ¥å
ãããããããæ¥ããããæ¥å
ãåœãããªãæ¥ããã£ãå Žæã®äœäººã«ã¯ããã®æ¥æ°ã«å¿ããŠè£åéãæ¯æã£ãŠãããã¢ã€ã
åœã®è£åéæ¯æãæ
åœè
ã§ããããªãã¯ã倩空ã®åãã«ã¬ã®æ¥ããšã®äœçœ®ãšè£åéã®ç³è«ããã£ãå Žæã®ãªã¹ãããããã®æ¥ã«ãã®å Žæã§æ¥å
ãåœãããªãã£ãããšã確ãããå¿
èŠãããã
</p>
<p>
倩空ã®åãã«ã¬ã®å Žæãšã¢ã€ã
åœã®å°äžã®ããå Žæãäžãããããšãããã®æ¥ã«ãã®å Žæã圱ã«å
¥ã£ãŠãããã©ãããå€å®ããããã°ã©ã ãäœæããã圱ã®äžã«å
¥ã£ãŠãããã©ããã¯ãããç¹å®ã®æå»ã§å€å®ããã®ã§ã倩空ã®åãã«ã¬ã倪éœã®ç§»åã«ã€ããŠã¯èããªããŠè¯ãã倪éœã®äœçœ®ã¯$x=y=0,z=10^6$ã«ãã倧ããã®ãªãç¹ã§ããã倩空ã®åãã«ã¬ã¯$z=100$ã®å¹³é¢ã«ããåžå€è§åœ¢ãå°äžã®å Žæã¯$z=0$ã«ãã倧ããã®ãªãç¹ãšããããŸããããå°ç¹ãšå€ªéœãçµã¶çŽç·ã倩空ã®åãã«ã¬ããããããšãããã®å°ç¹ã¯åœ±ã«å
¥ããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$xt_1$ $yt_1$
$xt_2$ $yt_2$
:
$xt_N$ $yt_N$
$Q$
$xa_1$ $ya_1$
$xa_2$ $ya_2$
:
$xa_Q$ $ya_Q$
</pre>
<p>
ïŒè¡ç®ã«å€©ç©ºã®åãã«ã¬ã®é åãè¡šãç¹ã®æ°$N$ ($3 \leq N \leq 3 \times 10^4$)ãäžãããããç¶ã$N$è¡ã«ãé åãæ§æããé ç¹ã®åº§æš$xt_i$,$yt_i$ ($-10^8 \leq xt_i,yt_i \leq 10^8$)ãé åã®éå¿ã®åšãã«åæèšåãã«æŽæ°ã§äžããããããã ããåã座æšããã€é ç¹ã¯äžããããªãïŒ$i \ne j$ã«ã€ããŠã$xt_i \ne xt_j$ ãŸã㯠$yt_i \ne yt_j$ïŒããŸããé åã®é¢ç©ã¯0ãã倧ãããšèããŠè¯ããç¶ãïŒè¡ã«ãè£åéã®ç³è«ããã£ãå Žæã®æ°$Q$ ($1 \leq Q \leq 6 \times 10^4$)ãäžãããããç¶ã$Q$è¡ã«ãè£åéã®ç³è«ããã£ãå Žæã®åº§æš$xa_i$,$ya_i$ ($-10^8 \leq xa_i,ya_i \leq 10^8$)ãæŽæ°ã§äžããããããã ããè£åéã®ç³è«ããã£ãå Žæã®åº§æšã¯ã倩空ã®åãã«ã¬ã®åœ±ã®èŒªéç·ããè·é¢$10^{-3}$以äžé¢ããŠãããšèããŠè¯ãã
</p>
<h2>åºå</h2>
<p>
è£åéã®ç³è«ããã£ãåå Žæã«ã€ããŠã圱ã«å
¥ã£ãŠãããã1ããå
¥ã£ãŠããªãã£ããã0ããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
6
0 0
4 0
6 3
5 5
1 5
0 3
5
2 2
6 6
3 1
5 1
-1 -1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
0
1
0
0
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
4
100000 100000
101000 100000
101000 101000
100000 101000
2
100005 100005
101005 101005
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
0
1
</pre>
| [
[
"6\n0 0\n4 0\n6 3\n5 5\n1 5\n0 3\n5\n2 2\n6 6\n3 1\n5 1\n-1 -1\n",
"6\n0 0\n4 0\n6 3\n5 5\n1 5\n0 3\n5\n2 2\n6 6\n3 1\n5 1\n-1 -1\n"
]
] |
p00408 | Tournament Record | <h1>ããŒãã¡ã³ãã®èšé²</h1>
ã<p.
$N$人ãåå ããããŒãã¡ã³ããè¡ããŸãããããŒãã¡ã³ãã§ã¯äžå¯Ÿäžã§å¯ŸæŠãè¡ããåã¡è² ãã決å®ããŸããåã£ãæ¹ã次ã®è©Šåã«é²ãã§ãããæçµçã«æ®ã£ãäžäººãåªåããŸããããŒãã¡ã³ããè¡ãããäŒå Žã¯ã²ãšã€ãããªãã®ã§ãåæã«è¡ããã®ã¯ïŒè©Šåã®ã¿ã§ãã
</p>
<p>
ããŒãã¡ã³ããçµãã£ãŠåªåè
ã決ãŸããŸã§ãèšé²ä¿ã®ããªãã¯å¯ŸæŠã®åè
ãšæè
ãèšé²ããŸãããããªãã¯å¯ŸæŠããšã«ïŒæã®çŽã䜿ã£ãŠæ£ããèšé²ããŸããããèšé²ããçŽã®é åºãããã€ãå
¥ãæ¿ãã£ãå¯èœæ§ããããŸãã
</p>
<p>
é åºãå
¥ãæ¿ãã£ãå¯èœæ§ã®ãã察æŠã®èšé²ãããããåŸã察æŠã®é çªãäœéãããããæ±ããããã°ã©ã ãäœæããããã ããããŒãã¡ã³ãã®åå è
ã«ã¯1ãã$N$ãŸã§ã®çªå·ãå²ãåœãŠãããŠãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$a_1$ $b_1$
$a_2$ $b_2$
:
$a_{N-1}$ $b_{N-1}$
</pre>
<p>
ïŒè¡ç®ã«åºå Žè
ã®æ°$N$ ($2 \leq N \leq 1000$)ãäžãããããç¶ã$N-1$è¡ã«ãè©Šåã®åè
ãšæè
ã®èšé²$a_i$,$b_i$ ($1 \leq a_i,b_i \leq N$)ãäžããããããã ãã$a_i$ãåè
ã$b_i$ãæè
ãè¡šãã
</p>
<h2>åºå</h2>
<p>
ããåŸã察æŠã®é çªãäœéãããããè¡šãæ°ã$10^6$ã§å²ã£ãäœããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3
1 2
1 3
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
<h3>å
¥åäŸïŒ</3>
<pre>
3
2 1
1 3
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
| [
[
"3\n1 2\n1 3\n",
"3\n1 2\n1 3\n"
]
] |
p00409 | Prayer for Iwashiro | <h1>ã€ã¯ã·ãã®ç¥ã</h1>
ã<p>
å€ä»£åœå®¶ã€ã¯ã·ãã§ã¯ãçœå®³ãèµ·ãããšãã«ãããé®ããããã«ãç¥å®ãç¥ããããããŸãã
</p>
<p>
ç¥å®ã¯å€ææžããæååSãéžã³ã以äžãç¹°ãè¿ãããšã§ååŒãé²ããŠãããŸãã
</p>
<ul>
<li>æåå$S$ã®äžã®å Žæãäžã€éžã³ãããã«æžãããæåãä»ã®æåã«å
¥ãæ¿ããŠã$S$ãæŽæ°ããã</li>
<li>$S$ãã©ã®ãããªæååã®ç¹°ãè¿ãã§è¡šããããèŠã€ããŠãèŠã€ããæååãå±ããããã ãã$S$ãæååã®ç¹°ãè¿ãã§è¡šããªããšãã¯$S$ãå±ããã
</li>
</ul>
<p>
ç¥ãã®å¹åãæ倧ã«ãªãã®ã¯ãæãçãæååã®ç¹°ãè¿ãã§å
ã®æååãè¡šããã®ãå±ãããšãã§ããããšãã°ãababababãšããæååã«å¯ŸããŠããã®æååãã®ãã®ãababã§ã¯ãªããabãšå±ãããšãã«ç¥ãã®å¹åãæ倧ã«ãªããŸãã
</p>
<p>
æ°ç±³ç¥å®ã®ããªãã¯ãäžããããæåå$S$ããç¥ãã®å¹åãæ倧ã«ããæååãçŽ æ©ãèŠã€ããæ¹æ³ãäŒåŸããªããã°ãªããŸããã
</p>
</p>
æåå$S$ãšæåã®å
¥ãæ¿ãã®æ
å ±ãããã€ãäžãããããæåãå
¥ãæ¿ãããã³ã«ãåŸãããæååã«ã€ããŠç¥ãã®å¹åãæ倧ã«ããæååã®é·ããæ±ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $Q$
$S$
$p_1$ $c_1$
$p_2$ $c_2$
:
$p_Q$ $c_Q$
</pre>
<p>
ïŒè¡ç®ã«æååã®é·ã$N$ ($2 \leq N \leq 10^5$)ãšæåãå
¥ãæ¿ããåæ°$Q$ ($1 \leq Q \leq 10^5$)ãäžãããããïŒè¡ç®ã«è±å°æåãããªãé·ã$N$ã®æåå$S$ãäžãããããç¶ã$Q$è¡ã«ã$i$çªç®ã«å
¥ãæ¿ããæåã®äœçœ®$p_i$ ($1 \leq p_i \leq N$)ãšå
¥ãæ¿ããåŸã®æå$c_i$ãäžããããããã ãã$p_i$ã¯æååã®å·Šç«¯ããæ°ããŠäœçªç®ãã§è¡šãããããŸãã$c_i$ã¯è±å°æåã§ããã
</p>
<h2>åºå</h2>
<p>
æåãå
¥ãæ¿ãããã³ã«ãåŸãããæååã«ã€ããŠç¥ãã®å¹åãæ倧ã«ããæååã®é·ããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
6 5
ababac
6 b
3 c
4 a
5 b
6 c
</pre>
<h3>åºåäŸ</h3>
<pre>
2
6
6
6
3
</pre>
| [
[
"6 5\nababac\n6 b\n3 c\n4 a\n5 b\n6 c\n",
"6 5\nababac\n6 b\n3 c\n4 a\n5 b\n6 c\n"
]
] |
p00410 | Dungeon 3 | <h1>ãã³ãžã§ã³ïŒ</h1>
ã
<p>
ããªãã¯æåãªåéºå®¶ã§ããããã§ã«ïŒã€ã®ãã³ãžã§ã³ãå¶èŠãããããªãã¯ããã€ãã®éè·¯ãšå®ç©åº«ãèšãããæ°ããªãã³ãžã§ã³ã®å°å³ãå
¥æãããå°å³ã«ã¯ããããã®å®ç©åº«ã«ãã財å®ã®äŸ¡å€ãæžãããŠããã
</p>
<p>
ããªãã¯ãä»»æã®å®ç©åº«ãããã³ãžã§ã³ã«äŸµå
¥ããä»»æã®å®ç©åº«ãããã³ãžã§ã³ãè±åºããããšãã§ããã䟵å
¥ããè±åºãŸã§ã®éã«ãéè·¯ãéã£ãŠå®ç©åº«ã®éãäœåºŠã移åããŠã蚪ããå®ç©åº«ã®è²¡å®ãæã«å
¥ããããšãã§ãããå°å³ã«ããã°ãåéè·¯ã¯åæ¹åã«éãããšãã§ããã©ã®å®ç©åº«ããã©ã®å®ç©åº«ã«ãïŒæ¬ä»¥äžã®éè·¯ãçµç±ããŠãã©ãã€ãããšãã§ãããããããéè·¯ã¯äžåºŠéããšäºåºŠç®ä»¥éã¯äžåºŠç®ãšåãåãã«ããéãããšãã§ããªããªããå®ç©åº«ã®è²¡å®ã¯ããããæåã«èšªãããšãã ãæã«å
¥ããããšãã§ããããã®ãšããæã«ãã財å®ã®äŸ¡å€ã®ç·åãæ倧ã«ãããã
</p>
<p>
å°å³ã®æ
å ±ãäžãããããšãã䟵å
¥ããè±åºãŸã§ã®éã«æã«ãããããšã®ã§ãã財å®ã®äŸ¡å€ã®ç·åã®æ倧å€ãæ±ããããã°ã©ã ãäœæããããã ããå®ç©åº«ã«ã¯1ããNãŸã§ã®çªå·ãå²ãåœãŠãããŠãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $M$
$v_1$
$v_2$
:
$v_N$
$s_1$ $t_1$
$s_2$ $t_2$
:
$s_M$ $t_M$
</pre>
<p>
ïŒè¡ç®ã«å®ç©åº«ã®æ°$N$ ($2 \leq N \leq 10^5$)ãšéè·¯ã®æ°$M$ ($1 \leq M \leq 2 \times 10^5$)ãäžãããããç¶ã$N$è¡ã«ã$i$çªç®ã®å®ç©åº«ã«çœ®ãããŠãã財å®ã®äŸ¡å€$v_i$ ($1 \leq v_i \leq 1000$)ãäžãããããç¶ã$M$è¡ã«ãããããã®éè·¯ã®äž¡ç«¯ã«æ¥ç¶ãããŠããå®ç©åº«ã®çªå·$s_i$,$t_i$ ($1 \leq s_i,t_i \leq N, s_i \ne t_i$)ãäžããããããã ããåãå®ç©åº«å士ãã€ãªãéè·¯ã¯ïŒåºŠä»¥äžäžããããªãã
</p>
<h2>åºå</h2>
<p>
åŸãããšãã§ãã財å®ã®äŸ¡å€ã®ç·åã®æ倧å€ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5 4
2
1
3
6
4
1 2
2 3
2 4
4 5
</pre>
<h3>åºåäŸ</h3>
<pre>
14
</pre>
| [
[
"5 4\n2\n1\n3\n6\n4\n1 2\n2 3\n2 4\n4 5\n",
"5 4\n2\n1\n3\n6\n4\n1 2\n2 3\n2 4\n4 5\n"
]
] |
p00411 | Stop Watch without Tick Mark | <h1>ç®çãã®ãªãã¹ããããŠã©ãã</h1>
ã
<p>
å³ã®ãããªã¹ããããŠã©ããããããŸãããã®ã¹ããããŠã©ããã«ã¯ïŒã瀺ãç®å°ãäžã€ããã ãã§ãç®çãããããŸãããèµ·åããç¬éãéã¯ç®å°ãæããããããéã¯è»žãäžå¿ã«äžå®ã®å²åã§æèšåãã«å転ããŸããç®çãããªãã®ã§ãèµ·åããã®çµéæéãçŽæ¥èªã¿åãããšã¯ã§ããŸããããã®ä»£ãããéãç®å°ããæèšåãã«$a$床åã£ããšãã®çµéæéã$t$ç§ã§ããããšãããã£ãŠããŸãããã ãã$a$ã¯360床æªæºãšããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/PCK2019_stop_watch"></img>
</center>
<p>
è§åºŠ$a$ãšçµéæé$t$ãäžãããããšããã¹ããããŠã©ããèµ·ååŸã«èªã¿åã£ãéã®è§åºŠrãè¡šãçµéæéãæ±ããããã°ã©ã ãäœæããããã ããéãïŒåšããŠããªãããšã¯ããã£ãŠãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$a$ $t$ $r$
</pre>
<p>
ïŒè¡ã«è§åºŠ$a$ ($1 \leq a \leq 359$)ãšè§åºŠ$a$ã®ãšãã®çµéæé$t$ ($1 \leq t \leq 1,000$)ãèªã¿åã£ãè§åºŠ$r$ ($0 \leq r \leq 359$)ããã¹ãŠæŽæ°ã§äžããããããã ãã$a$ãš$r$ã®åäœã¯åºŠã$t$ã®åäœã¯ç§ãšããã
</p>
<h2>åºå</h2>
<p>
èªã¿åã£ãéã®è§åºŠãè¡šãçµéæéãç§ã§ïŒè¡ã«å®æ°ã§åºåããããã ãã誀差ããã©ã¹ãã€ãã¹0.001ãè¶
ããŠã¯ãªããªãã<!--ãã®æ¡ä»¶ãæºããã°å°æ°ç¹ä»¥äžäœæ¡è¡šç€ºããŠãããã-->
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
180 120 90
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
60.0
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
90 100 120
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
133.333333
</pre>
| [
[
"180 120 90\n",
"180 120 90\n"
]
] |
p00412 | Gas Station | <h1>ã¬ãœãªã³ã¹ã¿ã³ã</h1>
ã
<p>
çœèãµãŒãã¹ãšãªã¢ã®ã¬ãœãªã³ã¹ã¿ã³ãã«ã¯ã$1$ãã$N$ã®çªå·ãå²ãåœãŠããã$N$åã®ã¬ãŒã³ããããŸããåã¬ãŒã³ã®å
é ã®è»ã絊油ãè¡ãããšãã§ããŸãã
</p>
<p>
ã¬ãœãªã³ã¹ã¿ã³ãã«å
¥å Žããè»ã¯ã䞊ãã§ããè»ãæãå°ãªãã¬ãŒã³ãéžã³åã®æ«å°Ÿã«äžŠã³ãŸãããã®ãããªã¬ãŒã³ãè€æ°ããå Žåã¯ãçªå·ãæãå°ããã¬ãŒã³ãéžã³ãŸãã絊油ãçµãããšãã®è»ã¯ã¬ãŒã³ããåºãŠããããã®åŸãã®è»ã絊油ãè¡ããŸããäžåºŠã¬ãŒã³ãéžãã ããä»ã®ã¬ãŒã³ã«ç§»ãããšã¯ã§ããŸããããŸããã¬ãŒã³ã«äžŠãã§ããè»ã®é çªãå€ããããšã¯ãããŸããã
</p>
<p>
ã¬ãŒã³ã®æ°ãå
¥å Žããè»ãšçµŠæ²¹ãçµäºããã¬ãŒã³ã®æ
å ±ãäžãããããšãã絊油ãçµäºããè»ã®ãã³ããŒãé çªã«åºåããããã°ã©ã ãäœæãããå
¥å Žã®æ
å ±ã¯ã¹ã¿ã³ãã«å
¥ã£ãŠããè»ã®ãã³ããŒã絊油çµäºã®æ
å ±ã¯å
é ã®è»ã®çµŠæ²¹ãçµäºããã¬ãŒã³çªå·ãšããŠããããäžããããããã ããæåã¯ã©ã®ã¬ãŒã³ã«ãè»ã¯äžŠãã§ããªããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $M$
$info_1$
$info_2$
:
$info_M$
</pre>
<p>
ïŒè¡ç®ã«ã¬ãŒã³ã®æ°$N$ ($1\leq N \leq 10$)ãšæ
å ±ã®æ°$M$ ($2 \leq M \leq 10,000$)ãäžãããããç¶ã$M$è¡ã«åæ
å ±$info_i$ãäžãããããå$info_i$ã¯ä»¥äžã®ããããã®åœ¢åŒã§äžããããã
</p>
<pre>
0 $lane$
</pre>
<p>
ãŸãã¯
</p>
<pre>
1 $car$
</pre>
<p>
æåã®æ°åã0ã®å Žåãçªå·ã$lane$ ($1 \leq lane \leq N$)ã§ããã¬ãŒã³ã«äžŠãã§ããå
é ã®è»ã®çµŠæ²¹ãçµäºããããšã瀺ããæåã®æ°åã1ã®å Žåããã³ããŒã$car$ ($1 \leq car \leq 9,999$)ã§ããè»ãã¹ã¿ã³ãã«å
¥å Žããããšã瀺ãã
</p>
<p>
å
¥åã¯ä»¥äžã®å¶çŽãæºããã
</p>
<ul>
<li> ã¬ãœãªã³ã¹ã¿ã³ãã«å
¥ã£ãŠæ¥ãè»ã®ãã³ããŒã¯ãå
šãŠç°ãªãã</li>
<li> æåã®æ°åã0,1ã§ããæ
å ±ã¯ãããããå¿
ãïŒã€ä»¥äžããã</li>
<li> è»ã®ããªãã¬ãŒã³ã«å¯ŸããŠãæåã®æ°åã0ã§ããæ
å ±ã¯äžããããªãã</li>
</ul>
<h2>åºå</h2>
<p>
絊油çµäºã®æ
å ±ããšã«ã絊油ãçµäºããè»ã®ãã³ããŒã1è¡ã«åºåããã
â</p>
<h2>å
¥åºåäŸ</h2>
<h3>
å
¥åäŸ
</h3>
<pre>
2 7
1 999
1 1000
0 2
1 1001
1 1002
0 1
0 1
</pre>
<h3>åºåäŸ</h3>
<pre>
1000
999
1002
</pre>
| [
[
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n0 1\n",
"2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n0 1\n"
]
] |
p00413 | Laver | <h1>æµ·è(ã®ã)</h1>
<p>ã
ããã©æµ·ã®æµèŸºã®éèœã§ã¯æµ·èã®çç£ãçãã§ããæµ·èã¯ãã¹ãŠé·æ¹åœ¢ã«æåãããŸããæµ·èã倩æ¥å¹²ããããšãã¯ãïŒæã®æµ·èãåãæ·ç©ã®äžã«ä¹ããŠãïŒæç®ã®äžèŸºãšïŒæç®ã®äžèŸºãå¹³è¡ã«ãªãããã«çœ®ããŸããã¢ã«ãã€ãã®ã²ã³ã ããã¯å¹³è¡ã«çœ®ãããšã¯ã§ããã®ã§ããããŸã æ
£ããŠããªãããéãªã£ãéšåãã§ããŠããŸãããšããããŸããéãªã£ãéšåã¯å£²ãç©ã«ãªããªãã®ã§ãéãªã£ãŠããªãéšåã®æµ·èã®é¢ç©ãæ±ããŠããå¿
èŠããããŸãã
</p>
<p>
åãæ·ç©ã®äžã«çœ®ããïŒæã®æµ·èããããã®å·Šäžç«¯ã®äœçœ®ãšå¹
ãšé«ããäžãããããšããéãªã£ãŠããªãéšåã®æµ·èã®é¢ç©ãåºåããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$x_1$ $y_1$ $w_1$ $h_1$
$x_2$ $y_2$ $w_2$ $h_2$
</pre>
<p>
ïŒè¡ç®ã«ïŒæç®ã®æµ·èã®å·Šäžç«¯ã®åº§æš$x_1,y_1$ ($0 \leq x_1,y_1 \leq 1,000$)ãšå¹
ãšé«ã$w_1,h_1$ ($1 \leq w_1,h_1 \leq 1,000$)ãäžãããããïŒè¡ç®ã«ïŒæç®ã®æµ·èã®å·Šäžç«¯ã®åº§æš$x_2,y_2$ ($0 \leq x_2,y_2 \leq 1,000$)ãšå¹
ãšé«ã$w_2,h_2$ ($1 \leq w_2,h_2 \leq 1,000$)ãäžãããããå
¥åã¯ãã¹ãŠæŽæ°ã§äžããããã
</p>
<h2>åºå</h2>
<p>
éãªã£ãŠããªãéšåã®æµ·èã®é¢ç©ãæŽæ°ã§ïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
0 0 4 5
2 2 3 6
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
26
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
1 2 2 1
2 0 2 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
6
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
0 0 1 1
0 0 1 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
0
</pre>
â
| [
[
"0 0 4 5\n2 2 3 6\n",
"0 0 4 5\n2 2 3 6\n"
]
] |
p00414 | Molting | <h1>ãžã³ã®è±ç®</h1>
<p>
ã»ã¢ããªé«åã§çºèŠãããæ°çš®ã®ãžã³ã¯ãé ããå°Ÿã«ãããŠïŒåã«äžŠãã ãã«ïŒoïŒãšããïŒxïŒãããªãæš¡æ§ãç¹åŸŽã§ããäžå³ã«äŸã瀺ããŸããããžã³ã®æš¡æ§ã¯åäœã«ããæ§ã
ã§ãã
</p>
<pre>
xxoooxxxoox
</pre>
<p>
ãã®ãžã³ã¯è±ç®ã®ãšãã«ãïŒã€ã®ãã«ã䞊ãã éšåã®éãã¹ãŠã䌞ã³ãããšã§æé·ããŸããæ°ãã«å ãã£ãç®æã«ã¯ãã«ãããããã«ã䞊ãã æš¡æ§ãä»ããŸãã
</p>
<p>
ããšãã°ãé·ãïŒã®ãžã³<span>ooo</span>ãïŒåè±ç®ãããšãå·Šãã1çªç®ãšïŒçªç®ãïŒçªç®ãšïŒçªç®ã®ãã«ã®éã«ãã«ãããããã«ã䞊ãã æš¡æ§ãå ããã®ã§ãè±ç®åŸã®ãžã³ã¯<span>ooxoooxoo</span>ãšãªããŸãïŒäžç·éšãæ°ãã«å ãã£ãç®æã§ãïŒãããäžåè±ç®ãããš<span>ooxooxooxoooxooxooxoo</span> ãšãªãããžã³ã®é·ãã¯ïŒïŒã«ãªããŸãã
</p>
<p>
ãã®ãžã³ã®çæ
ãç 究ããŠããããªãã¯ããã®ãžã³ãè±ç®ãç¹°ãè¿ãããããšãŠã€ããªãé·ãã«ãªã£ãŠããŸããããããªããšå±æ§ããŠããŸãã
</p>
<p>
ãžã³ã®æš¡æ§ãšè±ç®ã®åæ°ãäžãããããšãããã®åæ°ã ãè±ç®ããåŸã®ãžã³ã®é·ããæ±ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$L$ $N$
$snake$
</pre>
<p>
ïŒè¡ç®ã«è±ç®ããåã®èã®é·ã$L$($1\leq L \leq 100$)ãšè±ç®ã®åæ°$N$ ($1 \leq N \leq 50$)ãäžãããããç¶ãïŒè¡ã«è±ç®ããåã®ãžã³ã®æš¡æ§ãè¡šãé·ã$L$ã®æåå$snake$ãäžããããããã ã$snake$ã¯è±å°æå<span>x</span>ãš<span>o</span>ãããªãã
</p>
<h2>åºå</h2>
<p>
ãžã³ã®é·ããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3 2
ooo
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
21
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
3 4
xoo
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
48
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
13 30
xooxoooxxxoox
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
12884901889
</pre>
| [
[
"3 2\nooo\n",
"3 2\nooo\n"
]
] |
p00415 | Digits K | <h1>ããžãã</h1>
ã
<p>
ã¢ã€ã
èµ€ã¹ãåºã§ã¯ãããžãããšåŒã°ãããŠããŒã¯ãªããããã販売ããŠããŸããåããã«ã¯ãå·Šããå³ãžåãã£ãŠ1åã«$N$åã®æ°åã䞊ãã§ããŸãããã ããæžãããŠããã®ã¯ïŒããïŒãŸã§ã®æ°åã§ãã
</p>
<p>
ããã®è³Œå
¥è
ã¯ããããã®æ°åãã$K$åã®æ°åãæ¶å»ããæ®ã£ã$N-K$åã®æ°åãå·Šããé çªã«äžŠã¹ãŠã§ããæ°ããã€ã³ããšããŠç²åŸããããšãã§ããŸããããšãã°$K=3$ã®ãšããããã«$1414213$ãšæžãããŠããã°ãå·Šãã$1$ã$1$ã$2$ãéžæããŠæ¶å»ããããšã§$4413$ãã€ã³ããç²åŸããããšãã§ããŸãã
</p>
<p>
æ°åã®åãšæŽæ°$K$ãäžãããããšããç²åŸã§ãããã€ã³ãã®æ倧å€ãåºåããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $K$
$a_1$ $a_2$ ... $a_N$
</pre>
<p>
ïŒè¡ç®ã«æ°åã®æ°$N$ ($1 \leq N \leq 200,000$)ãšæŽæ°$K$ ($0 \leq K < N$)ãäžãããããïŒè¡ç®ã«ããã«æžãããŠãã$N$åã®æ°$a_i$ ($1 \leq a_i \leq 9$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
ãã€ã³ãã®æ倧å€ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
7 3
1 4 1 4 2 1 3
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
4423
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
4 1
1 1 9 9
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
199
</pre>
| [
[
"7 3\n1 4 1 4 2 1 3\n",
"7 3\n1 4 1 4 2 1 3\n"
]
] |
p00416 | Two Polygons | <h1>ïŒã€ã®å€è§åœ¢</h1>
ã
<p>
ã€ãšããã¯ïŒæ¬ä»¥äžã®çã£ãããªæ£ãç¹ããŠå€è§åœ¢ãäœããæ人ã®ãžã§ãŠåã«ãã¬ãŒã³ãããããšã«ããŸãããæ£ã¯ãããã®ç«¯ç¹ã§ã®ã¿ç¹ããããšãã§ããŸãã端ç¹ã¯ãã¹ãŠåãå¹³é¢äžã«çœ®ããŸããäžã€ã®æ¥åç¹ã§ç¹ããæ£ã¯ïŒæ¬ã ãã§ããããããªãè§åºŠã¯èªç±ã«æ±ºããããšãã§ããŸãã
</p>
<p>
ã€ãšããã¯ãèªåãæã£ãŠããæ£ããã¹ãŠäœ¿ã£ãŠå€§ãããåããããã®ïŒã€ã®å€è§åœ¢ãäœãããšããŠããŸãã
</p>
<p>
äžãããããã¹ãŠã®æ£ã䜿ã£ãŠãïŒã€ã®å€è§åœ¢ãããããã®åšå²ã®é·ãã®å·®ã®çµ¶å¯Ÿå€ãæå°ãšãªãããã«äœããåæ£ã®é·ããäžãããããšããïŒã€ã®å€è§åœ¢ã®åšå²ã®é·ãã®å·®ã®çµ¶å¯Ÿå€ãæ±ããããã°ã©ã ãäœæãããïŒã€ã®å€è§åœ¢ãäœæã§ããªãå Žåã¯ãã®ããšãå ±åããããã ããé·ãã$a_1 \leq a_2 \leq ... \leq a_m$ã§ãã$m$ ($3 \leq m$)æ¬ã®æ£ã§ã$a_m ïŒa_1+a_2+ ... +a_{m-1}$ãæºãããšããããã$m$æ¬ã®æ£ã§ã²ãšã€ã®å€è§åœ¢ãäœæã§ãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$a_1$ $a_2$ ... $a_N$
</pre>
<p>
ïŒè¡ç®ã«æ£ã®æ°$N$ ($6 \leq N \leq 40$)ãäžãããããïŒè¡ç®ã«åæ£ã®é·ã$a_i$ ($1 \leq a_i \leq 100$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
äžãããããã¹ãŠã®æ£ã䜿ã£ãŠïŒã€ã®å€è§åœ¢ãäœããå Žåã¯ãé·ãã®å·®ã®çµ¶å¯Ÿå€ã®æå°å€ãïŒè¡ã«åºåãããïŒã€ã®å€è§åœ¢ãäœããªãå Žåã¯ã-1ããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
6
2 2 3 2 2 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
7
2 2 3 2 2 2 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
0
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
6
1 1 1 1 2 4
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
-1
</pre>
| [
[
"6\n2 2 3 2 2 2\n",
"6\n2 2 3 2 2 2\n"
]
] |
p00417 | Bug | <h1>ã³ã³ãã¥ãŒã¿ã·ã¹ãã ã®äžå
·å</h1>
ã
<p>
ããªãã¯äžçæé«æ§èœã®ã³ã³ãã¥ãŒã¿ã·ã¹ãã ãé£ç±å€ïŒãªããïŒããèšèšããŠããããããããã®ã·ã¹ãã ã®ãããã¿ã€ãã®å®è£
äžã«ãåœä»€åãããæ¡ä»¶ãæºãããšã·ã¹ãã ãåæ¢ãããšããäžå
·åãèŠã€ãã£ãã
</p>
<p>
ãã®ã·ã¹ãã ã¯ãé·ã$N$ã®åœä»€åãããã°ã©ã ãšããŠäžããããšã§åäœãããåœä»€åã®äžã®$m$çªç®ã®åœä»€ãæ°$X_m$ã§è¡šãããšããäžå
·åãèµ·ããæ¡ä»¶ã¯ãããæŽæ°$i,j$ ($2 \leq iïŒj \leq N$)ã«å¯ŸããŠ$X_i + X_{j-1} = X_j + X_{i-1}$ãšãªãåœä»€ã®ãã¿ãŒã³ãåœä»€åã«ååšããããšã§ãããšå€æããã
</p>
<p>
ããªãã¯ãã®äžå
·åãã©ã®çšåºŠã®åœ±é¿ã«ãªãã®ãã調ã¹ããããããé·ãã§äœãããšãã§ããåœä»€åã®ãã¡ãäœçš®é¡ã®åœä»€åãäžå
·åãèµ·ãããã調ã¹ãããšã«ããã
</p>
<p>
é·ã$N$ã®åœä»€åã®ãã¡ãäžå
·åãèµ·ããåœä»€åãäœéãããããæ±ããããã°ã©ã ãäœæããããã ããåœä»€ã¯$1$以äž$K$以äžã®æŽæ°ã§è¡šããããšãšãããçãã¯äžããããçŽ æ°$M$ã§å²ã£ãäœããšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $K$ $M$
</pre>
<p>
ïŒè¡ã«ãåœä»€åã®é·ã$N$ ($3 \leq N \leq 100,000$)ãåœä»€ã®çš®é¡ã®æ°$K$ ($1 \leq K \leq 10$)ãçŽ æ°$M$ ($100,000,007 \leq M \leq 1,000,000,007$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
äžå
·åãèµ·ããåœä»€åã®æ°ãMã§å²ã£ãäœããåºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3 2 100000007
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
<p>
åœä»€åã$(X_1,X_2,X_3)$ã®ããã«è¡šããšãèããããåœä»€åã¯$(1,1,1)$ã$(1,1,2)$ã$(1,2,1)$ã$(1,2,2)$ã$(2,1,1)$ã$(2,1,2)$ã$(2,2,1)$ã$(2,2,2)$ã®ïŒéãããã®ãã¡ãäžå
·åãèµ·ããåœä»€åã¯$(1,1,1)$ã$(2,2,2)$ã®ïŒéãã
</p>
<h3>å
¥åäŸïŒ</h3>
<pre>
9 10 100000037
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
66631256
</pre>
<p>
äžå
·åãèµ·ããåœä»€åã¯866631552éããããããã®æ°ãçŽ æ°100000037ã§å²ã£ãäœããåºåãšãªãã
</p>
| [
[
"3 2 100000007\n",
"3 2 100000007\n"
]
] |
p00418 | Gym with Many Rules | <h1>決ãŸãããšã®å€ããžã </h1>
ã<p>
ã€ã
ã¢æã®ã¹ããŒããžã ã«ã¯$1$ãã$N$ãŸã§ã®çªå·ãä»ãã$N$å°ã®ãã¬ãŒãã³ã°æ©åšããããŸãããã¬ãŒãã³ã°æ©åšãïŒåå©çšããã«ã¯ããã®æ©åšã®çªå·ãæžããããã±ãããïŒæå¿
èŠã§ãããã¬ãŒãã³ã°æ©åšãïŒåå©çšãããšãã®æ¶è²»ã«ããªãŒã¯ãæ©åšããšã«æ±ºãŸã£ãŠããŸãã
</p>
<p>
ãã®ã¹ããŒããžã ã®ãã±ãããäœæãããã£ãã¢ãã·åã¯ãéåäžè¶³è§£æ¶ã®ããã«ãžã ã«è¡ããŸããããã®ãžã ã§ã¯ãå©çšè
ãéåããããããŠäœãçããªãããã«ãæ©åšã®å©çšåæ°ã«ã«ãŒã«ããããŸããããšãã°ããïŒçªã®æ©åšã¯ïŒçªã®æ©åšãããïŒå以äžå€ã䜿ã£ãŠã¯ãããŸããããšãããããªã«ãŒã«ã§ããæ©åšã䜿ã人ã¯ãã«ãŒã«ãå®ã£ãŠæ©åšãå©çšããªããã°ãªããŸããã
</p>
<p>
ã¢ãã·åã¯ãããã£ããã±ããã䜿ã£ãŠãã«ãŒã«ã§èš±ãããç¯å²ã§ãªãã¹ãå€ãã®ã«ããªãŒãæ¶è²»ããããšæã£ãŠããŸãã
</p.
<p>
ããã£ããã±ãããšããããã®æ©åšã®æ
å ±ãäžãããããšããã«ãŒã«ãå®ã£ããšãã®æ¶è²»ã«ããªãŒã®æ倧å€ãæ±ããããã°ã©ã ãäœæããªããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $R$
$t_1$ $e_1$
$t_2$ $e_2$
:
$t_N$ $e_N$
$a_1$ $b_1$ $c_1$
$a_2$ $b_2$ $c_2$
:
$a_R$ $b_R$ $c_R$
</pre>
<p>
ïŒè¡ç®ã«ãã¬ãŒãã³ã°æ©åšã®å°æ°$N$ ($1 \leq N \leq 100,000$)ãšã«ãŒã«ã®æ°$R$ ($0 \leq R \leq 100,000$)ãäžãããããç¶ã$N$è¡ã«ã$i$çªã®æ©åšã«ã€ããŠãã¢ãã·åãããã£ããã±ããã®ææ°$t_i$ ($1 \leq t_i \leq 200,000$)ãšãã®æ©åšã䜿ã£ããšãã®æ¶è²»ã«ããªãŒ$e_i$ ($0 \leq e_i \leq 100,000$)ãäžãããããç¶ã$R$è¡ã«ãã$a_i$çªã®æ©åšã¯$b_i$çªã®æ©åšããã$c_i$å以äžå€ã䜿ã£ãŠã¯ãããŸããããšããã«ãŒã«ãè¡šãæ°$a_i$ ($1 \leq a_i \leq N$)ã$b_i$ ($1 \leq b_i \leq N$)ã$c_i$ ($1 \leq c_i \leq 100,000$)ãäžããããã
</p>
<p>
å
¥åã¯ä»¥äžã®å¶çŽãæºããã
</p>
<ul>
<li> åãæ©åšã®ãã¢ã«å¯Ÿããã«ãŒã«ã¯ïŒåºŠããäžããããªã($i \ne j$ãªã$a_i \ne a_j$ãŸãã¯$b_i \ne b_j$)ã</li>
<li> åãæ©åšèªèº«ã«å¯Ÿããã«ãŒã«ã¯äžããããªã($a_i \ne b_i$)ã</li>
</ul>
<h2>åºå</h2>
<p>
æ¶è²»ã«ããªãŒã®æ倧å€ãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
3 2
5 1
10 4
6 2
2 1 3
3 2 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
45
</pre>
<p>
ããã£ããã±ããã䜿ã£ãŠãã«ãŒã«ãå®ã£ãŠäœ¿ããåæ©åšã®æ倧ã®åæ°ã¯ã$1$çªã$5$åã$2$çªã$7$åã$3$çªã$6$åãªã®ã§ãæ¶è²»ã«ããªãŒã®æ倧å€ã¯$5 \times 1 + 7 \times 4 + 6 \times 2 = 45$ãšãªãã
</p>
<h3>å
¥åäŸïŒ</h3>
<pre>
4 5
5 1
6 2
2 3
7 1
1 2 4
2 1 3
1 3 2
3 2 3
3 4 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
26
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
1 0
200000 100000
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
20000000000
</pre>
| [
[
"3 2\n5 1\n10 4\n6 2\n2 1 3\n3 2 1\n",
"3 2\n5 1\n10 4\n6 2\n2 1 3\n3 2 1\n"
]
] |
p00419 | Into the Wild | <h1>å±±ãžåž°ãã</h1>
<p>ã
è¿å¹Žã€ãºã¢åœã§ã¯ãå±±ããè¡ã«éããŠããåç©ã«æ©ãŸãããŠãããããªãã¯åç©ãå±±ãžåž°ãããšç 究ãéãã以äžã®ããšãæããã«ããã
</p>
<ul>
<li> ããããã®åç©ã«ã¯åºæã®ååãã€ããŠããã</li>
<li> ïŒäœã®åç©ã«ã€ããŠãäžæ¹ã®åç©ã®ååã®ã©ããã®äœçœ®ã«ïŒæåãæ¿å
¥ãããšãããäžæ¹ã®åç©ã®ååãšäžèŽããå Žåããããããã¢ã«ããŠå±±ãžåž°ãããšãã§ããã</li>
<li> äžåºŠå±±ãžåž°ã£ãåç©ããåã³è¡ã«éããŠããããšã¯ãªãã</li>
</ul>
<p>
ããªãã¯ãè¡ã«éããŠããåç©ãããã®æ¹æ³ã§ã©ã®ãããå±±ãžåž°ãããšãã§ããããèšç®ããããšã«ããã
</p>
<p>
è¡ã«éããŠããåç©ã®ååãäžãããããšãããã®æ¹æ³ã§æ倧ããã€ã®ãã¢ãå±±ãžåž°ãããšãã§ããããæ±ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$str_1$
$str_2$
:
$str_N$
</pre>
<p>
ïŒè¡ç®ã«åç©ã®æ°$N$ ($2 \leq N \leq 100,000$)ãäžãããããç¶ã$N$è¡ã«$i$çªç®ã®åç©ã®ååãè¡šãæåå$str_i$ãäžããããããã ã$str_i$ã¯è±å°æåãšè±å€§æåã§æ§æããã10æå以äžã®æååã§ããããŸãããã¹ãŠã®åç©ã®ååã¯ç°ãªã($i \ne j$ãªã$str_i \ne str_j$)ã
</p>
<h2>åºå</h2>
<p>
å±±ãžåž°ãããšãã§ããåç©ã®ãã¢ã®æ°ã®æ倧å€ãåºåããã
â</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
4
aedb
aeb
ebCd
cdE
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
1
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
4
bcD
bD
AbD
bc
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
2
</pre>
â
| [
[
"4\naedb\naeb\nebCd\ncdE\n",
"4\naedb\naeb\nebCd\ncdE\n"
]
] |
p00420 | Chemical Substance Alpha | <h1>ååŠç©è³ªã¢ã«ãã¡</h1>
ã<p>
ã¢ã€ã
補è¬ã§ã¯æ¥ã
ååŠç©è³ªã®ç 究ããªãããŠããŸããããŸç 究ãããŠããã®ã¯ã$1$çªãã$N$çªã®ååã巊端ããå³ç«¯ãžçŽç·ç¶ã«ãªããã æ§é ãããŠããååŠç©è³ªãã³ãŒãããŒã ãã¢ã«ãã¡ãã§ãã
</p>
<p>
ã¢ã€ã
補è¬ã®éçºããæè¡ã䜿ãã°ãã¢ã«ãã¡ãæ§æããååã®äœçœ®ãå
¥ãæ¿ããããšãã§ããŸããå
¥ãæ¿ãã¯æ±ºãŸã£ãæé ã§ããè¡ãããšãã§ããŸãããããã®æé ã®éäžããå§ããŠéäžã§çµããããšãã§ããŸãã巊端ãã$a$çªç®ãš$b$çªç®ã®ååãå
¥ãæ¿ããæäœã$(a,b)$ãšæžããšããŸããããšãã°ã$N=5$ã§æ±ºãŸã£ãæé ã$(1,3),(2,5),(4,3),(1,5)$ã®ãšãã$1$çªç®ã®æäœ$(1,3)$ããå§ããŠ$3$çªç®ã®æäœ$(4,3)$ã§çµããããšãã$2$çªç®ã®æäœ$(2,5)$ããå§ããŠ$4$çªç®ã®æäœ$(1,5)$ã§çµããããšãã§ããŸãã
</p>
<p>
ããªãã¯ãã¢ã«ãã¡ã®ååã®å
¥ãæ¿ãæé ã®äžã®éå§äœçœ®ãšçµäºäœçœ®ãéžãã§ã·ãã¥ã¬ãŒã·ã§ã³ãè¡ããå
¥ãæ¿ãåŸã®ååã®ç¶æ
ã調ã¹ãããšã«ããŸããã
</p>
<p>
ã¢ã«ãã¡ã®ååã®å
¥ãæ¿ãæé ãäžãããããã·ãã¥ã¬ãŒã·ã§ã³ãäœåºŠãè¡ã£ããšããåã·ãã¥ã¬ãŒã·ã§ã³ã§ã®ååã®äœçœ®ã«ã€ããŠè³ªåã«çããããã°ã©ã ãäœæããã質åã¯æ¬¡ã®1.ãŸãã¯2.ã®åœ¢ãããŠããã</p>
</p>
<ol>
<li> çµäºåŸã«å·Šç«¯ãã$i$çªç®ã«äœçœ®ããŠããååã¯ãæåã¯äœçªç®ã«äœçœ®ããŠãããã</li>
<li> æåã«$i$ çªç®ã«äœçœ®ããŠããååãçµäºåŸã«ã©ã®äœçœ®ã«æ¥ãŠãããã
</li>
</ol>
<p>
ãã ããåã·ãã¥ã¬ãŒã·ã§ã³ã¯ãã¢ã«ãã¡ã®åæç¶æ
ïŒ$1$çªãã$N$çªã®ååã巊端ããå³ç«¯ãžçŽç·ç¶ã«ãªããã ç¶æ
ïŒããå§ãããã®ãšããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$ $K$ $Q$
$a_1$ $b_1$
$a_2$ $b_2$
:
$a_K$ $b_K$
$query_1$
$query_2$
:
$query_Q$
</pre>
<p>
ïŒè¡ç®ã«ã¢ã«ãã¡ãæ§æããååã®æ°$N$ ($2 \leq N \leq 100,000$)ãå
¥ãæ¿ãæé ã®é·ã$K$ ($1 \leq K \leq 100,000$)ãå
¥ãæ¿ãåŸã®ååã®ç¶æ
ã調ã¹ãåæ°$Q$ ($1 \leq Q \leq 100,000$)ãäžãããããç¶ã$K$è¡ã«å
¥ãæ¿ãæé ã®äžã®åæäœ$a_i,b_i$ ($1 \leq a_i,b_i \leq N$, $a_i \ne b_i$)ãäžããããã$i$çªç®ã®æäœã¯ã巊端ãã$a_i$çªç®ãš$b_i$çªç®ã®ååãå
¥ãæ¿ããæäœãè¡šããç¶ã$Q$è¡ã«ãå
¥ãæ¿ãçµäºåŸã®ååã®ç¶æ
ãå°ãã質åãäžãããããå$query_i$ã¯ä»¥äžã®ããããã®åœ¢åŒã§äžããããã
</p>
<pre>
1 $s$ $t$ $x$
</pre>
<p>
ãŸãã¯
</p>
<pre>
2 $s$ $t$ $x$
</pre>
<p>
æåã®æ°åã1ã®å Žåãå
¥ãæ¿ãæé ã®äžã®å
¥ãæ¿ãã$s$çªãã$t$çª($1 \leq s \leq t \leq K$)ãŸã§è¡ã£ãåŸã«ãå·ŠåŽãã$x$çªç®($1 \leq x \leq N$)ã®ååã®çªå·ãäœçªãå°ãã質åãè¡šããæåã®æ°åã2ã®å Žåãå
¥ãæ¿ãæé ã®äžã®å
¥ãæ¿ãã$s$çªãã$t$çª($1 \leq s \leq t \leq K$)ãŸã§è¡ã£ãåŸã«ã$x$çª($1 \leq x \leq N$)ã®ååãå·Šããæ°ããŠäœçªç®ã«ãããå°ãã質åãè¡šãã
</p>
<h2>åºå</h2>
<p>
å質åã«å¯ŸããŠãçããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
6 5 8
1 3
2 5
3 4
2 4
2 5
1 1 5 1
1 1 5 2
1 1 5 3
1 1 5 4
1 1 5 5
1 1 5 6
2 3 4 2
1 1 1 1
</pre>
<h3>åºåäŸ</h3>
<pre>
3
2
4
5
1
6
4
3
</pre>
<p>
å
¥ãæ¿ãæé ã¯$(1,3),(2,5),(3,4),(2,4),(2,5)$ã§ããã<br/>
$1$çªç®ãã$6$çªç®ã®è³ªåã§ã¯ãæé ã®$1$çªç®($s=1$)ãã$5$çªç®($t=5$)ãŸã§ãã¹ãŠè¡ã£ãå Žåãªã®ã§ãå
¥ãæ¿ãåŸã®ç¶æ
ã¯ãã¹ãŠå
±éã§ä»¥äžã®ããã«ãªãã
</p>
<p>
åæç¶æ
ã<span>1 2 3 4 5 6</span><br>
$(1,3)$ã®åŸ <span>3 2 1 4 5 6</span><br>
$(2,5)$ã®åŸ <span>3 5 1 4 2 6</span><br>
$(3,4)$ã®åŸ <span>3 5 4 1 2 6</span><br>
$(2,4)$ã®åŸ <span>3 1 4 5 2 6</span><br>
$(2,5)$ã®åŸ <span>3 2 4 5 1 6</span><br>
</p>
<p>
$7$çªç®ã®è³ªåã§ã¯$s=3,t=4$ãªã®ã§ãå
¥ãæ¿ãåŸã®ç¶æ
ã¯ä»¥äžã®ããã«ãªããååçªå·$2$çªã¯å·Šããæ°ããŠ$4$çªç®ã«ããã®ã§ãçãã¯4ã«ãªãã
</p>
<p>
åæç¶æ
ã<span>1 2 3 4 5</span><br>
$(3,4)$ã®åŸ <span>1 2 4 3 5</span><br>
$(2,4)$ã®åŸ <span>1 3 4 2 5</span><br>
</p>
<p>
$8$çªç®ã®è³ªåã§ã¯$s=1,t=1$ãªã®ã§ãå
¥ãæ¿ãåŸã®ç¶æ
ã¯ä»¥äžã®ããã«ãªãã
</p>
<p>
åæç¶æ
ã<span>1 2 3 4 5</span><br>
$(1,3)$ã®åŸ <span>3 2 1 4 5</span><br>
</p>
| [
[
"6 5 8\n1 3\n2 5\n3 4\n2 4\n2 5\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1 5 6\n2 3 4 2\n1 1 1 1\n",
"6 5 8\n1 3\n2 5\n3 4\n2 4\n2 5\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1 5 6\n2 3 4 2\n1 1 1 1\n"
]
] |
p00421 | Sum of the Number of Triangles | <h1>äžè§åœ¢ã®åæ°ã®å</h1>
ã
<p>
座æšå¹³é¢äžã®åç¹$O$ãå·Šäžã座æš$(W,H)$ã«ããç¹ãå³äžãšããé·æ¹åœ¢ã®é åãäžããããŠããŸãããã®é åã«å«ãŸããã$x$座æšãš$y$座æšããšãã«æŽæ°ã§ããç¹ãïŒå以äžå«ãç¹ã®éãŸããèããŸãããã®ãããªç¹ã®éãŸãã®ãã¹ãŠã®çµã¿åããã®åæ°ã$N$ãšããç¹ã®éãŸãã®ããããã$D_1, D_2, ..., D_N$ã§è¡šãããšãã$D_1, D_2, ..., D_N$ã®ããããã«å«ãŸããç¹ãé ç¹ãšããäžè§åœ¢ãèããŸãã
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/PCK2019_triangle"></img>
</center>
<p>
ããšãã°ãå³ã®ããã«$W=H=1$ã®ãšããç¹$O(0,0)$ã$A(1,0)$ã$B(1,1)$ã$C(0,1)$ã®ãã¡ãïŒå以äžå«ãç¹ã®éãŸãã¯$\{O,A,B\}$ã$\{O,A,C\}$ã$\{O,B,C\}$ã$\{A,B,C\}$ã$\{O,A,B,C\}$ã®ïŒã€ã§ãããã®äŸã®å Žåãç¹ã®éãŸãã®ããããã«å«ãŸããäžè§åœ¢ã¯æ¬¡ã®ããã«ãªããŸãã
</p>
<ul>
<li> $\{O,A,B\}$ã«å«ãŸããäžè§åœ¢ã¯$OAB$ã®ã¿ã</li>
<li> $\{O,A,C\}$ã«å«ãŸããäžè§åœ¢ã¯$OAC$ã®ã¿ã</li>
<li> $\{O,B,C\}$ã«å«ãŸããäžè§åœ¢ã¯$OBC$ã®ã¿ã</li>
<li> $\{A,B,C\}$ã«å«ãŸããäžè§åœ¢ã¯$ABC$ã®ã¿ã</li>
<li> $\{O,A,B,C\}$ã«å«ãŸããäžè§åœ¢ã¯$OAB$ã$OAC$ã$OBC$ã$ABC$ã®ïŒåã</li>
</ul>
<p>
ãã®äŸãããããããã«ãåãäžè§åœ¢ãïŒã€ä»¥äžã®ç¹ã®éãŸãã«å«ãŸããå ŽåããããŸããããšãã°ãäžè§åœ¢$OAB$ã¯ç¹ã®éãŸã$\{O,A,B\}$ã«ã$\{O,A,B,C\}$ã«ãå«ãŸããŸãã
</p>
<p>
$W$ãš$H$ãäžãããããç¹ã®éãŸã$D_1, D_2, ..., D_N$ããããã«å«ãŸããç¹ãé ç¹ãšããäžè§åœ¢ã®åæ°ã$t_1, t_2, ..., t_N$ãšãããšããäžè§åœ¢ã®åæ°ã®å$t_1+t_2+...+t_N$ãèšç®ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$W$ $H$
</pre>
<p>
ïŒè¡ã«$W$ãš$H$ ($1 \leq W,H \leq 1,000$)ãäžããããã
</p>
<h2>åºå</h2>
<p>
ããããã®ç¹ã®éãŸãã«å«ãŸããäžè§åœ¢ã®åæ°ã®åã1,000,000,007ã§å²ã£ãäœããïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
1 1
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
8
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
1 2
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
144
</pre>
<h3>å
¥åäŸïŒ</h3>
<pre>
100 100
</pre>
<h3>åºåäŸïŒ</h3>
<pre>
879128399
</pre>
| [
[
"1 1\n",
"1 1\n"
]
] |
p00422 | Resource of the Planet Yanaizu | <h1>ææã€ãã€ã
ã®è³æº</h1>
ã<p>
人é¡ã¯ã€ãã«ç¥ççåœäœã®ååšããææã€ãã€ã
ãçºèŠãããææã€ãã€ã
ã§ã¯ç§åŠãé²æ©ããŠããã®ã§ã次第ã«æã
ãšã®å
±åç 究ãçãã«ãããªãããããã«ãªã£ãã
</p>
<p>
ææã€ãã€ã
ã§ã¯ãã³ãšããè«ãéèŠãªè³æºãšã¿ãªãããŠããããã³ã¯å¹Œè«ãããåããŠæè«ã«ãªãããã³ã®çæ¯åã§ã¯ãã³ã®å¹Œè«ã矀ããŠçæ¯ããŠãã矀çãããã€ãããããã®ãããªçŸ€çãäžåã«äžŠãã§ãããææã€ãã€ã
ã®ãã€ãªãã¯ãããžãŒã䜿ããšã矀çã«å¯ŸããŠä»¥äžã®ãããªæäœãã§ããã
</p>
<ul>
<li> æå®ããç¯å²ã®ãã¹ãŠã®çŸ€çã«ãåãæ°ã®å¹Œè«ãè¿œå ããã</li>
<li> æå®ããç¯å²ã®ãã¹ãŠã®çŸ€çã§ãæå®ããæ°ã®å¹Œè«ãæè«ã«ãåããããåãã幌è«ã®æ°ã®åèšãæ±ããããã®ãšãããåããã幌è«ã®æ°ãäžã€ã ãæå®ã§ããã</li>
</ul>
<p>
ïŒã€ç®ã®æäœã§ã¯ãæå®ããæ°ããã幌è«ã®æ°ãå°ãªã矀çã«ã€ããŠã¯ããã®çŸ€çã«ãããã¹ãŠã®å¹Œè«ããåããããããšãã°ã矀çïŒã«å¹Œè«ãïŒå¹ã矀çïŒã«å¹Œè«ãïŒå¹ããå Žåã矀çïŒããïŒã®ç¯å²ã«å¯ŸããŠãåãããæ°ïŒãæå®ãããšã矀çïŒããã¯ïŒå¹ã矀çïŒããã¯ïŒå¹ãæè«ã«ããããšã«ãªãããã®ãšãã«ãåãã幌è«ã®æ°ã®åèšã¯ïŒå¹ã§ããã
</p>
<p>
ä»åã®å
±åç 究ã§ã¯ãæã
人é¡ããã³ã®å¹Œè«ã«å¯Ÿãããããã®æäœã®ã·ãã¥ã¬ãŒã·ã§ã³ãæ
åœããããšãšãªã£ããããã¯æã
ã®ç§åŠã®åã瀺ããšãã§ããã
</p>
<p>
å矀çã«ååšãã幌è«ã®æ
å ±ãäžãããããšãããããã«å¯Ÿããæäœãã·ãã¥ã¬ãŒã·ã§ã³ããããã°ã©ã ãäœæããã
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããã
</p>
<pre>
$N$
$c_1$
$c_2$
:
$c_N$
$M$
$manip_1$
$manip_2$
:
$manip_M$
</pre>
<p>
ïŒè¡ç®ã«çŸ€çã®æ°$N$ ($1 \leq N \leq 100,000$)ãäžãããããç¶ã$N$è¡ã«ãå矀çã«ãã幌è«ã®æ°$c_i$ ($0 \leq c_i \leq 100,000$)ãäžããããã
</p>
<p>â
ç¶ãïŒè¡ã«ãæäœã®æ°$M$ ($1 \leq M \leq 100,000$)ãäžãããããç¶ã$M$è¡ã«æäœã®å
容ãäžãããããåæäœã®å
容ã¯æ¬¡ã®ããããã§ããã
</p>
<pre>
1 $a$ $b$ $d$
</pre>
<p>
ãŸãã¯
</p>
<pre>
2 $a$ $b$ $d$
</pre>
<p>
å
é ã®æ°åã1ã®ãšããæå®ããç¯å²$a$ãã$b$ ($1 \leq a \leq b \leq N$)ã®çŸ€çã«å¯ŸããŠã幌è«ã$d$å¹($1 \leq d \leq 1,000$)è¿œå ãããå
é ã®æ°åã2ã®ãšããæå®ããç¯å²$a$ãã$b$ ($1 \leq a \leq b \leq N$)ã®çŸ€çã«å¯ŸããŠã幌è«ã$d$å¹($1 \leq d \leq 1,000$)ã ãæè«ã«ãåãããæäœãè¡šãããã®ãšããå®éã«ãåãã幌è«ã®åèšãåºåããããŸããå
é ã®æ°åã2ã§ããæäœã¯å¿
ãã²ãšã€ä»¥äžäžãããããã®ãšããã
</p>
<h2>åºå</h2>
<p>
幌è«ããåãããæäœããšã«ãå®éã«ãåãã幌è«ã®åèšãïŒè¡ã«åºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ<h3>
<pre>
3
1
2
3
3
2 1 3 2
1 1 2 5
2 2 3 3
</pre>
<h3>åºåäŸ<h3>
<pre>
5
4
</pre>
| [
[
"",
""
]
] |
p00423 | Card Game |
<H1><!-- Card Game--></H1>
<p>
A ãš B ã® 2 人ã®ãã¬ãŒã€ãŒãïŒ 0 ãã 9 ãŸã§ã®æ°åãæžãããã«ãŒãã䜿ã£ãŠã²ãŒã ãè¡ãïŒæåã«ïŒ 2 人ã¯äžãããã n æãã€ã®ã«ãŒããïŒè£åãã«ããŠæšªäžåã«äžŠã¹ãïŒãã®åŸïŒ 2 人ã¯åèªã®å·Šãã 1 æãã€ã«ãŒããè¡šåãã«ããŠããïŒæžãããæ°åã倧ããæ¹ã®ã«ãŒãã®æã¡äž»ãïŒãã® 2 æã®ã«ãŒããåãïŒãã®ãšãïŒãã® 2 æã®ã«ãŒãã«æžãããæ°åã®åèšãïŒã«ãŒããåã£ããã¬ãŒã€ãŒã®åŸç¹ãšãªããã®ãšããïŒãã ãïŒéãã 2 æã®ã«ãŒãã«åãæ°åãæžãããŠãããšãã«ã¯ïŒåŒãåããšãïŒåãã¬ãŒã€ãŒãèªåã®ã«ãŒãã 1 æãã€åããã®ãšããïŒ
</p>
<p>
äŸãã°ïŒ AïŒB ã®æã¡æãïŒä»¥äžã®å
¥åäŸ 1 ãã 3 ã®ããã«äžŠã¹ãããŠããå ŽåãèãããïŒãã ãïŒå
¥åãã¡ã€ã«ã¯ n + 1 è¡ãããªãïŒ 1 è¡ç®ã«ã¯åãã¬ãŒã€ã®ã«ãŒãææ° n ãæžãããŠããïŒ i + 1 è¡ç®ïŒi = 1ïŒ2ïŒ... ïŒnïŒã«ã¯ A ã®å·Šãã i æç®ã®ã«ãŒãã®æ°åãš B ã®å·Šãã i æç®ã® ã«ãŒãã®æ°åãïŒç©ºçœãåºåãæåãšããŠãã®é ã§æžãããŠããïŒããªãã¡ïŒå
¥åãã¡ã€ã«ã® 2 è¡ç®ä»¥éã¯ïŒå·ŠåŽã®åã A ã®ã«ãŒãã®äžŠã³ãïŒå³åŽã®åã B ã®ã«ãŒãã®äžŠã³ãïŒããããè¡šããŠããïŒãã®ãšãïŒã²ãŒã çµäºåŸã® A ãš B ã®åŸç¹ã¯ïŒããããïŒå¯Ÿå¿ããåºåäŸã«ç€ºãããã®ãšãªãïŒ
</p>
<p>
ãå
¥åãã¡ã€ã«ã«å¯Ÿå¿ããã²ãŒã ãçµäºãããšãã® A ã®åŸç¹ãš B ã®åŸç¹ãïŒãã®é ã«ç©ºçœãåºåãæåãšã㊠1 è¡ã«åºåããããã°ã©ã ãäœæããªããïŒãã ãïŒ n ≤ 10000 ãšããïŒ
</p>
<!--
<p>
ã¢ããããŒãããåºåãã¡ã€ã«ã«ãããŠã¯ãåºåã®åŸïŒBã®åŸç¹ã®åŸïŒã«æ¹è¡ãå
¥ããããšã
</p>
-->
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td>3</td><td>3</td><td>3</td></tr>
<tr><td>9 1</td><td>9 1</td><td>9 1</td></tr>
<tr><td>5 4</td><td>5 4</td><td>5 5</td></tr>
<tr><td>0 8</td><td>1 0</td><td>1 8</td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>19 8</td><td>20 0</td><td>15 14</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãA ã®åŸç¹ãš B ã®åŸç¹ãïŒè¡ã«åºåããïŒ
</p>
<h3>å
¥åäŸ</h3>
<pre>
3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0
</pre>
<h3>åºåäŸ</h3>
<pre>
19 8
20 0
15 14
</pre>
<p>
åããŒã¿ã»ããã®åºåã®åŸïŒBã®åŸç¹ã®åŸïŒã«æ¹è¡ãå
¥ããããšã
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n",
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n"
]
] |
p00424 | Data Conversion |
<H1></H1>
<p>
äžããããå€æè¡šã«ããšã¥ãïŒããŒã¿ãå€æããããã°ã©ã ãäœæããªããïŒ
</p>
<p>
ããŒã¿ã«äœ¿ãããŠããæåã¯è±åãæ°åã§ïŒè±åã¯å€§æåãšå°æåãåºå¥ããïŒå€æè¡šã«çŸããæåã®é åºã«èŠåæ§ã¯ãªãïŒ
</p>
<p>
å€æè¡šã¯ç©ºçœãã¯ããã§åãšåŸãã® 2 ã€ã®æåããã(æååã§ã¯ãªã)ïŒå€ææ¹æ³ã¯ïŒå€æè¡šã®ããè¡ã®åã®æåãããŒã¿ã«çŸãããïŒãã®ãã³ã«ãã®æåãåŸãã®æåã«å€æãåºåããïŒå€æ㯠1 床ã ãã§ïŒå€æããæåããŸãå€æ察象ã®æåã«ãªã£ãŠãå€æããªãïŒå€æè¡šã«çŸããªãæåã¯å€æããïŒãã®ãŸãŸåºåããïŒ
</p>
<p>
å
¥åãã¡ã€ã«ã«ã¯ïŒå€æè¡šïŒæåã® n + 1 è¡ïŒã«ç¶ãå€æããããŒã¿ïŒn + 2 è¡ç®ä»¥éïŒãæžããŠããïŒ 1 è¡ç®ã«å€æè¡šã®è¡æ° nïŒç¶ã n è¡ã®åè¡ã¯ïŒç©ºçœãã¯ãã㧠2 ã€ã®æåïŒããã«ç¶ããŠïŒ n + 2 è¡ç®ã«å€æããããŒã¿ã®è¡æ° mïŒç¶ã m è¡ã®åè¡ã¯ 1 æåã§ããïŒ m ≤ 10<sup>5</sup> ãšããïŒåºåã¯ïŒåºåäŸã®ããã«éäžã«ç©ºçœãæ¹è¡ã¯å
¥ãã 1 è¡ãšããïŒ
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸ</th>
</tr>
<tr><td>3</td></tr>
<tr><td>A a</td></tr>
<tr><td>0 5</td></tr>
<tr><td>5 4</td></tr>
<tr><td>10</td></tr>
<tr><td>A</td></tr>
<tr><td>B</td></tr>
<tr><td>C</td></tr>
<tr><td>0</td></tr>
<tr><td>1</td></tr>
<tr><td>4</td></tr>
<tr><td>5</td></tr>
<tr><td>a</td></tr>
<tr><td>b</td></tr>
<tr><td>A</td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸ</th>
</tr>
<tr><td>aBC5144aba</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãå€æåŸã®æååãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
3
A a
0 5
5 4
10
A
B
C
0
1
4
5
a
b
A
3
A a
0 5
5 4
10
A
B
C
0
1
4
5
a
b
A
0
</pre>
<H2>åºåäŸ</H2>
<pre>
aBC5144aba
aBC5144aba
</pre>
<p>
åããŒã¿ã»ããã®åºåïŒå€æåŸã®æååïŒã®åŸã«æ¹è¡ãå
¥ããããšïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0\n",
"3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0\n"
]
] |
p00425 | Dice |
<H1></H1>
<p>
ãµã€ã³ãã以äžã®å³ã®ãããªåãã§çœ®ãããŠããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_base">
</center>
<br>
<p>
ããã§äœ¿çšãããµã€ã³ãã¯ïŒãã®å³ã®ããã«ïŒäžåŽã« 1ïŒååŽã« 2 ããããšãã¯ïŒæ±åŽã« 3 ããããã®ãšããïŒãµã€ã³ãã®åããããé¢ã®åã¯å¿
ã 7 ãªã®ã§ïŒèŠããªãé¢ã¯ããããååŽ 5ïŒè¥¿åŽ 4ïŒäžåŽ 6 ã«ãªã£ãŠããïŒ
</p>
<p>
ããã®åæé
眮ã®ç¶æ
ããæ瀺ã«åŸã£ãŠãµã€ã³ããåãããŠããïŒãã ãïŒæ瀺ã¯ä»¥äžã® 6 éãã®æäœãäœåãè¡ããã®ã§ããïŒ
</p>
<center>
<table>
<tr>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_north"></td>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_east"></td>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_west"></td>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_south"></td>
</tr>
<tr>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_right"></td>
<td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t3-fig_left"></td>
<td></td>
<td></td>
</tr>
</table>
</center>
<br/>
<p>
NorthïŒEastïŒSouthïŒWest ã®åæäœã¯æ瀺ãããæ¹åãžãµã€ã³ãã 90 床å転ãããïŒ
ãRightïŒLeft ã® 2 ã€ã®æäœã¯äžäžã®é¢ã¯ãã®ãŸãŸã§æ°Žå¹³æ¹åã« 90 床å転ãããïŒïŒå転ãããåãã«èŠæ³šæïŒïŒ
</p>
<p>
ãåæé
眮ã§äžã®é¢ã«åºãŠããç® 1 ãåæå€ãšãïŒ 1 åã®æäœãçµãããã³ã«ïŒäžã®é¢ã«åºãŠããç®ã®æ°ãå ç®ããŠããïŒæ瀺ã«ãããã£ãŠãã¹ãŠã®æäœãçµãããšãã®åèšå€ãåºåããããã°ã©ã ãäœæããªãã.
</p>
<p>
ãå
¥åãã¡ã€ã«ã® 1 è¡ç®ã«ã¯ç·æ瀺åæ° n ãæžãããŠããŠïŒç¶ã n è¡ã®åè¡ã«ã¯ãNorthïŒEastïŒSouthïŒWestïŒRightïŒLeftãã®ãããã 1 ã€ã®æ瀺ãæžãããŠãããã®ãšããïŒãã ãïŒ n ⊠10000 ãšããïŒ
</p>
<!--
<p>
ã¢ããããŒãããåºåãã¡ã€ã«ã«ãããŠã¯ãåºåïŒåèšå€ïŒã®åŸã«æ¹è¡ãå
¥ããããšã
</p>
-->
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th><th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td>5</td><td>8</td></tr>
<tr><td>North</td><td>West</td></tr>
<tr><td>North</td><td>North</td></tr>
<tr><td>East</td><td>Left</td></tr>
<tr><td>South</td><td>South</td></tr>
<tr><td>West</td><td>Right</td></tr>
<tr><td></td><td>North</td></tr>
<tr><td></td><td>Left</td></tr>
<tr><td></td><td>East</td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th> <th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>21</td><td>34</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãåèšå€ãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0
</pre>
<H2>åºåäŸ</H2>
<pre>
21
34
</pre>
<p>
åããŒã¿ã»ããã®åºåïŒåèšå€ïŒã®åŸã«æ¹è¡ãå
¥ããããšã
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\nNorth\nNorth\nEast\nSouth\nWest\n8\nWest\nNorth\nLeft\nSouth\nRight\nNorth\nLeft\nEast\n0\n",
"5\nNorth\nNorth\nEast\nSouth\nWest\n8\nWest\nNorth\nLeft\nSouth\nRight\nNorth\nLeft\nEast\n0\n"
]
] |
p00426 | Cup |
<H1></H1>
<p>
倧ãããç°ãªã n åã®ã³ãããš 3 ã€ã®ãã¬ã€ïŒãçïŒAïŒBïŒC ãããïŒãããã®ã³ãã㯠3 ã€ã®ãã¬ã€ã®äžã«ããããäœåããã€äžå±±ã«éããŠçœ®ãããŠããïŒãã ãïŒã©ã®ãã¬ã€ã«ãããŠãïŒãã®ãã¬ã€ã®äžã§äžçªå°ããã³ãããäžçªäžã«ïŒ 2 çªç®ã«å°ããã³ããããã®äžã«ïŒ 3 çªç®ã«å°ããã³ããããã®äžã«ãšïŒå°ããé ã«äŒããŠéããŠããïŒäŸãã°ïŒäžå³ã®å³åŽã¯ïŒ n = 5 åã®ã³ããããã¬ã€ AïŒBïŒC ã«ãããã 2 åïŒ0 åïŒ3 åéããŠçœ®ãããŠããç¶æ
ã瀺ããŠããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t4-fig1">
</center>
<br/>
<p>
ãã®ããã«ïŒã³ããã®åæç¶æ
ãäžãããããšãïŒæ¬¡ã®èŠå 1 ã 3 ãå®ããªããïŒãã¹ãŠã®ã³ããã A ãŸã㯠C ã®ã©ã¡ããã®ãã¬ã€ã«ç§»åãããã«ã¯äœå移åãè¡ãã°ããããæ±ãããïŒ
</p>
<p>
ïŒèŠå 1ïŒ 1 åã« 1 ã€ã®ã³ããã ãã移åãããããšãã§ããïŒããã¯ïŒãã®ãã¬ã€ã«ããã³ããã®äžã§äžçªäžã®ã³ããïŒã€ãŸãïŒäžçªå€§ããã³ããïŒã§ããïŒ
</p>
<p>
ïŒèŠå 2ïŒå€§ããã³ããã®äžã«å°ããã³ãããéããŠã¯ãããªãïŒ
</p>
<p>
ïŒèŠå 3ïŒã³ãã 1 åã®çŽæ¥ç§»åã¯ïŒãã¬ã€ A ãã BïŒB ãã AïŒB ãã CïŒC ãã B ã®ã¿ãèš±ããïŒ A ãã C ãžã®çŽæ¥ç§»åã C ãã A ãžã®çŽæ¥ç§»åã¯èš±ãããªãïŒ
</p>
<p>
ãn åã®ã³ããã®åæç¶æ
ãšæŽæ° m ãäžãããããšãïŒ m å以å
ã®ç§»åã§ïŒ A ãŸã㯠C ã®ã©ã¡ããã®ãã¬ã€ã«ãã¹ãŠã®ã³ããããŸãšããŠéããããšãã§ãããã©ãããå€å®ãïŒå¯èœãªå Žåã«ã¯ç§»ååæ°ã®æå°å€ãïŒäžå¯èœãªå Žåã«ã¯ -1 ãåºåããããã°ã©ã ãäœæããªããïŒ
</p>
<p>
ãå
¥åãã¡ã€ã«ã® 1 è¡ç®ã«ã¯ïŒ n ãš m ããã®é ã«ç©ºçœãåºåãæåãšããŠæžããŠããïŒ 1 ⊠n ⊠15 ã§ããïŒ 1 ⊠m ⊠15000000 ã§ããïŒ 2 è¡ç®ïŒ3 è¡ç®ïŒ4 è¡ç®ã«ã¯ïŒ 1 ãã n ãŸã§ã®æŽæ°ãäœåãã〠3 ã€ã®ã°ã«ãŒãã«åããŠïŒããããã®ã°ã«ãŒãå
ã§å°ããé ïŒæé ïŒã«äžŠã¹ããã®ãæžããŠããïŒãã ãïŒåè¡ã®å
é ïŒãããã®æŽæ°ã®åïŒã«ã¯ïŒãããã®åæ°ãæžããŠããïŒ 2 è¡ç®ã«æžãããŠããæŽæ°ïŒå
é ã® 1 ã€ãé€ãïŒã¯ãã¬ã€ A ã®äžã«éããããŠããåã³ããã®å€§ãããè¡šãïŒåæ§ã«ïŒ 3 è¡ç®ã«æžãããŠããæŽæ°ïŒå
é ã® 1 ã€ãé€ãïŒã¯ãã¬ã€ B ã®äžã«éããããŠããåã³ããã®å€§ãããè¡šãïŒ 4 è¡ç®ã«æžãããŠããæŽæ°ïŒå
é ã®ïŒã€ãé€ãïŒã¯ãã¬ã€ C ã®äžã«éããããŠããåã³ããã®å€§ãããè¡šãïŒ
</p>
<!--
<p>
ã¢ããããŒãããåºåãã¡ã€ã«ã«ãããŠã¯ïŒåºåïŒç§»ååæ°ãŸã㯠-1ïŒã®åŸã«æ¹è¡ãå
¥ããããšïŒ
</p>
-->
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>3 10</td><td>4 20 </td><td>2 5</td><td>3 3</td></tr>
<tr><td>0</td><td>2 1 2</td><td>2 1 2</td><td>0</td></tr>
<tr><td>1 1</td><td>1 3</td><td>0</td><td>1 1</td></tr>
<tr><td>2 2 3</td><td>1 4</td><td>0</td><td>2 2 3</td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>9</td><td>3</td><td>0</td><td>-1</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn, m ããšãã« 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ã移ååæ°ãŸã㯠-1 ãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
3 10
0
1 1
2 2 3
4 20
2 1 2
1 3
1 4
2 5
2 1 2
0
0
3 3
0
1 1
2 2 3
0 0
</pre>
<H2>åºåäŸ</H2>
<pre>
9
3
0
-1
</pre>
<p>
åããŒã¿ã»ããã®åºåïŒç§»ååæ°ãŸã㯠-1ïŒã®åŸã«æ¹è¡ãå
¥ããããšïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n",
"3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n"
]
] |
p00427 | Card Game II |
<H1></H1>
<p>
次ã®ãããªã²ãŒã ãèããïŒ 1 ãã n ãŸã§ã®æ°ã 1 ã€ãã€æžããã n æã®ã«ãŒãã k çµããïŒããã kn æã®ã«ãŒããããã·ã£ããã«ïŒããåãããšïŒããŠïŒ k æãã€ã®å±±ãäœã暪äžåã«äžŠã¹ãïŒãã®ããã«ããŠã§ãã n åã®å±±ã®å·Šãã i çªç®ã®ïŒk æã®ã«ãŒãã®ïŒå±±ããå±± i ããšåŒã¶ããšã«ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t5-fig_base">
</center>
<br>
<p>
ã²ãŒã ã¯å±± 1 ããå§ããïŒå±±ã®äžçªäžã®ã«ãŒã 1 æãåŒãïŒåŒããã«ãŒãã¯å
ã®å±±ã«æ»ããªãïŒïŒãã®ã«ãŒãã«æžãããŠããæ°ã i ã ã£ãå Žåã«ã¯å±± i ã®äžçªäžã®ã«ãŒã 1 æãåŒãïŒãã®ããã«ããŠïŒåŒããã«ãŒãã«æžãããŠããæ°ãçªå·ãšããå±±ã®äžçªäžã®ã«ãŒã 1 æãåŒãããšãç¹°ãè¿ãïŒãã¹ãŠã®å±±ã«ã«ãŒããç¡ããªãã°æåã§ããïŒãŸã ã«ãŒããæ®ã£ãŠããå±±ãããã®ã«ïŒæ¬¡ã«ã«ãŒããåŒãã¹ãå±±ãç¡ããªã£ãŠããå Žåã¯å€±æã§ããïŒ
</p>
<p>
ãéäžã§å€±æããå Žåã«ã¯ïŒãã®ãŸãŸå€±æã§çµäºãããïŒãŸãã¯æ®ã£ãã«ãŒãã®å±±ããã®ãŸãŸïŒå±±ã®çªå·ããã®ãŸãŸïŒã«ããŠã²ãŒã ãåéããïŒã²ãŒã ãåéããå Žåã¯ïŒæåã«åŒãã«ãŒãã¯ã«ãŒããæ®ã£ãŠããå±±ã®ãã¡ã®äžçªå·Šã®å±±ãããšããïŒãã®å±±ã®äžçªäžã®ã«ãŒããæåã«åŒãããã«ãŒããšãªãïŒïŒåéåŸãåéåãšåæ§ã®æ¹æ³ã§ã²ãŒã ãé²ãïŒãã¹ãŠã®å±±ã«ã«ãŒããç¡ããªãã°æåã§ããïŒãŸã ã«ãŒããæ®ã£ãŠããå±±ãããã®ã«ïŒæ¬¡ã«ã«ãŒããåŒãã¹ãå±±ãç¡ããªã£ãå Žåã¯å€±æã§ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2006-yo-t5-fig_sample">
</center>
<br>
<p>
ãã®ãããªã²ãŒã ã®åéãæ倧 m åãŸã§è¡ããã®ãšããïŒãã ãïŒm 㯠0 ã 1 ã§ããïŒã€ãŸãïŒ 1 åãåéããªããïŒ 1 åã ãåéãããã®ããããã§ããïŒã²ãŒã éå§åã®ã·ã£ããã«ã®ä»æ¹ã«ããã«ãŒãã®åæé
眮ã¯ç°ãªãïŒåœç¶ïŒã«ãŒãã®åæé
眮ã«ããïŒåéããã«æåããããšãããã°ïŒåéããŠæåããããšãïŒåéããŠå€±æããããšãããïŒååã·ã£ããã«ããŠããã®ã§ïŒã©ã®åæé
眮ãå
šãŠåã確çã§çŸãããã®ãšèããããšã«ããŠïŒåéã m å以å
ã§æåãã確ç p ãæ±ãããïŒãã®ç¢ºç p ãå°æ°ã§è¡šãïŒå°æ°ç¬¬ r äœãŸã§æ±ããŠåºåããããã°ã©ã ãäœããªããïŒãã ãïŒæ¬¡ã®æ¡ä»¶ãæºããããã«åºåããããš.
</p>
<ul>
<li> åå倧ããæ£æŽæ° K ãåããš pÃ10K ã æŽæ°ãšãªãå ŽåïŒ å°æ°éšã¯éäžãã 0 ãç¶ããïŒãã® 0 ãåºåããããšïŒ äŸãã°ïŒ p = 3/8 = 0.375 ã®å ŽåïŒ r = 5 ãªã 0.37500 ãšåºåãïŒ r = 2 ãªã 0.37 ãšåºåããïŒ p = 1.0 ã®å Žåãåæ§ã«ïŒ äŸãã° r = 3 ãªã 1.000 ãšåºåããããšïŒ</li>
<li> äŸãã° 0.150000⊠ã¯åŸªç°å°æ° 0.1499999⊠ãšããŠè¡šãããšãã§ãããïŒ ãã®ãããªå ŽåïŒ åè
ã®è¡šãæ¹ãçšããïŒ </li>
</ul>
<p>
å
¥åãã¡ã€ã«ã® 1 è¡ç®ã«ã¯æŽæ° nïŒkïŒmïŒr ããã®é ã«ç©ºçœãåºåãæåãšããŠæžããŠããïŒ 1 ⊠n ⊠10000ïŒ 1 ⊠k ⊠100ïŒ m = 0 ãŸã㯠m = 1ïŒ 1 ⊠r ⊠10000 ã§ããïŒ
</p>
<!--
<p>
ãã¢ããããŒãããåºåãã¡ã€ã«ã«ãããŠã¯ïŒæå®éãã«åºåãã p ã®åŸã«æ¹è¡ãå
¥ããããšïŒ
</p>
-->
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>2 1 0 5</td><td>3 1 1 3</td><td>2 2 1 3</td><td></td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>0.50000</td><td>0.833</td><td>1.000</td><td></td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn, k, m, r ããã¹ãŠ 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãæå®éãã« p ãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
2 1 0 5
3 1 1 3
2 2 1 3
0 0 0 0
</pre>
<H2>åºåäŸ</H2>
<pre>
0.50000
0.833
1.000
</pre>
<p>
åããŒã¿ã»ããã«ã€ããŠïŒæå®éãã«åºåãã p ã®åŸã«æ¹è¡ãå
¥ããããšïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"2 1 0 5\n3 1 1 3\n2 2 1 3\n0 0 0 0\n",
"2 1 0 5\n3 1 1 3\n2 2 1 3\n0 0 0 0\n"
]
] |
p00428 | Questionnaire |
<H1></H1>
<p>
ããåŠæ ¡ã§ä¿®åŠæ
è¡ãžè¡ãèšç»ããã.ãã®ããã«ã¢ã³ã±ãŒã調æ»ãè¡ã£ã.
çåŸã¯ 1 ãã <i>n</i> ãŸã§ã®çåŸçªå·ãæã¡,æ
è¡åè£ã®å Žæã 1 ãã <i>m</i> ãŸã§ã®çªå·ã§è¡šã,è¡ãããå Žæã« â,è¡ããããªãå Žæã«Ãã®å°ãã€ããŠæåºããŠãã.
</p>
<p>
ãã®ãšã, è¡ãããå Žæã®äººæ°ãå€ãé ã«,å Žæã®çªå·ãåºåããããã°ã©ã ãäœæãã.人æ°ãåããšãã¯,å Žæã®çªå·é ãšãã.
</p>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠âinput.txtâ ã§ãã. âinput.txtâ ã® 1 è¡ç®ã¯çåŸã®äººæ° <i>n</i> ãšæ
è¡åè£ã®å Žæã®æ° <i>m</i> ã空çœã§åºåãã, <i>i</i> + 1 è¡ã«çåŸ <i>i</i> ã®ã¢ã³ã±ãŒãçµæã â 㯠1 ã§Ã㯠0 ã§è¡šã,空çœã§åºåããã <i>m</i> åã®æ°åã䞊ãã§ãã.1 ≤ <i>n</i> ≤ 1000, 1 ≤ <i>m</i> ≤ 100 ãšãã.
</p>
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠âoutput.txtâ ã§ãã.âoutput.txtâ ã«ãããŠã¯,åºå(å Žæã®çªå·)ã®åŸã«æ¹è¡ãå
¥ããããš.
</p>
-->
<p>
å
¥åããŒã¿ ã® 1 è¡ç®ã¯çåŸã®äººæ° <i>n</i> ãšæ
è¡åè£ã®å Žæã®æ° <i>m</i> ã空çœã§åºåãã, <i>i</i> + 1 è¡ã«çåŸ <i>i</i> ã®ã¢ã³ã±ãŒãçµæã â 㯠1 ã§Ã㯠0 ã§è¡šã,空çœã§åºåããã <i>m</i> åã®æ°åã䞊ãã§ãã.1 ≤ <i>n</i> ≤ 1000, 1 ≤ <i>m</i> ≤ 100 ãšãã.
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr>
<td>4 6<br>
1 0 1 0 1 1<br>
1 1 0 1 0 0<br>
1 1 1 0 0 0<br>
1 0 1 0 1 0<br>
</td>
</tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr>
<td>1 3 2 5 4 6</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn, m ããšãã« 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãå Žæã®çªå· ãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
4 6
1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0
1 0 1 0 1 0
4 6
1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0
1 0 1 0 1 0
0 0
</pre>
<H2>åºåäŸ</H2>
<pre>
1 3 2 5 4 6
1 3 2 5 4 6
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n",
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n"
]
] |
p00429 | String |
<H1></H1>
<p>
0 ãã 9 ãŸã§ã®æ°åã ãã§æ§æãããæååãäžãããããšã,ãã®æååãã次ã®èŠåã«åŸã£ãŠæ°ããæååãäœãæäœãèãã.äžããããæååã巊端ãã1æåãã€é ã«èªãã§è¡ã,åãæ°å <i>a</i> ã <i>r</i> åç¶ããŠããå Žå,åæ° <i>r</i> ãšæ°å<i>a</i> ã空çœã§åºåããã«ãã®é ã§æžãåºã.äžããããæååã®å³ç«¯ãŸã§èªã¿,æåŸã®æžãåºããçµãã£ããšãããŸã§ãéäžäœåæžãåºãããã£ããšããŠãå
šéšãŸãšããŠæäœ1åãšã«ãŠã³ããã.2åç®ä»¥éã®æäœã¯ååã®æäœã«ããæžãåºãããæååãäžããããæååãšããŠåæ§ã®æäœãå®æœãã.äŸãã° â<span>122244</span>â ãšããæååãäžããããå Žåã«ã¯å·Šç«¯ããé ã«1åã®1, 3åã®2,2åã®4ãªã®ã§ãã®æäœ1åã§åŸãããæåå㯠â<span>113224</span>â ã§ãã,â<span>44444444444</span>â (11 åã®4)ã®å Žåã«ã¯åŸãããæåå㯠â<span>114</span>â ãšãªã.
</p>
<p>
100 æå以äžã®äžããããæååã«äžã®æäœã <i>n</i> åå®æœããæååãåºåããããã°ã©ã ãäœæãã.ãã ã, <i>n</i> ≤ 20 ãšãã.
</p>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠âinput.txtâ ã§ãã. âinput.txtâ 㯠2 è¡ãããªã,1 è¡ç®ã«æäœåæ° <i>n</i>, 2 è¡ç®ã«æåã®æååãæžãããŠãã.
</p>
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠âoutput.txtâ ã§ãã.âoutput.txtâ 㯠1 è¡ã§ãã, æå®ãããåæ°ã®æäœãæœããæååã®åŸã«æ¹è¡ãå
¥ããããš.
</p>
-->
<p>
å
¥åããŒã¿ 㯠2 è¡ãããªã,1 è¡ç®ã«æäœåæ° <i>n</i>, 2 è¡ç®ã«æåã®æååãæžãããŠãã.
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸ</th>
</tr>
<tr><td></td></tr>
<tr>
<td>5<br>
11</td>
</tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸ</th>
</tr>
<tr><td>13112221
</td>
</tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãæå®ãããåæ°ã®æäœãæœããæåå ãïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
5
11
5
11
0
</pre>
<H2>åºåäŸ</H2>
<pre>
13112221
13112221
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"5\n11\n5\n11\n0\n",
"5\n11\n5\n11\n0\n"
]
] |
p00430 | Square |
<H1></H1>
<p>
åã倧ããã®æ£æ¹åœ¢ã®çŽã <i>n</i> æãã.ãããã®çŽã®äžéšãæ°Žå¹³ã«æããŠäœåãã«äžŠã¹ã.ãã ã,é£ãåãåã¯å·ŠåŽãå³åŽããäœããªããªãããã«äžŠã¹ãªããã°ãªããªã.äŸãã°, <i>n</i> = 5 ã®ãšãã¯,次ã®ãã㪠7 éãã®äžŠã¹æ¹ãå¯èœã§ãã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ioi2006ho3">
</center>
<br>
<p>
ãããã,ååã«äžŠãã æ£æ¹åœ¢ã®åæ°ã®åã§è¡šãããšã«ãã.äŸãã°, <i>n</i> = 5 ã®
ãšãã¯,ãããã,<br>
<br>
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)<br>
<br>
ãšè¡šãããã.
</p>
<p>
<i>n</i> ãå
¥åãããšã, èŸæžåŒé åºã§å
šãŠåºåããããã°ã©ã ãäœæãã.<i>n</i> ≤30
ãšãã.ãã ã, èŸæžåŒé åºãšã¯2ã€ã®äžŠã¹æ¹ (<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub> , ..., <i>a</i><sub><i>s</i></sub>) ã䞊ã¹æ¹ (<i>b</i><sub>1</sub>, <i>b</i><sub>2</sub>, ..., <i>b<sub>t</sub></i> ) ã«å¯ŸããŠ, <i>a</i><sub>1</sub> > <i>b</i><sub>1</sub> ãŸãã¯, ããæŽæ° <i>i</i> > 1 ãååšã㊠<i>a</i><sub>1</sub> = <i>b</i><sub>1</sub> , ..., <i>a</i><sub><i>i</i>-1</sub> = <i>b</i><sub><i>i</i>-1</sub> ã〠<i>a<sub>i</sub></i> > <i>b<sub>i</sub></i> ãæãç«ã€ãšã (<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, ..., <i>a<sub>s</sub></i>) ã (<i>b</i><sub>1</sub> , <i>b</i><sub>2</sub>, ..., <i>b<sub>t</sub></i>) ããå
ã«åºåãããããã«äžŠã¹ãããšã§ãã.
</p>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠âinput.txtâ ã§ãã.âinput.txtâ 㯠1 è¡ãããªã,1 è¡ç®ã« <i>n</i> ãæžãããŠãã.
</p>
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠âoutput.txtâ ã§ãã.âoutput.txtâ ã«ã¯äžŠã¹æ¹ãèŸæžåŒé åºã§ 1 è¡ã«1éããã€æžãæåŸã«æ¹è¡ãå
¥ããããš. 䞊ã¹æ¹ã¯ (<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, ..., <i>a<sub>s</sub></i>) ã®åºåã¯æŽæ° <i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, . . . , <i>a<sub>s</sub></i> ããã®é çªã«ç©ºçœã§åºåã£ãŠåºåããããš.
</p>
-->
<p>
å
¥åããŒã¿ 㯠1 è¡ãããªã,1 è¡ç®ã« <i>n</i> ãæžãããŠãã.
</p>
<p>
åºåã«ã¯äžŠã¹æ¹ãèŸæžåŒé åºã§ 1 è¡ã«1éããã€æžãæåŸã«æ¹è¡ãå
¥ããããš. 䞊ã¹æ¹ã¯ (<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, ..., <i>a<sub>s</sub></i>) ã®åºåã¯æŽæ° <i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, . . . , <i>a<sub>s</sub></i> ããã®é çªã«ç©ºçœã§åºåã£ãŠåºåããããš.
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td></td></tr>
<tr><td>5</td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr>
<td>5<br>
4 1<br>
3 2<br>
3 1 1<br>
2 2 1<br>
2 1 1 1<br>
1 1 1 1 1<br>
</td>
</tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãèŸæžåŒé åºã§å
šãŠåºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
5
5
0
</pre>
<H2>åºåäŸ</H2>
<pre>
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\n5\n0\n",
"5\n5\n0\n"
]
] |
p00431 | String With Rings |
<H1></H1>
<p>
䞡端ã«ãªã³ã°ã®ã€ããçŽãèãã.ãªã³ã°ã¯æ£æŽæ°ãä»ããŠããŠ,çŽãåºå¥ãã.çŽã®äž¡ç«¯ã®ãªã³ã°ã«ã¯ç°ãªãæ° <i>a</i>, <i>b</i> ãä»ãããã.ããã,[<i>a</i>, <i>b</i>] ãšèšè¿°ãã.è€æ°ã®çŽããã,äžæ¹ã®çŽãšä»æ¹ã®çŽã®ãªã³ã°ã«ä»ããŠããæ°ãåãå Žå,ãã®ãªã³ã°ã®ãšããã§,ãããã®çŽãã€ãªããããšãã§ããŠ,ã€ãªããŠã§ãããã®ãéãšåŒã¶ããšã«ãã.äŸãã°,[1, 3] ãš [3, 4] ãšããçŽãã㯠[1, 3, 4] ãšããéãã§ãã.çŽãšéãéåå¿ãåãæŽæ°ãä»ããŠãããªã³ã°ã®ãšããã§ã€ãªããããšãã§ãããã®ãšãã.
</p>
<p>
äŸãã°,é [1, 3, 4] ãšçŽ [5, 1] ãã㯠[5, 1, 3, 4] ãã§ã,é [1, 3, 4] ãšé [2, 3, 5] ããã¯, äžå€®ã§ã¯ãã¹ãããããªåœ¢ã«ãªã.é [1, 3, 4] ãšé [4, 6, 1] ããã¯, 茪ã®åœ¢ãã§ãã.
</p>
<p>
ãã®ããã«æ§ã
ãªåœ¢ãã§ããã, ãã®ãã¡ã®äžéšã§,åãæ°ã®ä»ãããªã³ã°ã¯äžåºŠã ããã©ãã€ãªãã£ãè€æ°ã®çŽãéãšåŒã¶ããšã«ãã.äŸãã°,é [1, 3, 4] ãšé[2, 3, 5] ããã§ãã,äžå€®ã§ã¯ãã¹ãããããªåœ¢ã«ã¯, [1, 3, 5],[2, 3, 4] ãšããéãå«ãŸã,é [1, 3, 4] ãšé [4, 6, 1] ããã§ãã茪ã«ã¯, [1, 3, 4, 6],[3, 4, 6, 1],[4, 6, 1, 3]ãªã©ã®éãå«ãŸãã.
</p>
<p>
ãããã®éã«å¯ŸããŠ,å«ãŸããæ°ã®åæ°ãé·ããšå®çŸ©ãã. äžããããè€æ°ã®çŽã«å¯ŸããŠ,ã€ãªãããããã®ã¯ãã¹ãŠã€ãªãããš1ã€ä»¥äžã®
éãå«ã圢ãã§ãã.ãã®ãã¡ã®æ倧ã®éã®é·ããæ±ããããã°ã©ã ãäœæãã.
</p>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠âinput.txtâ ã§ãã.âinput.txtâ ã®æåã®è¡ã«ã¯çŽã®åæ°ã§ããæ£æŽæ° 1 ≤ <i>n</i> ≤ 100 ãæžããŠãã,ã€ã¥ã <i>n</i> è¡ã®ããããã«ã¯, 空çœã§åºåããã 2 ã€ã®æŽæ° <i>a</i>, <i>b</i> ãæžããŠãã 1 ≤ <i>a</i> < <i>b</i> ≤ 100 ãšãªã£ãŠãã.åè¡ã® 2 ã€ã®æŽæ°ã¯ 1 ã€ã®çŽã®äž¡ç«¯ã®æŽæ°ãè¡šãã.
</p>
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠âoutput.txtâ ã§ãã.âoutput.txtâ ã«ãããŠã¯,åºå(æ倧ã®éã®é·ã)ã®åŸã«æ¹è¡ãå
¥ããããš.
</p>
-->
<p>
å
¥åããŒã¿ ã®æåã®è¡ã«ã¯çŽã®åæ°ã§ããæ£æŽæ° 1 ≤ <i>n</i> ≤ 100 ãæžããŠãã,ã€ã¥ã <i>n</i> è¡ã®ããããã«ã¯, 空çœã§åºåããã 2 ã€ã®æŽæ° <i>a</i>, <i>b</i> ãæžããŠãã 1 ≤ <i>a</i> < <i>b</i> ≤ 100 ãšãªã£ãŠãã.åè¡ã® 2 ã€ã®æŽæ°ã¯ 1 ã€ã®çŽã®äž¡ç«¯ã®æŽæ°ãè¡šãã.
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>7 </td><td>6 </td><td>7 </td></tr>
<tr><td>1 3 </td><td>1 2 </td><td>1 3 </td></tr>
<tr><td>3 4 </td><td>2 3 </td><td>2 4 </td></tr>
<tr><td>1 4 </td><td>3 4 </td><td>3 5 </td></tr>
<tr><td>2 7 </td><td>4 5 </td><td>4 6 </td></tr>
<tr><td>5 7 </td><td>1 5 </td><td>6 7 </td></tr>
<tr><td>6 7 </td><td>2 6 </td><td>2 6 </td></tr>
<tr><td>1 7 </td><td> </td><td>4 7 </td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>5</td><td>6</td><td>4</td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒn ã 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«ãæ倧ã®éã®é·ããïŒè¡ã«åºåããïŒ
</p>
<H2>å
¥åäŸ</H2>
<pre>
7
1 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 5
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0
</pre>
<H2>åºåäŸ</H2>
<pre>
5
6
4
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"7\n1 3\n3 4\n1 4\n2 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 5\n1 5\n2 6\n7\n1 3\n2 4\n3 5\n4 6\n6 7\n2 6\n4 7\n0\n",
"7\n1 3\n3 4\n1 4\n2 7\n5 7\n6 7\n1 7\n6\n1 2\n2 3\n3 4\n4 5\n1 5\n2 6\n7\n1 3\n2 4\n3 5\n4 6\n6 7\n2 6\n4 7\n0\n"
]
] |
p00432 | Sheets |
<H1></H1>
<p>
å¹³é¢ã«é·æ¹åœ¢ã®ã·ãŒããäœæã眮ãããŠãã. ãããã®ã·ãŒãã§èŠãããŠããéšåã®é¢ç©ãåšé·ãæ±ããããã°ã©ã ãäœæãã.
</p>
<p>
ãã ã, å¹³é¢ã座æšå¹³é¢ãšã¿ãªãããšã, ã·ãŒãã®é
眮ã¯æ¬¡ã®æ¡ä»¶ (1), (2) ãæºãããã®ãšãã.
</p>
<p>
(1) åã·ãŒãã®é·æ¹åœ¢ã® 4 é ç¹ã® <i>x</i>, <i>y</i> 座æšã¯å
šãŠ 0 ä»¥äž 10000 以äžã®æŽæ°ã§ãã, é·æ¹åœ¢ã®å蟺㯠<i>x</i> 軞, ãŸã㯠<i>y</i> 軞ã«å¹³è¡ã§ãã.
</p>
<p>
(2) ã·ãŒãã®ææ°ã¯é«ã
10000 æ以äžã§ãã.
</p>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠âinput.txtâ ã§ãã.âinput.txtâ ã® 1 è¡ç®ã«é·æ¹åœ¢ã®åæ° <i>n</i> ãšåé¡ã®çš®é¡ãè¡šãæŽæ° <i>r</i> ã空çœã§åºåã£ãŠæžãããŠãã. 2 è¡ç®ä»¥éã®åè¡ã«ã¯, åã·ãŒãã®å·Šäžé ç¹åº§æš (<i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>) ãšå³äžé ç¹åº§æš (<i>x</i><sub>2</sub>, <i>y</i><sub>2</sub>) ã®åº§æšå€ã <i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>, <i>x</i><sub>2</sub>, <i>y</i><sub>2</sub> ã®é ã§ç©ºçœã§åºåã£ãŠæžããŠãã.
</p>
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠âoutput.txtâ ã§ãã.âoutput.txtâ ã«ã¯ <i>r</i> = 1 ã®ãšã 1 è¡ç®ã«é¢ç©ã, <i>r</i> = 2 ã®ãšã 1 è¡ç®ã«é¢ç©, 2 è¡ç®ã«åšå²ã®é·ããåºåãã. ãããã®å ŽåãæåŸã«æ¹è¡ãå
¥ããããš.
</p>
-->
<p>
å
¥åããŒã¿ ã® 1 è¡ç®ã«é·æ¹åœ¢ã®åæ° <i>n</i> ãšåé¡ã®çš®é¡ãè¡šãæŽæ° <i>r</i> ã空çœã§åºåã£ãŠæžãããŠãã. 2 è¡ç®ä»¥éã®åè¡ã«ã¯, åã·ãŒãã®å·Šäžé ç¹åº§æš (<i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>) ãšå³äžé ç¹åº§æš (<i>x</i><sub>2</sub>, <i>y</i><sub>2</sub>) ã®åº§æšå€ã <i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>, <i>x</i><sub>2</sub>, <i>y</i><sub>2</sub> ã®é ã§ç©ºçœã§åºåã£ãŠæžããŠãã.
</p>
<p>
åºåã«ã¯ <i>r</i> = 1 ã®ãšã 1 è¡ç®ã«é¢ç©ã, <i>r</i> = 2 ã®ãšã 1 è¡ç®ã«é¢ç©, 2 è¡ç®ã«åšå²ã®é·ããåºåãã. ãããã®å ŽåãæåŸã«æ¹è¡ãå
¥ããããš.
</p>
<p>
ãŸã, ãã¹ãããŒã¿ã® 40% ã§ã¯é·æ¹åœ¢ã®é ç¹ã®åº§æšã 0 ä»¥äž 100 以äžã§, ãã®ãã¡ã® 1/2 ã§ã¯é¢ç©ã ããæ±ããåé¡ã§ãã. ããã«, å
šäœã® 1/2 ã¯é¢ç©ã ããæ±ããåé¡ã§ãã.
</p>
<table style="margin-bottom: 28px; margin-left: 28px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
<th width="150" align="left">å
¥åäŸïŒ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>5 1 </td><td>5 2 </td><td>2 2 </td><td>3 2 </td></tr>
<tr><td>0 0 3 2 </td><td>0 0 3 2 </td><td>0 0 8 9 </td><td>2 2 8 8 </td></tr>
<tr><td>1 1 2 5 </td><td>1 1 2 5 </td><td>0 0 9 8 </td><td>3 0 4 9 </td></tr>
<tr><td>0 4 6 5 </td><td>0 4 6 5 </td><td> </td><td>5 0 7 9 </td></tr>
<tr><td>3 3 5 6 </td><td>3 3 5 6 </td><td> </td><td> </td></tr>
<tr><td>5 0 7 6 </td><td>5 0 7 6 </td><td> </td><td> </td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
<th width="150" align="left">åºåäŸïŒ</th>
</tr>
<tr><td>29 </td><td>29 </td><td>80 </td><td>45 </td></tr>
<tr><td> </td><td>38 </td><td>36 </td><td>36 </td></tr>
</table>
<h3>å
¥å</h3>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒ<i>n</i>, <i>r</i> ããšãã« 0 ã®ãšãå
¥åãçµäºããïŒããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h3>åºå</h3>
<p>
ããŒã¿ã»ããããšã«, <i>r</i> = 1 ã®ãšã 1 è¡ç®ã«é¢ç©ã, <i>r</i> = 2 ã®ãšã 1 è¡ç®ã«é¢ç©, 2 è¡ç®ã«åšå²ã®é·ããåºåãã.
</p>
<H2>å
¥åäŸ</H2>
<pre>
5 1
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6
5 2
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6
2 2
0 0 8 9
0 0 9 8
3 2
2 2 8 8
3 0 4 9
5 0 7 9
0 0
</pre>
<H2>åºåäŸ</H2>
<pre>
29
29
38
80
36
45
36
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 1\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n5 2\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n2 2\n0 0 8 9\n0 0 9 8\n3 2\n2 2 8 8\n3 0 4 9\n5 0 7 9\n0 0\n",
"5 1\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n5 2\n0 0 3 2\n1 1 2 5\n0 4 6 5\n3 3 5 6\n5 0 7 6\n2 2\n0 0 8 9\n0 0 9 8\n3 2\n2 2 8 8\n3 0 4 9\n5 0 7 9\n0 0\n"
]
] |
p00433 | Score |
<H1>åŸç¹</H1>
<h2>åé¡</h2>
<p>
JOIé«æ ¡ã®2人ã®çåŸ A ãããš B ããã¯ïŒæ
å ±ïŒæ°åŠïŒçç§ïŒè±èªã®4æç§ã®è©ŠéšãåããïŒ A ãããš B ããã®ããã4æç§ã®åŸç¹ãäžãããããšïŒ Aããã®åèšç¹ S ãš Bããã®åèšç¹ T ã®ãã¡å€§ããªæ¹ãåºåããããã°ã©ã ãäœæããïŒãã ãïŒåç¹ã®å Žå㯠S (= T) ãåºåããïŒ
</p>
<H2>å
¥å</H2>
<p>
<!--å
¥åãã¡ã€ã«ã¯2è¡ãããªãïŒ-->
å
¥åã¯2è¡ãããªãïŒ
</p>
<p>
1è¡ç®ã¯4ã€ã®æŽæ°ã1ã€ã®ç©ºçœãåºåããšããŠæžãããŠããïŒããããé ã«ïŒ A ããã®æ
å ±ã®åŸç¹ïŒæ°åŠã®åŸç¹ïŒçç§ã®åŸç¹ïŒè±èªã®åŸç¹ãè¡šããŠããïŒ
</p>
<p>
2è¡ç®ã¯4ã€ã®æŽæ°ã1ã€ã®ç©ºçœãåºåããšããŠæžãããŠããïŒããããé ã«ïŒ B ããã®æ
å ±ã®åŸç¹ïŒæ°åŠã®åŸç¹ïŒçç§ã®åŸç¹ïŒè±èªã®åŸç¹ãè¡šããŠããïŒ
</p>
<p>
ã©ã®æç§ã®åŸç¹ã100ç¹æºç¹ã§ïŒè² ã®åŸç¹ãäžããããããšã¯ãªãïŒ
</p>
<H2>åºå</H2>
<p>
<!--æåºãããã¡ã€ã«ã¯, æ±ãã1ã€ã®æŽæ°ãããªã.-->
åºåã¯, æ±ãã1ã€ã®æŽæ°ãããªã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ1</h3>
<pre>
100 80 70 60
80 70 80 90
</pre>
<h3>åºåäŸ1</h3>
<pre>
320
</pre>
<br>
<h3>å
¥åäŸ2</h3>
<pre>
100 80 70 60
80 70 60 100
</pre>
<h3>åºåäŸ2</h3>
<pre>
310
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"100 80 70 60\n80 70 80 90\n",
"100 80 70 60\n80 70 80 90\n"
]
] |
p00434 | Who Are The Student Yet To Submit |
<H1>æªæåºè
ã¯èª°ã </H1>
<h2>åé¡</h2>
<p>
JOI倧åŠã®Mææã¯ããã°ã©ãã³ã°ã®ææ¥ãæ
åœããŠããïŒã¯ã©ã¹ã«ã¯30人ã®åè¬çãããŠååè¬çã«ã¯1çªãã30çªãŸã§ã®åºåžçªå·ããµãããŠããïŒãã®ææ¥ã®èª²é¡ã28人ã®åŠçãæåºããïŒæåºãã28人ã®åºåžçªå·ããæåºããŠããªã2人ã®åºåžçªå·ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<H2>å
¥å</H2>
<p>
å
¥åã¯28è¡ããïŒåè¡ã«ã¯æåºè
ã®åºåžçªå·ïŒ1以äž30以äžïŒã1ã€ãã€æžãããŠããïŒå
¥åãããåºåžçªå·ã«éè€ã¯ãªããïŒã©ã®ãããªé ã«å
¥åããããã¯ããããªãïŒ
</p>
<H2>åºå</H2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯2è¡ãããªãïŒ 1è¡ç®ã«2人ã®æªæåºè
ã®åºåžçªå·ã®ãã¡å°ããã»ããïŒ 2è¡ç®ã«å€§ããã»ããåºåããïŒ-->
åºåã¯2è¡ãããªãïŒ 1è¡ç®ã«2人ã®æªæåºè
ã®åºåžçªå·ã®ãã¡å°ããã»ããïŒ 2è¡ç®ã«å€§ããã»ããåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
3
1
4
5
7
9
6
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
8
</pre>
<h3>å
¥åäŸ 2</h3>
<pre>
9
30
6
12
10
20
21
11
7
5
28
4
18
29
17
19
27
13
16
26
14
23
22
15
3
1
24
25
</pre>
<h3>åºåäŸ 2</h3>
<pre>
2
8
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3\n1\n4\n5\n7\n9\n6\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n",
"3\n1\n4\n5\n7\n9\n6\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n"
]
] |
p00435 | Caesar Cipher |
<H1>ã·ãŒã¶ãŒæå·</H1>
<h2>åé¡</h2>
<p>
ã¬ã€ãŠã¹ã»ãŠãªãŠã¹ã»ã«ãšãµã«ïŒGaius Julius Caesar)ïŒè±èªèªã¿ã§ãžã¥ãªã¢ã¹ã»ã·ãŒã¶ãŒïŒJulius CaesarïŒã¯ïŒå€ä»£ããŒãã®è»äººã§ããæ¿æ²»å®¶ã§ããïŒã«ãšãµã«ã¯ïŒç§å¯ã®æçŽãæžããšãã«ïŒ 'A' ã 'D' ã«ïŒ 'B' ã 'E' ã«ïŒ 'C' ã 'F' ã«ïŒãšããããã«3ã€ããããŠè¡šèšãããšããèšé²ãæ®ã£ãŠããïŒ
</p>
<p>
倧æåã®ã¢ã«ãã¡ããã26æåã ããããªãæååãïŒã«ãšãµã«ãããããã«3æåãã€ãããå€æãæœãåŸãããæååãããïŒãã®ãããªæååãå
ã®æååã«æ»ãããã°ã©ã ãäœæããïŒ
</p>
<p>
åæåã®å€æåãšå€æåŸã®å¯Ÿå¿ã¯æ¬¡ã®ããã«ãªãïŒ
</p>
<table style="margin-left:28px; margin-bottom:28px">
<tr>
<td width="80">å€æå</td>
<td width="30">A</td>
<td width="30">B</td>
<td width="30">C</td>
<td width="30">D</td>
<td width="30">E</td>
<td width="30">F</td>
<td width="30">G</td>
<td width="30">H</td>
<td width="30">I</td>
<td width="30">J</td>
<td width="30">K</td>
<td width="30">L</td>
<td width="30">M</td>
<td width="30">N</td>
<td width="30">O</td>
<td width="30">P</td>
<td width="30">Q</td>
<td width="30">R</td>
<td width="30">S</td>
<td width="30">T</td>
<td width="30">U</td>
<td width="30">V</td>
<td width="30">W</td>
<td width="30">X</td>
<td width="30">Y</td>
<td width="30">Z</td>
</tr>
<tr>
<td>å€æåŸ</td>
<td>D</td>
<td>E</td>
<td>F</td>
<td>G</td>
<td>H</td>
<td>I</td>
<td>J</td>
<td>K</td>
<td>L</td>
<td>M</td>
<td>N</td>
<td>O</td>
<td>P</td>
<td>Q</td>
<td>R</td>
<td>S</td>
<td>T</td>
<td>U</td>
<td>V</td>
<td>W</td>
<td>X</td>
<td>Y</td>
<td>Z</td>
<td>A</td>
<td>B</td>
<td>C </td>
</tr>
</table>
<p>
äŸãã°ïŒãã®æ¹æ³ã§æåå JOI ãå€æãããš MRL ãåŸããïŒãã®æ¹æ³ã§å€æãããæåå FURDWLD ã®å
ã®æåå㯠CROATIA ã§ããïŒ
</p>
<H2>å
¥å</H2>
<p>
å
¥åã¯1è¡ã ããããªãïŒãã®1è¡ã¯å€§æåã®ã¢ã«ãã¡ãããã®ã¿ã§æ§æãããæååã1ã€å«ãïŒ
</p>
<p>
å
¥åãããæååã®é·ã㯠1000 以äžã§ããïŒ
</p>
<H2>åºå</H2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯ãå
¥åãããæååãå
ã«æ»ããæååã ããå«ã1è¡ãåºåããã-->
å
¥åãããæååãå
ã«æ»ããæååã ããå«ã1è¡ãåºåããã
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>MRL</pre>
<h3>åºåäŸ 1</h3>
<pre>
JOI
</pre>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>FURDWLD</pre>
<h3>åºåäŸ 2</h3>
<pre>CROATIA</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"MRL\n",
"MRL\n"
]
] |
p00436 | Shuffle The Cards |
<H1>ã«ãŒãã®äžŠã³æ¿ã</H1>
<h2>åé¡</h2>
<p>
1 ãã 2n ã®æ°ãæžããã 2n æã®ã«ãŒããããïŒäžãã 1, 2, 3, ... , 2n ã®é ã«ç©ã¿éãªã£ãŠããïŒ
</p>
<p>
ãã®ã«ãŒããïŒæ¬¡ã®æ¹æ³ãäœåãçšããŠäžŠã¹æ¿ããïŒ
</p>
<p>
<b>æŽæ° k ã§ã«ãã</b><br>
äžãã k æã®ã«ãŒãã®å±± A ãš æ®ãã®ã«ãŒãã®å±± B ã«åããåŸïŒ å±± A ã®äžã«å±± B ãã®ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_card01">
</center>
<br/>
<p>
<b>ãªãã«ã·ã£ããã«</b><br>
äžãã n æã®å±± A ãšæ®ãã®å±± B ã«åãïŒ äžãã A ã®1æç®ïŒ B ã®1æç®ïŒ A ã®2æç®ïŒ B ã®2æç®ïŒ âŠïŒ A ã® næç®ïŒ B ã® næç®ïŒ ãšãªãããã«ããŠïŒ 1 ã€ã®å±±ã«ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_card02">
</center>
<br/>
<p>
å
¥å<!--ãã¡ã€ã«-->ã®æ瀺ã«åŸãïŒã«ãŒãã䞊ã³æ¿ããããšã®ã«ãŒãã®çªå·ãïŒäžããé çªã«åºåããããã°ã©ã ãäœæããïŒ
</p>
<H2>å
¥å</H2>
<ul>
<li> 1 è¡ç®ã«ã¯ n ïŒ1 ⊠n ⊠100ïŒãæžãããŠããïŒ ããªãã¡ã«ãŒãã®ææ°ã¯ 2n æã§ããïŒ</li>
<li> 2 è¡ç®ã«ã¯æäœã®åæ° m ïŒ1 ⊠m ⊠1000ïŒãæžãããŠããïŒ</li>
<li> 3 è¡ç®ãã m + 2 è¡ç®ãŸã§ã® m è¡ã«ã¯ïŒ 0 ãã 2n-1 ãŸã§ã®ãããã 1 ã€ã®æŽæ° k ãæžãããŠããïŒ ã«ãŒãã䞊ã¹æ¿ããæ¹æ³ãé ã«æå®ããŠããïŒ
<ul>
<li> k = 0 ã®å Žåã¯ïŒ ãªãã«ã·ã£ããã«ãè¡ãïŒ</li>
<li> 1 ⊠k ⊠2n-1 ã®å Žåã¯ïŒ k ã§ã«ãããè¡ãïŒ </li>
</ul>
</li>
</ul>
<H2>åºå</H2>
<p>
<!--2n è¡ãããªããåºåãã¡ã€ã«ãæåºããïŒ-->åºåã¯2n è¡ãããªãïŒ 1 è¡ç®ã«ã¯äžŠã¹æ¿ãçµäºåŸã®äžçªäžã®ã«ãŒãã®çªå·ïŒ 2 è¡ç®ã«ã¯äžŠã¹æ¿ãçµäºåŸã®äžãã 2 çªç®ã®ã«ãŒãã®çªå·ãšããããã«ïŒ i è¡ç®ã«ã¯äžãã i çªç®ã®ã«ãŒãã®çªå·ãåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
2
2
1
0
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
4
3
1
</pre>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
3
4
2
4
0
0
</pre>
<h3>åºåäŸ 2</h3>
<pre>
1
5
4
3
2
6
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"2\n2\n1\n0\n",
"2\n2\n1\n0\n"
]
] |
p00437 | Quality Checking |
<H1>å質æ€æ»</H1>
<h2>åé¡</h2>
<p>
ããªãã¯ããæ©æ¢°ã®è£œé å·¥å Žã§å質管çã®è²¬ä»»è
ãããŠããïŒ ãã®æ©æ¢°ã«ã¯ïŒ éšåãšããŠé»æºãšã¢ãŒã¿ãŒãšã±ãŒãã«ãå¿
èŠã§ããïŒ è£œé å·¥å Žã«ã¯é»æºã a åïŒ ã¢ãŒã¿ãŒã b åïŒ ã±ãŒãã«ã c åããïŒ ãããã 1 ãã a ãŸã§ïŒ a+1 ãã a+b ãŸã§ïŒ a+b+1 ãã a+b+c ãŸã§ã®çªå·ãä»ããŠããïŒ å°ã£ãããšã«ïŒ éšåã®äžã«æ
éããŠãããã®ããããããããªãïŒ å·¥å Žã§ã¯ã©ã®éšåãæ
éããŠããŠã©ã®éšåãæ£åžžã§ããããç¥ãããïŒ
</p>
<p>
ããã§ïŒ å·¥å Žã§ã¯æ¬¡ã®æ¹æ³ã§éšåãæ€æ»ããïŒ é»æºãšã¢ãŒã¿ãŒãšã±ãŒãã«ãïŒã€ãã€æã£ãŠããŠã€ãªãïŒ åäœãããŠã¿ãïŒ ãã®ãšãïŒ ïŒã€ã®éšåããã¹ãŠæ£åžžã§ãããšãã¯æ£ããåäœããŠãåæ ŒããšãããïŒ ïŒã€ã®äžã«æ
éããŠããéšåãïŒã€ã§ãå
¥ã£ãŠãããšãã¯æ£ããåäœããªãã®ã§ãäžåæ ŒããšãããïŒ ïŒå·¥å Žã§äœã£ãŠããæ©æ¢°ã¯ãšãŠã粟å¯ãªã®ã§ïŒ æ
éããéšåããŸãã£ãŠããã®ã«å¶ç¶æ£ããåäœããŠããŸããªã©ãšããããšã¯èµ·ããªãã®ã ïŒïŒ
</p>
<p>
ããªãã«ã¯æ€æ»çµæã®ãªã¹ããæž¡ãããïŒ æ€æ»çµæã®ãªã¹ãã®åè¡ã«ã¯ïŒ æ€æ»ã«äœ¿ã£ãé»æºãšã¢ãŒã¿ãŒãšã±ãŒãã«ã®çªå·ãšïŒ æ€æ»ãåæ Œã ã£ããäžåæ Œã ã£ãããæžãããŠããïŒ
</p>
<p>
æ€æ»çµæã®ãªã¹ããäžãããããšãïŒ ãã¹ãŠã®éšåãïŒ æ€æ»çµæãã確å®ã«æ
éããŠãããšãããéšåãšïŒ 確å®ã«æ£åžžãšãããéšåãšïŒ æ€æ»çµæããã¯æ
éããŠãããšãæ£åžžã§ãããšã決ãŸããªãéšåã«åé¡ããããã°ã©ã ãäœæããïŒ
</p>
<H2>å
¥å</H2>
<p>
<!--å
¥åãã¡ã€ã«ã®åœ¢åŒã¯ä»¥äžã®éãã§ããïŒ-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã®åœ¢åŒã¯ä»¥äžã®éãã§ããïŒå
¥åã¯ïŒã€ã®ãŒããå«ãè¡ã§çµäºããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ 3 åã®æŽæ°ã空çœåºåãã§æžãããŠããïŒ é ã«é»æºã®åæ° a, ã¢ãŒã¿ãŒã®åæ° b, ã±ãŒãã«ã®åæ° c ãè¡šãïŒ
</p>
<p>
2 è¡ç®ã«ã¯ 1 åã®æŽæ°ãæžãããŠããïŒ æ€æ»çµæã®ãªã¹ãã«å«ãŸããæ€æ»ã®åæ° N ãæžãããŠããïŒ
</p>
<p>
ç¶ã N è¡ã¯æ€æ»çµæã®ãªã¹ããè¡šãïŒ åè¡ã«ã¯ïŒ 4 åã®æŽæ° i, j, k, r ãïŒã€ã®ç©ºçœãåºåããšããŠæžãããŠããïŒ é»æº i ãšã¢ãŒã¿ãŒ j ãšã±ãŒãã« k ãã€ãªãã§æ€æ»ããçµæãïŒ ãåæ Œã (r=1 ã®ãšã) ããäžåæ Œã (r=0 ã®ãšã) ã ã£ãããšãè¡šã.
</p>
<p>
a, b, c, N 㯠1 ≤ a, b, c ≤ 100, 1 ≤ N ≤ 1000 ãæºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<H2>åºå</H2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯ä»¥äžã®éãã§ãã.åºåãã¡ã€ã«ã¯ a+b+c è¡ãããªã.-->
ããŒã¿ã»ããããšã«ä»¥äžã®åœ¢åŒã§åºåããïŒåããŒã¿ã»ããã®åºå㯠a+b+c è¡ãããªã.
</p>
<p>
i è¡ç® (1 ≤ i ≤ a+b+c)ïŒ
</p>
<ul>
<li> æ€æ»çµæããéšå i ãæ
éããŠãããšãããå Žå㯠0 ãåºåãã.</li>
<li> æ€æ»çµæããéšå i ãæ£åžžãšãããå Žå㯠1 ãåºåãã.</li>
<li> æ€æ»çµæããéšå i ãæ
éããŠãããæ£åžžã§ãããã決ãŸããªãå Žå㯠2 ãåºåãã.</li>
</ul>
<h2>å
¥åºåäŸ</h2>
<!--
<table style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>2 2 2 </td></tr>
<tr><td>4 </td></tr>
<tr><td>2 4 5 0 </td></tr>
<tr><td>2 3 6 0 </td></tr>
<tr><td>1 4 5 0 </td></tr>
<tr><td>2 3 5 1 </td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸ</th>
</tr>
<tr><td>2 </td></tr>
<tr><td>1 </td></tr>
<tr><td>1 </td></tr>
<tr><td>0 </td></tr>
<tr><td>1 </td></tr>
<tr><td>0 </td></tr>
</table>
-->
<h3>å
¥åäŸ</h3>
<pre>
2 2 2
4
2 4 5 0
2 3 6 0
1 4 5 0
2 3 5 1
0 0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
2
1
1
0
1
0
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0\n",
"2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0\n"
]
] |
p00438 | School Road |
<H1>éåŠçµè·¯</H1>
<h2>åé¡</h2>
<p>
倪éåã®äœãã§ããJOIåžã¯ïŒååæ¹åã«ãŸã£ããã«äŒžã³ã a æ¬ã®éè·¯ãšïŒæ±è¥¿æ¹åã«ãŸã£ããã«äŒžã³ã b æ¬ã®éè·¯ã«ããïŒç¢ç€ã®ç®ã®åœ¢ã«åºåããããŠããïŒ
</p>
<p>
ååæ¹åã® a æ¬ã®éè·¯ã«ã¯ïŒè¥¿ããé ã« 1, 2, ... , a ã®çªå·ãä»ããããŠããïŒãŸãïŒæ±è¥¿æ¹åã® b æ¬ã®éè·¯ã«ã¯ïŒåããé ã« 1, 2, ... , b ã®çªå·ãä»ããããŠããïŒè¥¿ãã i çªç®ã®ååæ¹åã®éè·¯ãšïŒåãã j çªç®ã®æ±è¥¿æ¹åã®éè·¯ã亀ãã亀差ç¹ã (i, j) ã§è¡šãïŒ
</p>
<p>
倪éåã¯ïŒäº€å·®ç¹ (1, 1) ã®è¿ãã«äœãã§ããïŒäº€å·®ç¹ (a, b) ã®è¿ãã®JOIé«æ ¡ã«èªè»¢è»ã§éã£ãŠããïŒèªè»¢è»ã¯éè·¯ã«æ²¿ã£ãŠã®ã¿ç§»åããããšãã§ããïŒå€ªéåã¯ïŒéåŠæéãçãããããïŒæ±ãŸãã¯åã«ã®ã¿åãã£ãŠç§»åããŠéåŠããŠããïŒ
</p>
<p>
çŸåšïŒ JOIåžã§ã¯ïŒ n åã®äº€å·®ç¹ (x<sub>1</sub>, y<sub>1</sub>), (x<sub>2</sub>, y<sub>2</sub>), ... , (x<sub>n</sub>, y<sub>n</sub>) ã§å·¥äºãè¡ã£ãŠããïŒå€ªéåã¯å·¥äºäžã®äº€å·®ç¹ãéãããšãã§ããªãïŒ
</p>
<p>
倪éåãäº€å·®ç¹ (1, 1) ããäº€å·®ç¹ (a, b) ãŸã§ïŒå·¥äºäžã®äº€å·®ç¹ãé¿ããªããïŒæ±ãŸãã¯åã«ã®ã¿åãã£ãŠç§»åããŠéåŠããæ¹æ³ã¯äœéãããã ãããïŒå€ªéåã®éåŠçµè·¯ã®åæ° m ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<H2>å
¥å</H2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒå
¥åã¯ãŒããïŒã€å«ãè¡ã§çµäºããïŒ
</p>
<p>
1è¡ç®ã«ã¯ïŒç©ºçœãåºåããšããŠ2åã®æŽæ° a, b ãæžãããŠããïŒããã¯ïŒååæ¹åã®éè·¯ã®æ¬æ°ãšïŒæ±è¥¿æ¹åã®éè·¯ã®æ¬æ°ãè¡šãïŒ a, b 㯠1 ≤ a, b ≤ 16 ãã¿ããïŒ
</p>
<p>
2è¡ç®ã«ã¯, å·¥äºäžã®äº€å·®ç¹ã®åæ°ãè¡šãæŽæ° n ãæžãããŠããïŒ n 㯠1 ≤ n ≤ 40 ãã¿ããïŒ
</p>
<p>
ç¶ã n è¡ (3è¡ç®ãã n+2 è¡ç®) ã«ã¯ïŒå·¥äºäžã®äº€å·®ç¹ã®äœçœ®ãæžãããŠããïŒ i+2 è¡ç®ã«ã¯ç©ºçœã§åºåãããæŽæ° x<sub>i</sub>, y<sub>i</sub> ãæžãããŠããïŒäº€å·®ç¹ (x<sub>i</sub>, y<sub>i</sub>) ãå·¥äºäžã§ããããšãè¡šãïŒ x<sub>i</sub>, y<sub>i</sub> 㯠1 ≤ x<sub>i</sub>, y<sub>i</sub> ≤ 16 ãã¿ããïŒ
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<H2>åºå</H2>
<p>
<!--æåºãããã¡ã€ã«ã¯, 倪éåã®éåŠçµè·¯ã®åæ° m ã ããå«ã1è¡ãããªã.-->
ããŒã¿ã»ããããšã«, 倪éåã®éåŠçµè·¯ã®åæ° m ã1è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<!--
<pre>
<table style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px;">
<tr>
<th width="150" align="left">å
¥åäŸ</th>
</tr>
<tr><td></td><td></td></tr>
<tr><td>5 4 </td></tr>
<tr><td>3 </td></tr>
<tr><td>2 2 </td></tr>
<tr><td>2 3 </td></tr>
<tr><td>4 2 </td></tr>
<tr>
<td>ã</td>
</tr>
<tr>
<th width="150" align="left">åºåäŸ</th>
</tr>
<tr><td>5</td></tr>
</table>
-->
<H2>å
¥åäŸ</H2>
<pre>
5 4
3
2 2
2 3
4 2
5 4
3
2 2
2 3
4 2
0 0
</pre>
<H2>åºåäŸ</H2>
<pre>
5
5
</pre>
<p>äžå³ã¯ a=5, b=4, n=3 ã§ïŒå·¥äºäžã®äº€å·®ç¹ã (2,2), (2,3), (4,2) ã®å Žåãè¡šããŠããïŒ</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_route-fig1">
</center>
<p>
ãã®å ŽåïŒéåŠçµè·¯ã¯ m=5 éãããïŒ 5éãã®éåŠçµè·¯ãå
šãŠå³ç€ºãããšïŒä»¥äžã®éãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_route-fig2">
</center>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n",
"5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n"
]
] |
p00439 | Maximum Sum |
<H1>æ倧ã®å </H1>
<h2>åé¡</h2>
<p>
<i>n</i> åã®æŽæ°ãããªãæ°å <i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>, ..., <i>a<sub>n</sub></i> ãšæ£æŽæ° <i>k</i> (1 ≤ <i>k</i> ≤ <i>n</i>) ãäžãããã.ãã®ãšã, é£ç¶ããŠäžŠã¶ <i>k</i> åã®æŽæ°ã®å <i>S<sub>i</sub></i> = <i>a<sub>i</sub></i> + <i>a</i><sub>i+1</sub> + ... + <i>a</i><sub><i>i</i>+<i>k</i>-1</sub> (1 ≤ <i>i</i> ≤ <i>n</i> - <i>k</i> + 1) ã®æ倧å€ãåºåããããã°ã©ã ãäœããªãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠<span>input.txt</span> ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒå
¥åã¯ïŒã€ã®ãŒããå«ãè¡ã§çµäºããïŒ
</p>
<p>
1 è¡ç®ã«ã¯æ£æŽæ° <i>n</i> (1 ≤ <i>n</i> ≤ 100000) ãšæ£æŽæ° <i>k</i> (1 ≤ <i>k</i> ≤ <i>n</i>) ããã®é ã«ç©ºçœã§
åºåãããŠæžãããŠãã.2 è¡ç®ä»¥éã®ç¬¬ 1 + <i>i</i> è¡ç® (1 ≤ <i>i</i> ≤ <i>n</i>) ã«ã¯, æ°åã® <i>i</i> çªç®ã®é
<i>a<sub>i</sub></i> (-10000 ≤ <i>a<sub>i</sub></i> ≤ 10000) ãæžãããŠãã.
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 60% å㯠<i>n</i> ≤ 5000, <i>k</i> ≤ 1000 ãæºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠<span>output.txt</span> ã§ãã.
<span>output.txt</span> 㯠1 è¡ã ããããªã,ãã® 1 è¡ã¯ <i>S<sub>i</sub></i> ã®æ倧å€ã ããå«ã.
-->
ããŒã¿ã»ããããšã«<i>S<sub>i</sub></i> ã®æ倧å€ãïŒè¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5 3
2
5
-4
10
3
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
11
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 3\n2\n5\n-4\n10\n3\n0 0\n",
"5 3\n2\n5\n-4\n10\n3\n0 0\n"
]
] |
p00440 | Longest Steps |
<H1>æé·ã®é段 </H1>
<h2>åé¡</h2>
<p>
1 ãã <i>n</i> ãŸã§ã®æŽæ°ããããã 1 ã€ãã€æžããã <i>n</i> æã®ã«ãŒããš,1 æã®çœçŽã®
ã«ãŒãããã.ããã <i>n</i> + 1 æã®ã«ãŒãã®å
,<i>k</i> æã®ã«ãŒããäžãããã.ãã ã,
1 ≤ <i>k</i> ≤ n ã§ãã.çœçŽã®ã«ãŒãã«ã¯ 1 ãã <i>n</i> ãŸã§ã®æŽæ°ã 1 ã€æžãããšãã§ã
ã.äžããããã«ãŒãã ãã§,ã§ããã ãé·ãé£ç¶ããæŽæ°åãäœããã.
</p>
<p>
äžããããã«ãŒããå
¥åããããšãã«, äžããããã«ãŒãããäœãããšãã§ããé£
ç¶ããæŽæ°åã®æ倧é·ãåºåããããã°ã©ã ãäœæãã.
</p>
<h2>äŸ1</h2>
<p>
<i>n</i> = 7, <i>k</i> = 5 ãšãã.6, 2, 4, 7, 1 ã®ã«ãŒããäžãããããšã,ãã®ã«ãŒãã䜿ã£
ãŠäœããé£ç¶ããæŽæ°åã®ãã¡æé·ã®ãã®ã¯ 1, 2 ã§ãã,ãã®é·ã㯠2 ã§ãã.
</p>
<h2>äŸ2</h2>
<p>
<i>n</i> = 7, <i>k</i> = 5 ãšãã.6, 2, 4, 7 ãšçœçŽã®ã«ãŒããäžãããããšã,ãã®ã«ãŒãã
䜿ã£ãŠäœããé£ç¶ããæŽæ°åã®ãã¡æé·ã®ãã®ã¯,çœçŽã®ã«ãŒãã« 5 ãæžãããšã«
ãã£ãŠã§ãã 4, 5, 6, 7 ã§ãã,ãã®é·ã㯠4 ã§ãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠<span>input.txt</span> ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒå
¥åã¯ãŒãïŒã€ãå«ãè¡ã§çµäºããïŒ
</p>
<p>
1 è¡ç®ã«ã¯,2 ã€ã®æŽæ° <i>n</i> (1 ≤ <i>n</i> ≤ 100000) ãš <i>k</i> (1 ≤ <i>k</i> ≤ <i>n</i>) ããã®é 㧠1 ã€ã®
空çœãåºåããšããŠæžãããŠãã.ç¶ã <i>k</i> è¡ã«ã¯æŽæ°ã 1 ã€ãã€æžãããŠãã,äž
ãããã <i>k</i> æã®ã«ãŒãã«æžãããŠããæŽæ°ãè¡šããŠãã.çœçŽã®ã«ãŒã㯠0 ã§è¡šã
ãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 40% å㯠1 ≤ <i>n</i> ≤ 1000, 1 ≤ <i>k</i> ≤ 500 ã, é
ç¹ã® 20% å㯠1 ≤ <i>n</i> ≤ 60000, 1 ≤ <i>k</i> ≤ 50000 ã. é
ç¹ã® 40% å㯠1 ≤ <i>n</i> ≤ 100000, 1 ≤ <i>k</i> ≤ 100000 ãæºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠<span>output.txt</span> ã§ãã.
<span>output.txt</span> 㯠1 è¡ã ããããªã,ãã® 1 è¡ã¯åºåããæŽæ° 1 ã€ã ããå«ã.
-->
ããŒã¿ã»ããããšã«æŽæ°ã1è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
7 5
6
2
4
7
1
7 5
6
2
0
4
7
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
2
4
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0\n",
"7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0\n"
]
] |
p00441 | The Oldest Site |
<H1>æå€ã®éºè·¡ </H1>
<h2>åé¡</h2>
<p>
æ, ããã«ã¯éèœããã, å€ãã®äººãæ®ãããŠãã. 人ã
ã¯åœ¢ã倧ãããæ§ã
ãªå»ºç©ã建ãŠã. ã ã, ãããã®å»ºé ç©ã¯æ¢ã«å€±ãã, æç®ãš, éºè·¡ããèŠã€ãã£ãæ±ã ãã建é ç©ã®äœçœ®ãç¥ãæãããã ã£ã.
</p>
<p>
æç®ã«ã¯ç¥æ®¿ã®èšè¿°ããã. ç¥æ®¿ã¯äžããèŠããšæ£ç¢ºã«æ£æ¹åœ¢ã«ãªã£ãŠãã, ãã®åé
ã«ã¯æ±ããã£ã. ç¥æ®¿ãã©ã®åããåããŠãããã¯ããããªã. ãŸã, 蟺äžãå
éšã«æ±ããã£ããã©ãããããããªã. èå€åŠè
ãã¡ã¯, éºè·¡ããèŠã€ãã£ãæ±ã®äžã§, æ£æ¹åœ¢ã«ãªã£ãŠãããã®ã®ãã¡, é¢ç©ãæ倧ã®ãã®ãç¥æ®¿ã«éããªããšèãã.
</p>
<p>
æ±ã®äœçœ®ã®åº§æšãäžããããã®ã§, 4 æ¬ã®æ±ã§ã§ããæ£æ¹åœ¢ã®ãã¡é¢ç©ãæ倧ã®ãã®ãæ¢ã, ãã®é¢ç©ãåºåããããã°ã©ã ãæžã. ãªã, æ£æ¹åœ¢ã®èŸºã¯åº§æšè»žã«å¹³è¡ãšã¯éããªãããšã«æ³šæãã.
</p>
<h2>äŸ</h2>
<p>
äžã®å³ã®äŸã§ã¯, 10 æ¬ã®æ±ããã, åº§æš (4, 2), (5, 2), (5, 3), (4, 3) ã«ãã 4 æ¬ãšåº§æš (1, 1), (4, 0), (5, 3), (2, 4) ã«ãã 4 æ¬ãæ£æ¹åœ¢ããªããŠãã. é¢ç©ãæ倧ã®æ£æ¹åœ¢ã¯åŸè
ã§, ãã®é¢ç©ã¯ 10 ã§ãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_oldestSite">
</center>
<br>
<h2>å
¥å</h2>
<p>
<!--å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒå
¥åã¯ãŒãïŒã€ãå«ãè¡ã§çµäºããïŒ
</p>
<p>
1 è¡ç®ã«ã¯, éºè·¡ããèŠã€ãã£ãæ±ã®æ¬æ° n ãæžãããŠãã.
</p>
<p>
2 è¡ç®ãã n + 1 è¡ç®ãŸã§ã® n è¡ã®åã
ã«ã¯, æ±ã® x 座æšãš y 座æšã空çœåºåãã§æžãããŠãã.
</p>
<p>
1 æ¬ã®æ±ã 2 床以äžçŸããããšã¯ãªã.
</p>
<p>
n 㯠1 ≤ n ≤ 3000 ãæºããæŽæ°ã§ãã, æ±ã® x 座æšãš y 座æšã¯ 0 ä»¥äž 5000 以äžã®æŽæ°ã§ãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 30% å㯠1 ≤ n ≤ 100 ãæºãã, é
ç¹ã® 60% åã¯1 ≤ n ≤ 500 ãæºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
</p>
-->
<p>
<!-- åºåãã¡ã€ã«ã«ã¯-->
ããŒã¿ã»ããããšã« 1 åã®æŽæ°ãåºåãã. 4 æ¬ã®æ±ãããªãæ£æ¹åœ¢ãååšããå Žåã¯, ãã®ãããªæ£æ¹åœ¢ã®ãã¡é¢ç©ãæ倧ã®ãã®ã®é¢ç©ãåºåã, ãã®ãããªæ£æ¹åœ¢ãååšããªãå Žå㯠0 ãåºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
0
</pre>
<h3>åºåäŸ</h3>
<pre>
10
10
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0\n",
"10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0\n"
]
] |
p00442 | Worst Reporter |
<H1>ææªã®èšè
</H1>
<h2>åé¡</h2>
<p>
ããªã㯠JOI æ°è瀟ã®èšè
ã§ããïŒã¹ããŒãèšäºãæ
åœããŠããïŒ
</p>
<p>
æšæ¥ãŸã§ã«ïŒã¯ãã¢ãã¢ã§ã¯ïŒn åã®ãµãã«ãŒããŒã ã«ããç·åœãã®ãªãŒã°æŠãè¡ãããïŒå€§äŒå®è¡å§å¡äŒã¯ïŒè©ŠåçµæãšèŠå®ã«åºã¥ãåããŒã ã« 1 äœãã n äœãŸã§ã®é äœãã€ããããã§ããïŒããªãã«ã¯ïŒäžéšã®è©Šåã®åæãšãšãã«ïŒæ¬¡ã®æ
å ±ãäŒããããïŒ
<br/>
<b>æ
å ± 1</b> åŒãåãã®è©Šåã¯ãªãã£ãïŒ<br/>
<b>æ
å ± 2</b> å
šãŠã®ããŒã ã«ç°ãªãé äœãã€ããïŒ<br/>
<b>æ
å ± 3</b> å
šãŠã® 1 ≤ a < b ≤ n ã«å¯ŸãïŒa äœã®ããŒã ãš b äœã®ããŒã ã®è©Šåã«ãããŠïŒå¿
ã a äœã®ããŒã ãåå©ããïŒ
<br/>
</p>
<p>
ããªãã¯èšäºãäœæããããã«ïŒäžéšã®è©Šåã®åæãšïŒäŒããããæ
å ± 1 3 ãããšã«ïŒé äœè¡šãæšæž¬ããããšã«ããïŒ
</p>
<p>
å
¥åãšããŠäžéšã®è©Šåã®åæãäžãããããšãïŒäŒããããæ
å ±ã«é©åããé äœè¡šã 1 ã€åºåããããã°ã©ã ãäœãïŒãŸãïŒåºåããé äœè¡šä»¥å€ã«ïŒäŒããããæ
å ±ã«é©åããé äœè¡šãååšãããã©ãããå€å®ããïŒ
</p>
<p>
ããã§ïŒé äœè¡šãšã¯ 1 äœãã n äœã®é ã«ããŒã ã䞊ã¹ããã®ã®ããšãããïŒ
</p>
<h2>äŸ</h2>
<b>
äŸ1 (æ
å ±ã«é©åããé äœè¡šã 1 ã€ãããªãå Žå)
</b>
<p>
ããŒã æ°ã4ã§ïŒåããŒã ã«1ãã4ãŸã§ã®çªå·ãä»ããããŠããïŒåæã次ã®è¡šã§äžããããŠãããšããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_worstSportswriter1">
</center><br/>
<p>
i è¡ j åãâã®ãšãã¯ïŒçªå· i ã®ããŒã ãšçªå· j ã®ããŒã ã®è©Šåã«ãããŠïŒçªå· i ã®ããŒã ãåå©ããããšãæå³ããïŒãŸãïŒÃã®ãšãã¯ïŒçªå· j ã®ããŒã ãåå©ããããšãæå³ããïŒ? ã¯åæãäžããããŠããªãããšãæå³ããïŒãã®ãšãïŒäŒããããæ
å ±ã«é©åããé äœè¡šã¯æ¬¡ã® 1 ã€ãããªã
</p>
<center>
<table>
<tr><td>
1 äœ çªå· 3 ã®ããŒã <br/>
2 äœ çªå· 4 ã®ããŒã <br/>
3 äœ çªå· 1 ã®ããŒã <br/>
4 äœ çªå· 2 ã®ããŒã <br/>
</td></tr>
</table>
</center>
<br/>
<b>
äŸ2 (æ
å ±ã«é©åããé äœè¡šãè€æ°ååšããå Žå)
</b>
<p>
ããŒã æ°ã3ã§ïŒåããŒã ã«1ãã3ãŸã§ã®çªå·ãä»ããããŠããïŒåæã次ã®è¡šã§äžããããŠãããšããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_worstSportswriter2">
</center><br/>
<p>
ãã®ãšãïŒäŒããããæ
å ±ã«é©åããé äœè¡šã¯ïŒæ¬¡ã® 2 ã€ã§ããïŒ
</p>
<center>
<table>
<tr>
<td width="200">
1 äœ çªå· 2 ã®ããŒã <br/>
2 äœ çªå· 1 ã®ããŒã <br/>
3 äœ çªå· 3 ã®ããŒã <br/>
</td>
<td width="200">
1 äœ çªå· 2 ã®ããŒã <br/>
2 äœ çªå· 3 ã®ããŒã <br/>
3 äœ çªå· 1 ã®ããŒã <br/>
</td>
</tr>
</table>
</center>
<h2>å
¥å</h2>
<p>
<!--å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ããïŒ-->
å
¥åã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ïŒãµãã«ãŒããŒã ã®åæ° n ãæžãããŠããïŒåããŒã ã«ã¯ïŒ1 ãã n ãŸã§ã®çªå·ãä»ããããŠããïŒ
</p>
<p>
2 è¡ç®ã«ã¯ïŒäžããããè©Šåã®åæã®åæ° m ãæžãããŠããïŒ
</p>
<p>
3 è¡ç®ãã m + 2 è¡ç®ã¯è©Šåã®åæãè¡šãïŒåè¡ã¯ç©ºçœã§åºåããã 2 ã€ã®æŽæ° i, j ãå«ã¿ïŒçªå· i ã®ããŒã ãçªå· j ã®ããŒã ã«åå©ããããšãè¡šãïŒ
</p>
<p>
n, m 㯠1 ≤ n ≤ 5000, 1 ≤ m ≤ 100000 ãã¿ããïŒ
</p>
<p>
æ¡ç¹ã®éã«çšãããã¹ãããŒã¿ã®ãã¡ïŒ30% 㯠1 ≤ n ≤ 7, 1 ≤ m ≤ 15 ãã¿ããïŒãŸãïŒ60% 㯠1 ≤ n ≤ 100, 1 ≤ m ≤ 2000 ãã¿ããïŒ
</p>
<h2>åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ããïŒ
</p>
-->
<p>
åºå<!--ãã¡ã€ã«-->㯠n + 1 è¡ãããªãïŒ
</p>
<p>
1 è¡ç®ãã n è¡ç®ãŸã§ã® n è¡ã«ã¯ïŒäŒããããæ
å ±ã«é©åããé äœè¡šãåºåããïŒ
</p>
<p>
i è¡ç® (1 ≤ i ≤ n) ã« i äœã®ããŒã ã®çªå·ãåºåããïŒ
</p>
<p>
n + 1 è¡ç®ã«ã¯ïŒåºåããé äœè¡šä»¥å€ã«ïŒäŒããããæ
å ±ã«é©åããé äœè¡šãååšãããã©ãããè¡šãæŽæ°ãåºåããïŒããååšããªããã° 0 ãïŒååšããå Žå㯠1 ãåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<p>
äŸ 1 ã«å¯Ÿå¿ããå
¥åºåã¯ä»¥äžã®éãã§ããïŒ
</p>
<h3>å
¥åäŸ 1</h3>
<pre>
4
5
1 2
3 1
3 2
3 4
4 1
</pre>
<h3>åºåäŸ 1</h3>
<pre>
3
4
1
2
0
</pre>
<br/>
<p>
äŸ 2 ã«å¯Ÿå¿ããå
¥åºåã¯ä»¥äžã®éãã§ããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
3
2
2 1
2 3
</pre>
<p>
ãã®å
¥åããŒã¿ã«å¯ŸããŠïŒæ¬¡ã® 2 éãã®åºåããŒã¿ãèããããïŒã©ã¡ããåºåããŠãããïŒ
</p>
<h3>åºåäŸ 2</h3>
<pre>
2
1
3
1
</pre>
<pre>
2
3
1
1
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4\n5\n1 2\n3 1\n3 2\n3 4\n4 1\n",
"4\n5\n1 2\n3 1\n3 2\n3 4\n4 1\n"
]
] |
p00443 | Lightest Mobile |
<H1>æ軜éã®ã¢ããŒã«</H1>
<h2>åé¡</h2>
<p>
ã¢ããŒã«ã¯åãèžè¡åãšããŠåºã芪ããŸããŠãã.IOI æ¥æ¬å§å¡äŒã§ã¯,JOI ãåºå ±ããããã«ã¢ããŒã«ãäœæããããšã«ãªã£ã.JOI åºå ±çšã¢ããŒã«ã¯,æ£,çŽ(ã²ã),é(ããã)ã® 3 çš®é¡ã®èŠçŽ ãçšããŠ,次ã®ããã«æ§æããã.
</p>
<ul>
<li> æ£ã®äžæ¹ã®ç«¯ã¯éã«,ããäžæ¹ã®ç«¯ã¯èµ€ã«å¡ãããŠãã. </li>
<li> æ£ã¯äž¡ç«¯ä»¥å€ã® 1 ç®æãæ¯ç¹ãšããŠçŽã§ã€ãããã.</li>
<li> æ¯ç¹ããèµ€ã®ç«¯ãŸã§ã®é·ããæ¯ç¹ããéã®ç«¯ãŸã§ã®é·ããæ£æŽæ°ã§ãã.</li>
<li> æ£ã®äž¡ç«¯ã«ã¯,çŽã§éãä»ã®æ£ãã€ãã.</li>
<li> éã¯çŽãçšããŠã©ããã®æ£ã®äžç«¯ã«ã€ãããã.</li>
<li> éã«ã¯äœãã€ãããªã.</li>
<li> éã®éãã¯æ£æŽæ°ã§ãã.</li>
<li> çŽã®ãã¡ 1 æ¬ã ãã¯,çæ¹ã®ç«¯ãããæ£ãã€ããããã«ãã®æ£ã®æ¯ç¹ã«çµã°ã,
ããäžæ¹ã®ç«¯ã¯ä»ã®ã©ã®æ§æèŠçŽ ãšãçµã°ããŠããªã.ä»ã®çŽã¯å
šãŠæ¬¡ã®ãã
ãããæºãã.</li>
<ul>
<li> ããæ£ã®ç«¯ãšããæ£ã®æ¯ç¹ãçµã¶.</li>
<li> ããæ£ã®ç«¯ãšããéãçµã¶.</li>
</ul>
</ul>
<p>
ãã ã,ã©ã®æ£ã«ãããŠã,ãã©ã³ã¹ãåããŠããå¿
èŠããã.æ£ãšçŽã®éãã¯ç¡èŠã§ããã»ã©è»œãã®ã§,æ£ãšçŽã®éãã¯å
šãŠ 0 ã§ãããšã¿ãªããŠè§£çãã.ã€ãŸã,ããããã®æ£ã«ã€ããŠ,
</p>
<p>
(ãã®æ£ã®èµ€ã®ç«¯ããäžã«ã€ããããŠããéã®éãã®ç·èš)
× (ãã®æ£ã®æ¯ç¹ããèµ€ã®ç«¯ãŸã§ã®é·ã)
= (ãã®æ£ã®éã®ç«¯ããäžã«ã€ããããŠããéã®éãã®ç·èš)
× (ãã®æ£ã®æ¯ç¹ããéã®ç«¯ãŸã§ã®é·ã)
</p>
<p>
ã§ãããšã,ãã®æ£ã¯ãã©ã³ã¹ãåããŠãããšãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_lightestMobile1">
</center>
<br>
<p>
ã©ã®ãããªé·ãã®æ£ãã©ã®ããã«çµã³ã¢ããŒã«ãæ§æãããã¯æ¢ã«æ±ºãŸã£ãŠããã®ã ã,éã®éãããŸã 決ãŸã£ãŠããªã.ã¢ããŒã«ã¯è»œãæ¹ãã€ãããããã, ãªãã¹ã軜ãã¢ããŒã«ãäœããã.åè¿°ããããã«ã©ã®æ£ããã©ã³ã¹ãåããªãã, ã¢ããŒã«ã®ç·ééãæå°ã«ãããããªéã®ä»ãæ¹ãæ±ã, ãã®ãšãã®ã¢ããŒã«ã®ç·ééãåºåããããã°ã©ã ãäœã. ããã°ã©ã ã«ã¯ä»¥äžã®ã¢ããŒã«ã®æ§æã«é¢ããæ
å ±ãäžãããã.
</p>
<ul>
<li> æ£ã®æ¬æ° n</li>
<li> åæ£ããšã®æ
å ±(æ£ã®çªå·ã¯ 1 ãã n)</li>
<ul>
<li>æ¯ç¹ããèµ€ã®ç«¯ãŸã§ã®é·ããšæ¯ç¹ããéã®ç«¯ãŸã§ã®é·ãã®æ¯</li>
<li> èµ€ã®ç«¯ã«ã€ããæ£ã®çªå· (éãã€ããå Žå㯠0)</li>
<li> éã®ç«¯ã«ã€ããæ£ã®çªå· (éãã€ããå Žå㯠0)</li>
</ul>
</ul>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_lightestMobile2">
</center>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒå
¥åã¯ãŒãïŒã€ãå«ãè¡ã§çµäºããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ã¢ããŒã«ã«äœ¿ãããŠããæ£ã®æ¬æ° n ãæžãããŠãã.ç¶ã n è¡ (1 ≤ n ≤ 100) ã«ã¯,åã
ã®æ£ã®ããŒã¿ãæžãããŠãã.i + 1 è¡ç® (1 ≤ i ≤ n) ã«ã¯,4 ã€ã®æŽæ° p, q, r, b ã空çœãåºåããšããŠæžãããŠãã,æ£ i ã«ãããŠ,æ¯ç¹ããèµ€ã®ç«¯ãŸã§ã®é·ããšæ¯ç¹ããéã®ç«¯ãŸã§ã®æ¯ã p : q ã§ãã,èµ€ã®ç«¯ã«ã€ããããæ£ã®çªå·ã r ã§ãã,éã®ç«¯ã«ã€ããããæ£ã®çªå·ã b ã§ããããšãè¡šããŠãã.ãã ã,æ£çªå· 0 ã¯éãã€ããããããšãè¡šããŠãã.ãŸã,ã©ã®å
¥åã«ãããŠã,ã¢ããŒã«ã®ééã®æå°å€ã w ãšã,å
¥åäžã§æ¯ãè¡šãã®ã«çšããããæ£æŽæ°ã®æ倧å€ã L ãšãããš,wL < 2<sup>31</sup> ãæºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 15 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt 㯠1 è¡ã ãã§ãã,ã¢ããŒã«ã®ééãåºåãã.
-->
ããŒã¿ã»ããããšã«ã¢ããŒã«ã®ééãïŒè¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
1
6 9 0 0
4
3 2 0 4
1 3 0 0
4 4 2 1
2 2 0 0
0
</pre>
<h3>åºåäŸ</h3>
<pre>
5
40
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n2 2 0 0\n0\n",
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n2 2 0 0\n0\n"
]
] |
p00444 | Change |
<H1> ãã€ã </H1>
<h2>åé¡</h2>
<p>
倪éåã¯ããJOIé貚åºã§è²·ãç©ãããïŒ JOIé貚åºã«ã¯ç¡¬è²šã¯500åïŒ100åïŒ50åïŒ10åïŒ5åïŒ1åãååãªæ°ã ãããïŒãã€ãæãææ°ãå°ãªããªããããªãã€ãã®æ¯æãæ¹ãããïŒå€ªéåãJOIé貚åºã§è²·ãç©ãããŠã¬ãžã§1000åæã1æåºããæïŒããããã€ãã«å«ãŸãã硬貚ã®ææ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<p>
äŸãã°å
¥åäŸ1ã®å Žåã¯äžã®å³ã«ç€ºãããã«ïŒ4ãåºåããªããã°ãªããªãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_otsuri">
</center>
<br>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯1è¡ãããªãïŒå€ªéåãæ¯æãéé¡ïŒ1以äž1000æªæºã®æŽæ°ïŒã1ã€ã ãæžãããŠããïŒå
¥åããŒã¿ã¯ãŒãïŒã€ã®è¡ã§çµäºããïŒ
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯1è¡ã®ã¿ã§ããïŒãã€ãã«å«ãŸãã硬貚ã®ææ°ãåºåããïŒ-->
ããŒã¿ã»ããããšã«ãã€ãã«å«ãŸãã硬貚ã®ææ°ã1è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
380
1
0
</pre>
<h3>åºåäŸ</h3>
<pre>
4
15
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"380\n1\n0\n",
"380\n1\n0\n"
]
] |
p00445 | JOI and IOI |
<H1> JOIãšIOI </H1>
<h2>åé¡</h2>
<p>
äžããããæååå
ã®é£ç¶ãã3æåãïŒJOIãŸãã¯IOIãšãã䞊ã³ã«ãªã£ãŠããåæãããããäœåæããã®ããæ°ãäžããããã°ã©ã ãäœæããïŒæååã¯ã¢ã«ãã¡ãããã®å€§æåã ããããªãïŒäŸãã°äžå³ã®ãJOIOIOIããšããæååã«ã¯JOIã1åæïŒIOIã2åæã«å«ãŸããŠããïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_joiioi">
<br>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯1è¡ã§ããïŒ10000æå以äžã®ã¢ã«ãã¡ãããã®å€§æåãããªãïŒå
¥å㯠EOF ã§çµäºãã.
</p>
<p>
ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯2è¡ãããªãïŒ 1è¡ç®ã«èŠã€ãã£ãJOIã®åæ°ïŒ2è¡ç®ã«èŠã€ãã£ãIOIã®åæ°ãããããåºåããïŒ-->
ããŒã¿ã»ããããšã«, 1è¡ç®ã«èŠã€ãã£ãJOIã®åæ°ïŒ2è¡ç®ã«èŠã€ãã£ãIOIã®åæ°ãããããåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
JOIJOI
JOIOIOIOI
JOIOIJOINXNXJIOIOIOJ
</pre>
<h3>åºåäŸ</h3>
<pre>
2
0
1
3
2
3
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"JOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ\n",
"JOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ\n"
]
] |
p00446 | Card Game |
<H1> ã«ãŒãã²ãŒã </H1>
<h2>åé¡</h2>
<p>
次ã®ãããª2人ã§è¡ãã«ãŒãã²ãŒã ãããïŒ
</p>
<ul>
<li> ãã®ã²ãŒã ã§ã¯ïŒ 1ãã2nãŸã§ã®åæŽæ°ãæžãããå
šéšã§2næã®ã«ãŒãã䜿çšããïŒ ããã§ïŒnã¯1以äž100以äžã®æŽæ°ã§ããïŒ</li>
<li> ãã®ã«ãŒãã2人ã«næãã€é
ãïŒ</li>
<li> 次ã®ã«ãŒã«ã«åŸã£ãŠäº€äºã«ã«ãŒãã1æãã€å Žã«åºãïŒ</li>
<ul>
<li> å Žã«ã«ãŒããåºãŠããªããªãã°ïŒ 奜ããªã«ãŒããåºãããšãã§ããïŒ</li>
<li> å Žã«ã«ãŒããåºãŠãããªãã°ïŒ æåŸã«å Žã«åºãã«ãŒãããã倧ããæ°ã®æžãããã«ãŒããåºãããšãã§ããïŒ</li>
<li> ã«ãŒããåºããå Žåã¯ïŒå¿
ãå Žã«ã«ãŒããåºãå¿
èŠãããïŒ</li>
<li> åºããã«ãŒããç¡ãå Žåã¯ãã¹ãšãªãïŒçžæã®çªã«ãªãïŒ ãã®ãšãïŒå Žã«åºãŠããã«ãŒãã¯ç¡ããªãïŒ </li>
</ul>
<li> ã²ãŒã ã¯å Žã«ã«ãŒããåºãŠããªãç¶æ
ã§å§ããïŒ</li>
<li> ã©ã¡ããã®ææã¡ã®ã«ãŒããç¡ããªã£ãæç¹ã§ã²ãŒã ã¯çµäºããïŒ</li>
<li> ã²ãŒã çµäºæã«çžæã®æã£ãŠããã«ãŒãã®ææ°ãåŸç¹ãšããïŒ</li>
</ul>
<p>
倪éãšè±åã¯ïŒãã®ã²ãŒã ã§å¯ŸæŠããããšã«ãªã£ãïŒã²ãŒã ã¯å€ªéã®çªããå§ããïŒ 2人ã¯å
±ã«ïŒåºãããšã®ã§ããã«ãŒãã®ãã¡å¿
ãäžçªå°ããæ°ãæžãããã«ãŒããåºãããšã«ããŠããïŒ
</p>
<p>
倪éã«é
ãããã«ãŒããå
¥åããããšãïŒå€ªéãšè±åã®åŸç¹ãåºåããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥å㯠n+1 è¡ããïŒ 1è¡ç®ã«ã¯æŽæ°nãæžãããŠããïŒ 2è¡ç®ããn+1è¡ç®ãŸã§ã®åè¡ã«ã¯æŽæ°ã1ã€ãã€æžãããŠããïŒå€ªéã«é
ãããã«ãŒãã«æžãããæŽæ°ãè¡šãïŒ
</p>
<p>
n ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯2è¡ãããªãïŒ 1è¡ç®ã«ã¯å€ªéã®åŸç¹ãïŒ 2è¡ç®ã«ã¯è±åã®åŸç¹ãåºåããïŒ -->
ããŒã¿ã»ããããšã« 1è¡ç®ã«ã¯å€ªéã®åŸç¹ãïŒ 2è¡ç®ã«ã¯è±åã®åŸç¹ãåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5
1
7
9
6
10
10
8
7
14
18
4
11
3
17
5
19
0
</pre>
<h3>åºåäŸ</h3>
<pre>
3
0
2
0
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0\n",
"5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0\n"
]
] |
p00447 | Searching Constellation |
<H1>æ座æ¢ã </H1>
<h2>åé¡</h2>
<p>
ããªãã¯æ空ã®åçã®äžããæ座ãæ¢ããŠããïŒåçã«ã¯å¿
ãïŒæ¢ãããæ座ãšåã圢ã»åãã»å€§ããã®å³åœ¢ãã¡ããã©äžã€å«ãŸããŠããïŒãã ãïŒåçã®äžã«ã¯æ座ãæ§æããæ以å€ã«äœåãªæãåã£ãŠããå¯èœæ§ãããïŒ
</p>
<p>
äŸãã°ïŒå³ 1 ã®æ座ã¯å³ 2 ã®åçã«å«ãŸããŠããïŒäžžã§å²ãã§ç€ºããïŒïŒäžããããæ座ã®æã®åº§æšã x æ¹åã« 2ïŒ y æ¹åã« â3 ã ãå¹³è¡ç§»åãããšåçã®äžã®äœçœ®ã«ãªãïŒ
</p>
<p>
æ¢ãããæ座ã®åœ¢ãšåçã«åã£ãŠããæã®äœçœ®ãäžãããããšãïŒæ座ã®åº§æšãåçã®äžã®åº§æšã«å€æããããã«å¹³è¡ç§»åããã¹ãéãçããããã°ã©ã ãæžãïŒ
</p>
<table style="margin-left: 30px; margin-right: 30px; text-align: center;">
<col><col>
<tr><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_constellation1" width="270" height="270"></td><td><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_constellation2" width="270" height="270"></td></tr>
<tr><td>å³ 1: æ¢ãããæ座</td><td>å³ 2: æ空ã®åç</td></tr>
</table>
<br>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã® 1 è¡ç®ã«ã¯æ¢ãããæ座ãæ§æããæã®åæ° <i>m</i> ãæžãããŠããïŒç¶ã <i>m</i> è¡ã«ã¯æ¢ãããæ座ãæ§æãã <i>m</i> åã®æã® x 座æšãš y 座æšã瀺ãæŽæ°ã空çœåºåãã§æžãããŠããïŒ <i>m</i>+2 è¡ç®ã«ã¯åçã«åã£ãŠããæã®åæ° <i>n</i> ãæžãããŠããïŒç¶ã <i>n</i> è¡ã«ã¯åçã«åã£ãŠãã <i>n</i> åã®æã® x 座æšãš y 座æšã瀺ãæŽæ°ã空çœåºåãã§æžãããŠããïŒ
</p>
<p>
æ座ãæ§æãã <i>m</i> åã®æã®äœçœ®ã¯ãã¹ãŠç°ãªãïŒãŸãïŒåçã«åã£ãŠãã <i>n</i> åã®æã®äœçœ®ã¯ãã¹ãŠç°ãªãïŒ 1 ≤ <i>m</i> ≤ 200ïŒ 1 ≤ <i>n</i> ≤ 1000 ã§ããïŒæã® x 座æšãš y 座æšã¯ãã¹ãŠ 0 ä»¥äž 1000000 以äžã§ããïŒ
</p>
<p>
<i>m</i> ã 0ãã®ãšãå
¥åã®çµããã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--æåºããåºåãã¡ã€ã«-->åããŒã¿ã»ããã®åºå㯠1 è¡ãããªãïŒ 2 åã®æŽæ°ã空çœåºåãã§æžãïŒãããã¯æ¢ãããæ座ã®åº§æšãã©ãã ãå¹³è¡ç§»åããã°åçã®äžã®åº§æšã«ãªãããè¡šãïŒæåã®æŽæ°ã x æ¹åã«å¹³è¡ç§»åããéïŒæ¬¡ã®æŽæ°ã y æ¹åã«å¹³è¡ç§»åããéã§ããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5
8 5
6 4
4 3
7 10
0 10
10
10 5
2 7
9 7
8 10
10 2
1 2
8 1
6 7
6 0
0 9
5
904207 809784
845370 244806
499091 59863
638406 182509
435076 362268
10
757559 866424
114810 239537
519926 989458
461089 424480
674361 448440
81851 150384
459107 795405
299682 6700
254125 362183
50795 541942
0
</pre>
<h3>åºåäŸ</h3>
<pre>
2 -3
-384281 179674
</pre>
<p>
å
¥åºåäŸã®ïŒã€ç®ã¯äžã®å³ã«å¯Ÿå¿ããŠããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 541942\n0\n",
"5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 541942\n0\n"
]
] |
p00448 | Osenbei |
<H1> ãããã¹ã </H1>
<h2>åé¡</h2>
<p>
IOI補èã§ã¯ïŒåµæ¥ä»¥æ¥ã®äŒçµ±ã®è£œæ³ã§ç
é€
ïŒããã¹ãïŒãçŒããŠããïŒãã®äŒçµ±ã®è£œæ³ã¯ïŒçç«ã§äžå®æéè¡šåŽãçŒãïŒè¡šåŽãçŒãããšè£è¿ããŠïŒçç«ã§äžå®æéè£åŽãçŒããšãããã®ã§ããïŒãã®äŒçµ±ãå®ãã€ã€ïŒç
é€
ãæ©æ¢°ã§çŒããŠããïŒãã®æ©æ¢°ã¯çžŠ R (1 ≤ R ≤ 10) è¡, 暪 C (1 ≤ C ≤ 10000) åã®é·æ¹åœ¢ç¶ã«ç
é€
ã䞊ã¹ãŠçŒãïŒéåžžã¯èªåé転ã§ïŒè¡šåŽãçŒãããäžæã«ç
é€
ãè£è¿ãè£åŽãçŒãïŒ
</p>
<p>
ããæ¥ïŒç
é€
ãçŒããŠãããšïŒç
é€
ãè£è¿ãçŽåã«å°éãèµ·ããäœæãã®ç
é€
ãè£è¿ã£ãŠããŸã£ãïŒå¹žããªããšã«çç«ã®ç¶æ
ã¯é©åãªãŸãŸã§ãã£ããïŒãã以äžè¡šåŽãçŒããšåµæ¥ä»¥æ¥ã®äŒçµ±ã§å®ããããŠããçŒãæéãè¶
ããŠããŸãïŒç
é€
ã®è¡šåŽãçŒããããŠååãšããŠåºè·ã§ããªããªãïŒããã§ïŒæ¥ãã§æ©æ¢°ãããã¥ã¢ã«æäœã«å€æŽãïŒãŸã è£è¿ã£ãŠããªãç
é€
ã ããè£è¿ãããšããïŒãã®æ©æ¢°ã¯ïŒæšªã®è¡ãäœè¡ãåæã«è£è¿ããã瞊ã®åãäœåãåæã«è£è¿ãããããããšã¯ã§ãããïŒæ®å¿µãªããšã«ïŒç
é€
ãïŒæããšè£è¿ãããšã¯ã§ããªãïŒ
</p>
<p>
è£è¿ãã®ã«æéãããããšïŒå°éã§è£è¿ããªãã£ãç
é€
ã®è¡šåŽãçŒããããŠååãšããŠåºè·ã§ããªããªãã®ã§ïŒæšªã®äœè¡ããåæã«ïŒåè£è¿ãïŒåŒãç¶ãïŒçžŠã®äœåããåæã«ïŒåè£è¿ããŠïŒè¡šåŽãçŒããããã«äž¡é¢ãçŒãããšã®ã§ããç
é€
ïŒã€ãŸãïŒãåºè·ã§ããç
é€
ãã®ææ°ããªãã¹ãå€ãããããšã«ããïŒæšªã®è¡ãïŒè¡ãè£è¿ããªãïŒãããã¯ïŒçžŠã®åãïŒåãè£è¿ããªãå Žåãèããããšã«ããïŒåºè·ã§ããç
é€
ã®ææ°ã®æ倧å€ãåºåããããã°ã©ã ãæžããªããïŒ
</p>
<p>
å°éã®çŽåŸã«ïŒç
é€
ã次ã®å³ã®ãããªç¶æ
ã«ãªã£ããšããïŒé»ãäžžãè¡šåŽãçŒããç¶æ
ãïŒçœãäžžãè£åŽãçŒããç¶æ
ãè¡šããŠããïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_osenbei1">
<p>
1è¡ç®ãè£è¿ããšæ¬¡ã®å³ã®ãããªç¶æ
ã«ãªãïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_osenbei2">
<p>
ããã«ïŒ 1åç®ãš5åç®ãè£è¿ããšæ¬¡ã®å³ã®ãããªç¶æ
ã«ãªãïŒãã®ç¶æ
ã§ã¯ïŒåºè·ã§ããç
é€
ã¯9æã§ããïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_osenbei3">
<h2>ãã³ã</h2>
<p>
R ã®äžé 10 㯠C ã®äžé 10000 ã«æ¯ã¹ãŠå°ããããšã«æ³šæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã®1è¡ç®ã«ã¯2ã€ã®æŽæ° R, C (1 ≤ R ≤ 10, 1 ≤ C ≤ 10 000) ã空çœãåºåããšããŠæžãããŠããïŒç¶ã R è¡ã¯å°éçŽåŸã®ç
é€
ã®ç¶æ
ãè¡šãïŒ (i+1) è¡ç® (1 ≤ i ≤ R) ã«ã¯ïŒ C åã®æŽæ° a<sub>i,1</sub>, a<sub>i,2</sub>, âŠâŠ, a<sub>i,C</sub> ã空çœãåºåããšããŠæžãããŠããïŒ a<sub>i,j</sub> 㯠i è¡ j å ã®ç
é€
ã®ç¶æ
ãè¡šããŠãã. a<sub>i,j</sub> ã 1 ãªãè¡šåŽãçŒããããšãïŒ 0 ãªãè£åŽãçŒããããšãè¡šãïŒ
</p>
<p>
C, R ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ãããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--æåºããåºåãã¡ã€ã«ã¯ïŒåºè·ã§ããç
é€
ã®æ倧ææ°ã ããå«ã1è¡ãããªãïŒ-->
ããŒã¿ã»ããããšã«ïŒåºè·ã§ããç
é€
ã®æ倧ææ°ã1è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
9
15
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n",
"2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n"
]
] |
p00449 | Boat Travel |
<H1>è¹æ
</H1>
<h2>åé¡</h2>
<p>
JOIåœã«ã¯ïŒn 島ã®å³¶ãããïŒå島ã«ã¯ 1 ãã n ãŸã§ã®çªå·ãä»ããããŠããïŒçŸåšïŒJOIåœã§ã¯å島ã®éãçµã¶èªè·¯ç¶²ã®æŽåãé²ãã§ããïŒ
</p>
<p>
ããªãã¯ïŒè¹è¶ã®å笊ãæ±ã£ãŠãããã±ããã»ã³ã¿ãŒã«å€åããŠããïŒJOIåœã«ã¯è¹è¶ã䜿ã£ãŠïŒã§ããéãå®äŸ¡ã«ïŒå³¶ãšå³¶ã®éãæ
è¡ããããšèããŠãã人ã沢山ããïŒåœŒãã¯ïŒåºçºå°ãšç®çå°ã泚æ祚ã«èšå
¥ããŠïŒããªãã®ãšããã«éã£ãŠããïŒ
</p>
<p>
ããªãã®ä»äºã¯ïŒå®¢ãã泚æ祚ãåãåã£ããããã«ïŒããã€ãã®è¹è¶ãä¹ãç¶ãã§ïŒåºçºå°ãšç®çå°ãçµã¶èªè·¯ã®äžã§ïŒãã£ãšãå®äŸ¡ãªéè³ãèšç®ãïŒå®¢ã«äŒããããšã§ããïŒ
ãã ãïŒæ
çšã«ãã£ãŠã¯ïŒè¹è¶ã䜿ã£ãŠæ
è¡ããããšãåºæ¥ãªãå ŽåãããïŒãã®ãšãã¯ãè¹è¶ã䜿ã£ãŠæ
è¡ããããšãåºæ¥ãªãããšå®¢ã«äŒããå¿
èŠãããïŒãŸãïŒJOIåœã§ã¯ïŒå³¶ãšå³¶ã®éãçµã¶æ°ããè¹è¶ãïŒæ¬¡ã
ãšéèªãéå§ããŠããïŒããªãã«ã¯ïŒãã®æ
å ±ãéæäŒããããïŒå®¢ã«è¿äºãããéã«ã¯ïŒææ°ã®æ
å ±ã«çæããªããã°ãªããªãïŒ
</p>
<p>
å
¥åãšããŠïŒå®¢ã®æ³šæ祚ãæ°ãã«éèªãéå§ããè¹è¶ã®éèªæ
å ±ãäžãããããšãã«ïŒå®¢ãžã®è¿äºãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<p>
ãªãïŒå
¥åäŸïŒãšåºåäŸïŒã«å¯Ÿããå®è¡ç¶æ³ãïŒå³ïŒãšããŠå³ç€ºããŠããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã® 1 è¡ç®ã«ã¯2ã€ã®æŽæ° n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 5000) ãæžãããŠããïŒããã¯ïŒå³¶ã®æ°ã n 島ã§ïŒå
¥åã k + 1 è¡ãããªãããšãè¡šãïŒ
i + 1 è¡ç® (1 ≤ i ≤ k) ã«ã¯ïŒ 3 åãŸã㯠4 åã®æŽæ°ã空çœãåºåããšããŠæžãããŠããïŒ
</p>
<ul>
<li> æåã®æ°åã 0 ã®ãšãïŒãã®è¡ã¯å®¢ã®æ³šæ祚ãè¡šãïŒ<br>
ãã®è¡ã«ã¯3åã®æŽæ° 0, a, b (1 ≤ a ≤ n, 1 ≤ b ≤ n, a ≠ b) ã空çœãåºåããšããŠæžãããŠããïŒ
ããã¯ïŒå®¢ãïŒå³¶ a ãåºçºå°ãšã島 b ãç®çå°ãšãããããªæ³šæ祚ãéã£ãŠããããšãè¡šãïŒ
</li>
<li> æåã®æ°åã 1 ã®ãšãïŒãã®è¡ã¯æ°ãã«éèªãéå§ããè¹è¶ã®éèªæ
å ±ãè¡šãïŒ<br>
ãã®è¡ã«ã¯ 4 åã®æŽæ° 1, c, d, e (1 ≤ c ≤ n, 1 ≤ d ≤ n, c ≠ d, 1 ≤ e ≤ 1000000) ãæžãããŠããïŒ<br>
ããã¯å³¶ c ãšå³¶ d ãåŸåŸ©ããè¹è¶ãæ°ãã«éèªãéå§ãïŒãã®è¹è¶ã®å³¶ c ãã島 d ãžã®éè³ãšïŒå³¶ d ãã島 c ãžã®éè³ãïŒå
±ã« e ã§ããããšãè¡šãïŒ<br>
ãã®è¡ä»¥éã®æ³šæ祚ã«å¯ŸããŠã¯ïŒãã®è¹è¶ãèæ
®ããŠè¿äºãããªããã°ãªããªãïŒ
</li>
</ul>
<p>
æåã®æ®µéã§ã¯ïŒè¹è¶ã¯äžé»ãéèªããŠããªããã®ãšããïŒå
¥åã®ãã¡ïŒè¹è¶ã®éèªæ
å ±ãè¡šãè¡ã¯ 1000 è¡ä»¥äžã§ããïŒãŸãïŒå³¶ãšå³¶ã®éã«ïŒè€æ°ã®è¹è¶ãéèªããããšãããããšã«æ³šæããïŒ
</p>
<p>
n, k ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«ä»¥äžã®åœ¢åŒã§åºåããïŒ
</p>
<p>
å
¥åã®ãã¡ïŒæ³šæ祚ãè¡šãè¡ã®æ°ã m ãšããïŒ
<!--æåºããåºåãã¡ã€ã«--> åããŒã¿ã»ããã®åºå㯠m è¡ãããªãïŒ i è¡ç®(1 ≤ i ≤ m)ã«ã¯ïŒ i çªç®ã®æ³šæ祚ã«å¯Ÿããè¿äºãè¡šãæŽæ°ãæžãïŒ
ããªãã¡ïŒ i çªç®ã®æ³šæ祚ã®åºçºå°ãšç®çå°ã®éãïŒããã€ãã®è¹è¶ãä¹ãç¶ãã§æ
è¡ããããšãå¯èœãªãã°ïŒãã®éè³ã®åèšã®æå°å€ãæžãïŒæ
è¡ããããšãäžå¯èœãªãã°ïŒ-1 ãåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3 8
1 3 1 10
0 2 3
1 2 3 20
1 1 2 5
0 3 2
1 1 3 7
1 2 1 9
0 2 3
5 16
1 1 2 343750
1 1 3 3343
1 1 4 347392
1 1 5 5497
1 2 3 123394
1 2 4 545492
1 2 5 458
1 3 4 343983
1 3 5 843468
1 4 5 15934
0 2 1
0 4 1
0 3 2
0 4 2
0 4 3
0 5 3
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
-1
15
12
5955
21431
9298
16392
24774
8840
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0\n",
"3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 2 343750\n1 1 3 3343\n1 1 4 347392\n1 1 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 15934\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0\n"
]
] |
p00450 | Setting Go Stones |
<H1> ç¢ç³ãªãã¹ </H1>
<h2>åé¡</h2>
<p>
çœãšé»ã®ç¢ç³ãããŒãã«ã®äžã«ãªãã¹ãŠéã¶.ãŸãããŒãã«ã®å·Šç«¯ã«ç¢ç³ã眮ã.次ã«å·Šãã 2 çªç®ã®å Žæã«ç¢ç³ã眮ã.ããã n åç¹°ãè¿ã㊠n åã®ç¢ç³ã暪äžåã«ãªãã¹ã.ãã ã,æ°ãã i çªç®ã®ç¢ç³ã眮ãéã«ã¯,次ã®ã«ãŒã«ã«åŸã£ãŠããŒãã«äžã®ç¢ç³ã眮ãæãã.
</p>
<ul>
<li> i ãå¥æ°ã®å Žå: ããŒãã«ã«çœ®ããŠãã£ãç¢ç³ã¯çœ®ãæãã,æ°ããç¢ç³ãå·Š
ãã i çªç®ã«çœ®ã.</li>
<li> i ãå¶æ°ã®å Žå: æ°ããå·Šãã i çªç®ã«çœ®ãç¢ç³ã®è²ãšããŒãã«äžã®å³ç«¯ã®ç¢
ç³ã®è²ãåãå Žåã¯,ããŒãã«äžã®ç¢ç³ã¯çœ®ãæãã,æ°ããç¢ç³ãå·Šãã i
çªç®ã«çœ®ã.ããã§ãªãå Žå,ããªãã¡,æ°ããå·Šãã i çªç®ã«çœ®ãç¢ç³ã®è²
ãšããŒãã«äžã®å³ç«¯ã®ç¢ç³ã®è²ãç°ãªãå Žåã¯,ãŸãããŒãã«äžã®å³ç«¯ã®é£ç¶
ããåè²ã®ç¢ç³ãå
šãŠåãé€ã,i çªç®ã®ç¢ç³ãšåè²ã®ç¢ç³ã«çœ®ãæãã.ã
ããŠããŒãã«ã®å³ç«¯ã« i çªç®ã®ç¢ç³ã眮ã.</li>
</ul>
<p>
äŸãã°,æåã® 7 åã®ç¢ç³ã眮ããæç¹ã§,
</p>
<p>
âââââââ
</p>
<p>
ãšãªã£ãŠãããšãã. (âã¯çœã®ç¢ç³ã,âã¯é»ã®ç¢ç³ãè¡šã. )
</p>
<ul>
<li> 8 çªç®ã®ç¢ç³ãçœ(â)ã®å Žåã¯,å³ç«¯ã®ç¢ç³ãšåè²ãªã®ã§,ãã®ãŸãŸçœ®ã.ã
ããã£ãŠ,ããŒãã«äžã®ç¢ç³ã¯<br>
<p>ââââââââ</p>
ãšãªã.
</li>
<li> 8 çªç®ã®ç¢ç³ãé»(â)ã®å Žåã¯,å³ç«¯ã®ç¢ç³(â)ãšè²ãç°ãªãã®ã§,ãŸã
ããŒãã«ã®å³ç«¯ã«ãã 3 åã®é£ç¶ããçœãç¢ç³(â)ãåãé€ã,é»ãç¢ç³
(â)ã«çœ®ãæãã.ãããŠå³ç«¯ã« 8 çªç®ã®ç¢ç³ã眮ã.ãããã£ãŠ,ããŒã
ã«äžã®ç¢ç³ã¯<br>
<p>
ââââââââ
</p>
ãšãªã.
</li>
</ul>
<p>
å
¥åãšããŠçœ®ãç¢ç³ã®é çªãäžãããããšã,n åã®ç¢ç³ããªãã¹çµãã£ãåŸ,ããŒ
ãã«äžã«çœ®ããŠããçœãç¢ç³ã®åæ°ãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
1 è¡ç®ã«ã¯æ£æŽæ° n (1 ≤ n ≤ 100000) ãæžãããŠãã.2 è¡ç®ä»¥éã®ç¬¬ i + 1 è¡ç® (1 ≤ i ≤ n) ã«ã¯,i çªç®ã«çœ®ãç¢ç³ã®è²ãè¡šãæŽæ° c<sub>i</sub> ãæžãããŠãã,c<sub>i</sub> ã 0 ãªã i çªç®ã«çœ®ãç¢ç³ã®è²ãçœã§ããããšã,1 ãªã i çªç®ã«çœ®ãç¢ç³ã®è²ãé»ã§ããããšãè¡šã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 50% åã«ã€ããŠã¯, n ≤ 10000 ãæºãã.
</p>
<p>
n ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!-- åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt ã¯,n åã®ç¢ç³ããªãã¹çµãã£ãåŸã«ããŒãã«äžã«çœ®ããŠããçœãç¢ç³ã®åæ°ã ããå«ã 1 è¡ãããªã.
-->
ããŒã¿ã»ããããšã«, n åã®ç¢ç³ããªãã¹çµãã£ãåŸã«ããŒãã«äžã«çœ®ããŠããçœãç¢ç³ã®åæ°ã 1 è¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
8
1
0
1
1
0
0
0
0
8
1
0
1
1
0
0
0
1
0
</pre>
<h3>åºåäŸ</h3>
<pre>
6
2
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"8\n1\n0\n1\n1\n0\n0\n0\n0\n8\n1\n0\n1\n1\n0\n0\n0\n1\n0\n",
"8\n1\n0\n1\n1\n0\n0\n0\n0\n8\n1\n0\n1\n1\n0\n0\n0\n1\n0\n"
]
] |
p00451 | Common Sub-String |
<H1> å
±ééšåæåå </H1>
<h2>åé¡</h2>
<p>
2 åã®æååãäžãããããšã, äž¡æ¹ã®æååã«å«ãŸããæååã®ãã¡æãé·ããã®ãæ¢ã, ãã®é·ããçããããã°ã©ã ãäœæãã.
</p>
<p>
ããã§, æåå s ãæåå t ã«å«ãŸãããšã¯, t ã®äžã« s ãé£ç¶ããŠçŸããããšããã. 空æåå, ããªãã¡é·ã 0 ã®æååã¯, ã©ããªæååã«ãå«ãŸãã. äŸãã°, æåå ABRACADABRA ã«ã¯æ¬¡ã®æååãå«ãŸãã: ABRA, RAC, D, ACADABRA, ABRACADABRA,空æååãªã©. äžæ¹, æåå ABRACADABRA ã«ã¯æ¬¡ã®æååã¯å«ãŸããªã: ABRC, RAA,BA, K ãªã©.
</p>
<h2>äŸ</h2>
<p>
äŸ 1: æååãšã㊠ABRACADABRA ãš ECADADABRBCRDARA ãäžããããå Žå, äž¡æ¹ã«å«ãŸããæååã«ã¯ CA ã CADA ã ADABR ã空æååãªã©ããã. ãã®ãã¡æãé·ãã®ã¯ ADABR ã§ãã, ãã®é·ã㯠5 ã§ãã. 2 åã®æååã®äžã«å«ãŸãã ADABR
ã®äœçœ®ã以äžã«ç€ºã.
<br><br>
<span>ABRAC<u>ADABR</u>A</span><br>
<span>ECAD<u>ADABR</u>BCRDARA</span><br>
<!-- <p> å³ 2-1 äŸ 1 ã®æååã®äžã«çŸãã ADABR ã®äœçœ®</p>-->
</p>
<p>
äŸ 2: æååãšã㊠<span>UPWJCIRUCAXIIRGL</span> ãš <span>SBQNYBSBZDFNEV</span> ãäžããããå Žå, äž¡æ¹ã«å«ãŸããæååã¯ç©ºæååã®ã¿ã§ãã, ãã®é·ã㯠0 ã§ãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥å㯠2 è¡ãããªã, 1 è¡ç®ã« 1 åç®ã®æååã, 2 è¡ç®ã« 2 åç®ã®æååãäžãããã. æååã¯è±å€§æåãããªã, åã
ã®æååã®é·ã㯠1 ä»¥äž 4000 以äžã§ãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 30% åã«ã€ããŠã¯, åã
ã®æååã®é·ã㯠1 ä»¥äž 50以äžã§ãã.
</p>
<p>
å
¥åã®çµãã㯠EOF ã§ç€ºããã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
</p>
<p>
output.txt ã¯,äžãããã 2 åã®æååã®äž¡æ¹ã«å«ãŸããæååã®ãã¡æãé·ããã®ã®é·ãã ããå«ã 1 è¡ãããªã.
</p>
-->
<p>
ããŒã¿ã»ããããšã«äžãããã 2 åã®æååã®äž¡æ¹ã«å«ãŸããæååã®ãã¡æãé·ããã®ã®é·ãã 1 è¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
ABRACADABRA
ECADADABRBCRDARA
UPWJCIRUCAXIIRGL
SBQNYBSBZDFNEV
</pre>
<h3>åºåäŸ</h3>
<pre>
5
0
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"ABRACADABRA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV\n",
"ABRACADABRA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV\n"
]
] |
p00452 | Darts |
<H1>ããŒã </H1>
<h2>åé¡</h2>
<p>
ããªãã¯ä»¥äžã®ã«ãŒã«ã§ããŒãã²ãŒã ãããããšã«ãªã£ã.
</p>
<p>
ããªãã¯,ç¢ãç(ãŸãš)ã«åãã£ãŠ 4 æ¬ãŸã§æããããšãã§ãã.å¿
ããã 4 æ¬å
šãŠãæããå¿
èŠã¯ãªã,1 æ¬ãæããªããŠãããŸããªã.ç㯠N åã®éšåã«åºåãããŠããŠ,åã
ã®éšåã«ç¹æ° P<sub>1</sub>,..., P<sub>N</sub> ãæžã ããŠãã.ç¢ãåºãã£ãå Žæã®ç¹æ°ã®åèš S ãããªãã®åŸç¹ã®åºç€ãšãªã.S ãããããã決ããããããç¹æ° M 以äžã®å Žå㯠S ããã®ãŸãŸããªãã®åŸç¹ãšãªã.ããã,S ã M ãè¶
ããå Žåã¯ããªãã®åŸç¹ã¯ 0 ç¹ãšãªã.
</p>
<p>
çã«æžãããŠããç¹æ°ãš M ã®å€ãäžãããããšã,ããªããåŸãããšã®ã§ããç¹æ°ã®æ倧å€ãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯,æŽæ° N (1 ≤ N ≤ 1000) ãš M (1 ≤ M ≤ 200000000 = 2 × 10<sup>8</sup>)ããã®é ã«ç©ºçœåºåãã§æžãããŠãã.2 è¡ç®ä»¥éã®ç¬¬ 1 + i è¡ç® (1 ≤ i ≤ N ) ã«ã¯, P<sub>i</sub> (1 ≤ P<sub>i</sub> ≤ 100000000 = 10<sup>8</sup> ) ãæžãããŠãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 20% å㯠N ≤ 100 ãæºãã,é
ç¹ã® 50% åã¯N ≤ 300 ãæºãã.
</p>
<p>
N, M ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt 㯠1 è¡ã ããããªã,ããªããåŸãããšã®ã§ããç¹æ°ã®æ倧å€ãå«ã.
-->
ããŒã¿ã»ããããšã«ããªããåŸãããšã®ã§ããç¹æ°ã®æ倧å€ãïŒè¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
4 50
3
14
15
9
3 21
16
11
2
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
48
20
</pre>
<p>
1ã€ç®ã®äŸã§ã¯,15 ç¹ã®éšåã« 3 æ¬,3 ç¹ã®éšåã« 1 æ¬ã®ç¢ãåºãã£ãå Žåã«ããªãã®åŸç¹ã¯æ倧ã«ãªã,ãã®åŸç¹ã¯ 48 ç¹ã§ãã.
</p>
<p>
2ã€ç®ã®äŸã§ã¯,16 ç¹ã®å Žæã« 1 æ¬,2 ç¹ã®å Žæã« 2 æ¬ã®ç¢ãåºãã£ãå Žåã«ããªãã®åŸç¹ã¯æ倧ã«ãªã,ãã®åŸç¹ã¯ 20 ç¹ã§ãã.
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4 50\n3\n14\n15\n9\n3 21\n16\n11\n2\n0 0\n",
"4 50\n3\n14\n15\n9\n3 21\n16\n11\n2\n0 0\n"
]
] |
p00453 | Pyon-Pyon River Crossing |
<H1> ãŽãããŽããå·æž¡ã </H1>
<h2>åé¡</h2>
<p>
ããå·ã§,äžæ¹ã®å²žããç³ã®äžã次ã
ãšé£ã³ç§»ã£ãŠå察åŽã®å²žãŸã§è¡ããšããå°ã
å±éºãªã²ãŒã ãã¯ãã£ãŠãã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_hyonhyon1">
</center>
<br>
<p>
ä»,å³ 4-1 ã®ããã«,ç³ã¯ãã¹ç®ã®äžã«ååšãããšèãã.è¡ã®æ°ã¯ n ã§ãã. å³ 4-1 ã§ã¯ n = 5 ã§ãã.
</p>
<p>
ãã®ã²ãŒã ã§ã¯,äžæ¹ã®å²žããå§ããŠ,éåžžã®ãžã£ã³ããŸã㯠m å以äžã®äžè¡é£ã°ãã®ãžã£ã³ããããŠå察åŽã®å²žãŸã§æž¡ã.éåžžã®ãžã£ã³ããšã¯,ä»ããè¡ã®äžã€å
ã®è¡ã®å²žãŸãã¯ç³ã®ã©ããã«é£ã³ç§»ãããšã§ãã,äžè¡é£ã°ãã®ãžã£ã³ããšã¯,ä»ããè¡ã®äºã€å
ã®è¡ã®å²žãŸãã¯ç³ã®ã©ããã«é£ã³ç§»ãããšã§ãã.å§ãã岞ã®äžã€å
ã®è¡ã¯ 1 è¡ç®,äºã€å
ã®è¡ã¯ 2 è¡ç®ã§ãã,n â 1 è¡ç®ã®äºã€å
ã®è¡,åã³ n è¡ç®ã®äžã€å
ã®è¡ã¯å察åŽã®å²žã§ãããšãã.
</p>
<p>
ããŠ,ãã®ã²ãŒã ãã§ããã ãå®å
šã«æãéããããã«,ãžã£ã³ãã®å±éºåºŠãšãããã®ãèããããšã«ãã.ããããã®ç³ã«ã¯,æ»ãããããå®ãŸã£ãŠãã.ç³ããç³ãžé£ã³ç§»ãéã®ãžã£ã³ãã®å±éºåºŠã¯,éåžžã®ãžã£ã³ãã§ãã£ãŠã,äžè¡é£ã°ãã®ãžã£ã³ãã§ãã£ãŠã,
</p>
<p>
(ä»ããç³ã®æ»ãããã + é£ã³ç§»ãå
ã®ç³ã®æ»ãããã)×(暪ã®ç§»åè·é¢)
</p>
<p>
ã§å®ãã.ãã ã,暪ã®ç§»åè·é¢ãšã¯,åã®çªå·ã®å·®ã§ãã.ãŸã,岞ããç³ãž,ãããã¯ç³ãã岞ãžé£ã³ç§»ããžã£ã³ãã®å±éºåºŠã¯ 0 ãšãã.
</p>
<p>
å
¥åãšã㊠n, m,ããããã®ç³ã®äœçœ®ãšæ»ãããããäžãããããšã,å察åŽã®å²žãŸã§å°éããéã®ãžã£ã³ãã®å±éºåºŠã®åèšã®æå°å€ãæ±ããããã°ã©ã ãäœæãã.äžããããå
¥åããŒã¿ã¯å¿
ãå察åŽã®å²žãŸã§å°éããããšãã§ããããã«ãªã£ãŠãã,åããã¹ç®ã«ç³ã¯ 2 å以äžååšããªã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã® 1 è¡ç®ã«ã¯,空çœãåºåããšã㊠2 åã®æŽæ° n,m ãæžãããŠãã.ããã¯,è¡ã®æ°ãš,äžè¡é£ã°ãã®ãžã£ã³ãã®èš±ãããåæ°ãè¡šã.n,m ã¯ãããã 2 ≤ n ≤ 150, 0 ≤ m ≤ (n+1)/2ããæºãã.
</p>
<p>
ç¶ã n è¡ã«ã¯,ããããã®è¡ã«ããç³ã®æ
å ±ãæžãããŠãã.i+1 è¡ç® (1 ≤ i ≤ n)ã«ã¯,1 ã€ã®æŽæ° k<sub>i</sub> (0 ≤ k<sub>i</sub> ≤ 10) ãš,ããã«ç¶ã 2 × ki åã®æŽæ°ã空çœã§åºåããæžãããŠãã.ãããã¯,å§ãã岞ããæ°ã㊠i çªç®ã®è¡ã«ããç³ã®æ
å ±ãè¡šã.
</p>
<p>
ki ã¯ãã®è¡ã«ååšããç³ã®åæ°ãè¡šã,ããã«ç¶ã 2 × ki åã®æŽæ°ã«ã€ããŠã¯,2 × j - 1 åç® (1 ≤ j ≤ k<sub>i</sub> ) ã®æŽæ° x<sub>i,j</sub> ã¯ãã®è¡ã® j åç®ã®ç³ã®åã®çªå·ã,2 × jåç®ã®æŽæ° d<sub>i,j</sub> ã¯ãã®è¡ã® j åç®ã®ç³ã®æ»ãããããããããè¡šã.x<sub>i,j</sub> ,d<sub>i,j</sub> ã¯ãããã 1 ≤ x<sub>i,j</sub>, d<sub>i,j</sub> ≤1000 ãæºãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 20% åã«ã€ããŠã¯, n ≤ 6 ãæºãã,é
ç¹ã®å¥ã® 20%åã«ã€ããŠã¯, m = 0 ãæºãã.
</p>
<p>
n, m ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt ã¯,å察åŽã®å²žãŸã§å°éããéã®ãžã£ã³ãã®å±éºåºŠã®åèšã®æå°å€ãè¡šã 1 ã€ã®æŽæ°ãå«ã 1 è¡ãããªã.
-->
ããŒã¿ã»ããããšã«, å察åŽã®å²žãŸã§å°éããéã®ãžã£ã³ãã®å±éºåºŠã®åèšã®æå°å€ãè¡šã 1 ã€ã®æŽæ°ã1 è¡ã«åºåãã.
</p>
<h2>äŸ</h2>
<p>
å³ 4-2 ã«ãããŠ,ç³ã«æžãããæ°åã¯ããããã®ç³ã®æ»ãããããè¡šããšãã.
ç¢å°ã§ç€ºãããé çªã§ç³ãæž¡ããšã,ããããã®ãžã£ã³ãã®å±éºåºŠã¯,é çªã« 0,
(2 + 2) × 1 = 4,(2 + 1) × 1 = 3,(1 + 4) × 2 = 10,0 ã§ãã,åèšã¯ 17 ãšãªã.
ãã®ãšã,ãžã£ã³ãã®å±éºåºŠã®åèšã¯æå°ãšãªã.
ãã®äŸã¯ïŒã€ç®ã®å
¥åºåäŸã«å¯Ÿå¿ããŠãã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_hyonhyon2">
</center>
<br>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5 1
2 1 3 2 2
1 3 2
1 1 7
1 2 1
1 4 4
5 0
2 1 3 2 2
1 3 2
1 1 7
1 2 1
1 4 4
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
17
40
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n0 0\n",
"5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n0 0\n"
]
] |
p00454 | Paint Color |
<H1> ãã³ãã®è² </H1>
<h2>åé¡</h2>
<p>
æ
å ±ãªãªã³ããã¯ã®å®£äŒã®ããã«,é·æ¹åœ¢ã®ããã€æ¿ã«ãã³ããå¡ãçæ¿ãå¶äœããã.ããã€æ¿ã«ã¯è²ãå¡ããããªããšããã«ãããããäœæãã®é·æ¹åœ¢ã®ãã¹ãã³ã°ããŒãã貌ãããŠãã.ããã§ãã¹ãã³ã°ããŒãã§åºåãããé åããšã«å¥ã
ã®è²ã䜿ããã³ããå¡ãããšã«ãã.äŸãã°,å³ 5-1 ã®å Žå㯠5 è²ã®ãã³ãã䜿ã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_penki1">
</center>
<br>
<p>
å
¥åãšããŠãã¹ãã³ã°ããŒãã貌ãäœçœ®ãäžããããæ,䜿ããã³ãã®è²ã®æ°ãæ±ããããã°ã©ã ãäœæãã.ãã ã,ããã€æ¿å
šäœããã¹ãã³ã°ããŒãã§èŠãããããšã¯ãªã,å
šãŠã®ãã¹ãã³ã°ããŒãã®èŸºã¯ããã€æ¿ã®ããããã®èŸºã«å¹³è¡ã§ãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ããã€æ¿ã®å¹
w (1 ≤ w ≤ 1000000 ãšãªãæŽæ°) ãšé«ã h (1 ≤ h ≤ 1000000 ãšãªãæŽæ°) ããã®é ã«ç©ºçœåºåãã§æžãããŠãã.
</p>
<p>
2 è¡ç®ã«ã¯ãã¹ãã³ã°ããŒãã®æ° n (1 ≤ n ≤ 1000 ãšãªãæŽæ°) ãæžãããŠãã.
ç¶ã 3 è¡ç®ä»¥éã® 2 + i è¡ç® (1 ≤ i ≤ n) ã«ã¯,i çªç®ã«è²Œããã¹ãã³ã°ããŒãã®å·Šäžã®åº§æš (x<sub>1</sub> , y<sub>1</sub> ) ãš,å³äžã®åº§æš (x<sub>2</sub> , y<sub>2</sub> ) ã x<sub>1</sub> , y<sub>1</sub> , x<sub>2</sub> , y<sub>2</sub> (0 ≤ x<sub>1</sub> < x<sub>2</sub> ≤ w, 0 ≤ y<sub>1</sub> < y<sub>2</sub> ≤ h ãšãªãæŽæ°) ã®é ã«ç©ºçœåºåãã§æžãããŠãã.
</p>
<p>
ãã ã,ããã€æ¿ã®å·Šäžã®è§ã®åº§æšã¯ (0, 0) ã§å³äžã®è§ã®åº§æšã¯ (w, h) ã§ãã. æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 30% å㯠w ≤ 100, h ≤ 100, n ≤ 100 ãæºãã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_penki2">
</center>
<br>
<p>
h, w ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 20 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt 㯠1 è¡ã ããããªã,ãã® 1 è¡ã¯äœ¿ããã³ãã®è²æ°ã ããå«ã.
-->
ããŒã¿ã»ããããšã«äœ¿ããã³ãã®è²æ°ãïŒè¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<p>次ã®äŸã¯å³ 5-1 ã®å Žåã§ãã.</p>
<h3>å
¥åäŸ</h3>
<pre>
15 6
10
1 4 5 6
2 1 4 5
1 0 5 1
6 1 7 5
7 5 9 6
7 0 9 2
9 1 10 5
11 0 14 1
12 1 13 5
11 5 14 6
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
5
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"15 6\n10\n1 4 5 6\n2 1 4 5\n1 0 5 1\n6 1 7 5\n7 5 9 6\n7 0 9 2\n9 1 10 5\n11 0 14 1\n12 1 13 5\n11 5 14 6\n0 0\n",
"15 6\n10\n1 4 5 6\n2 1 4 5\n1 0 5 1\n6 1 7 5\n7 5 9 6\n7 0 9 2\n9 1 10 5\n11 0 14 1\n12 1 13 5\n11 5 14 6\n0 0\n"
]
] |
p00455 | Time Card |
<H1>ã¿ã€ã ã«ãŒã </H1>
<h2>åé¡</h2>
<p>
JOIåäºã§ã¯ç€Ÿå¡ã®åšç€Ÿæéãã¿ã€ã ã«ãŒãã§ç®¡çããŠããïŒç€Ÿå¡ã¯ïŒåºç€Ÿãããšå°çšã®è£
眮ã䜿ã£ãŠã¿ã€ã ã«ãŒãã«åºç€Ÿæå»ãå»å°ããïŒå€åãçµãé瀟ãããšãã«ãïŒã¿ã€ã ã«ãŒãã«é瀟æå»ãå»å°ããïŒæå»ã¯24æéå¶ã§æ±ãããïŒ
</p>
<p>
é²ç¯äžã®çç±ããïŒç€Ÿå¡ã®åºç€Ÿæå»ã¯7æ以éã§ããïŒãŸãïŒå
šãŠã®ç€Ÿå¡ã¯23æããåã«é瀟ããïŒç€Ÿå¡ã®é瀟æå»ã¯åžžã«åºç€Ÿæå»ããåŸã§ããïŒ
</p>
<p>
å
¥åãšããŠJOIåäºã®3人ã®ç€Ÿå¡AããïŒBããïŒCããã®åºç€Ÿæå»ãšé瀟æå»ãäžãããããšãïŒããããã®ç€Ÿå¡ã®åšç€Ÿæéãèšç®ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯3è¡ãããªãïŒ 1è¡ç®ã«ã¯Aããã®åºç€Ÿæå»ãšé瀟æå»ïŒ 2è¡ç®ã«ã¯Bããã®åºç€Ÿæå»ãšé瀟æå»ïŒ 3è¡ç®ã«ã¯Cããã®åºç€Ÿæå»ãšé瀟æå»ããããã空çœã§åºåããæžãããŠããïŒ
</p>
<p>
æå»ã¯ãããã空çœã§åºåããã3ã€ã®æŽæ°ã§æžãããŠããïŒ 3ã€ã®æŽæ° h, m, s 㯠h æ m å s ç§ãè¡šãïŒ 7 ≤ h ≤ 22, 0 ≤ m ≤ 59, 0 ≤ s ≤ 59 ã§ããïŒ
</p>
<h2>åºå</h2>
<p>
1è¡ç®ã«Aããã®åšç€ŸæéïŒ 2è¡ç®ã«Bããã®åšç€ŸæéïŒ 3è¡ç®ã«Cããã®åšç€ŸæéãåºåããïŒ
</p>
<p>
åºåããåšç€Ÿæéã h æé m å s ç§ã®å ŽåïŒ h, m, s ã®é ã«ç©ºçœã§åºåã£ãŠåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
9 0 0 18 0 0
9 0 1 18 0 0
12 14 52 12 15 30</pre>
<h3>åºåäŸ</h3>
<pre>
9 0 0
8 59 59
0 0 38</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"9 0 0 18 0 0\n9 0 1 18 0 0\n12 14 52 12 15 30\n",
"9 0 0 18 0 0\n9 0 1 18 0 0\n12 14 52 12 15 30\n"
]
] |
p00456 | Contest |
<H1> ã³ã³ãã¹ã </H1>
<h2>åé¡</h2>
<p>
å
æ¥ïŒãªã³ã©ã€ã³ã§ã®ããã°ã©ãã³ã°ã³ã³ãã¹ããè¡ãããïŒ W倧åŠãšK倧åŠã®ã³ã³ãã¥ãŒã¿ã¯ã©ãã¯ä»¥åããã©ã€ãã«é¢ä¿ã«ããïŒãã®ã³ã³ãã¹ããå©çšããŠäž¡è
ã®åªå£ã決ããããšããããšã«ãªã£ãïŒ
</p>
<p>
ä»åïŒãã®2ã€ã®å€§åŠããã¯ãšãã«10人ãã€ããã®ã³ã³ãã¹ãã«åå ããïŒé·ãè°è«ã®æ«ïŒåå ãã10人ã®ãã¡ïŒåŸç¹ã®é«ãæ¹ãã3人ã®åŸç¹ãåèšãïŒå€§åŠã®åŸç¹ãšããããšã«ããïŒ
</p>
<p>
W倧åŠããã³K倧åŠã®åå è
ã®åŸç¹ã®ããŒã¿ãäžããããïŒãã®ãšãïŒãã®ãã®ã®å€§åŠã®åŸç¹ãèšç®ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯20è¡ãããªãïŒ 1è¡ç®ãã10è¡ç®ã«ã¯W倧åŠã®ååå è
ã®åŸç¹ãè¡šãæŽæ°ãïŒ 11è¡ç®ãã20è¡ç®ã«ã¯K倧åŠã®ååå è
ã®åŸç¹ãè¡šãæŽæ°ãæžãããŠããïŒãããã®æŽæ°ã¯ã©ãã0以äž100以äžã§ããïŒ
</p>
<h2>åºå</h2>
<p>
W倧åŠã®åŸç¹ãšK倧åŠã®åŸç¹ãïŒãã®é ã«ç©ºçœåºåãã§åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸïŒ</h3>
<pre>
23
23
20
15
15
14
13
9
7
6
25
19
17
17
16
13
12
11
9
5</pre>
<h3>åºåäŸïŒ</h3>
<pre>
66 61</pre>
<br>
<h3>å
¥åäŸïŒ</h3>
<pre>
17
25
23
25
79
29
1
61
59
100
44
74
94
57
13
54
82
0
42
45</pre>
<h3>åºåäŸïŒ</h3>
<pre>
240 250</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"23\n23\n20\n15\n15\n14\n13\n9\n7\n6\n25\n19\n17\n17\n16\n13\n12\n11\n9\n5\n",
"23\n23\n20\n15\n15\n14\n13\n9\n7\n6\n25\n19\n17\n17\n16\n13\n12\n11\n9\n5\n"
]
] |
p00457 | Chain |
<H1> é£é </H1>
<h2>åé¡</h2>
<p>
次ã®ãããªã²ãŒã ãããïŒ
</p>
<p>
ãããã£ã©ã¯ã¿ãŒã瞊 1 åã« N å䞊ãã§ããïŒãããã®ãã£ã©ã¯ã¿ãŒã®è²ã¯èµ€ïŒéïŒé»ã®ããããã§ããïŒåæç¶æ
ã§åãè²ã®ãã£ã©ã¯ã¿ãŒã4ã€ä»¥äžé£ç¶ããŠäžŠãã§ããããšã¯ãªãïŒãã¬ãŒã€ãŒã¯ïŒããäœçœ®ã®ãã£ã©ã¯ã¿ãŒãéžã³ä»ã®è²ã«å€æŽããããšãã§ããïŒãã®æäœã«ããåãè²ã®ãã£ã©ã¯ã¿ãŒã4ã€ä»¥äžé£ç¶ããŠäžŠã¶ãšãããã®ãã£ã©ã¯ã¿ãŒã¯æ¶æ»
ããïŒãã£ã©ã¯ã¿ãŒãæ¶æ»
ããããšã«ããæ°ãã«åãè²ã®ãã£ã©ã¯ã¿ãŒã4ã€ä»¥äžé£ç¶ããŠäžŠã¶ãšãããã®ãã£ã©ã¯ã¿ãŒãæ¶æ»
ãïŒåãè²ã®ãã£ã©ã¯ã¿ãŒã4ã€ä»¥äžé£ç¶ããŠäžŠãã§ããç®æããªããªããŸã§ãã®é£éã¯ç¶ãïŒãã®ã²ãŒã ã®ç®çã¯ïŒæ¶æ»
ããªãã§æ®ã£ãŠãããã£ã©ã¯ã¿ãŒæ°ããªãã¹ãå°ãªãããããšã§ããïŒ
</p>
<p>
äŸãã°ïŒäžå³ã®å·Šç«¯ã®ç¶æ
ã§ïŒäžãã6çªç®ã®ãã£ã©ã¯ã¿ãŒã®è²ãé»è²ããéã«å€æŽãããšïŒéã®ãã£ã©ã¯ã¿ãŒã5ã€é£ç¶ããã®ã§æ¶æ»
ãïŒæçµçã«3ã€ã®ãã£ã©ã¯ã¿ãŒãæ¶æ»
ããã«æ®ãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_chain">
</center>
<br>
<p>
åæç¶æ
ã«ããã N åã®ãã£ã©ã¯ã¿ãŒã®è²ã®äžŠã³ãäžãããããšãïŒ 1ç®æã ããã£ã©ã¯ã¿ãŒã®è²ãå€æŽããå Žåã®ïŒæ¶æ»
ããªãã§æ®ã£ãŠãããã£ã©ã¯ã¿ãŒæ°ã®æå°å€ M ãæ±ããããã°ã©ã ãäœæããïŒ</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1è¡ç®ã¯ãã£ã©ã¯ã¿ãŒæ° N (1 ≤ N ≤ 10000) ã ããããªãïŒç¶ã N è¡ã«ã¯ 1, 2, 3 ã®ãããã1ã€ã®æŽæ°ãæžãããŠããïŒ i + 1 è¡ç® (1 ≤ i ≤ N) ã¯åæç¶æ
ã«ãããäžãã i çªç®ã®ãã£ã©ã¯ã¿ãŒã®è²ãè¡šãïŒ1 ã¯èµ€ãïŒ2 ã¯éãïŒ3ã¯é»ãè¡šãïŒïŒ
</p>
<p>
N ã 0 ã®ãšãå
¥åã®çµäºã瀺ãïŒããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«, æ¶æ»
ããªãã§æ®ã£ãŠãããã£ã©ã¯ã¿ãŒæ°ã®æå°å€ M ãïŒè¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
12
3
2
1
1
2
3
2
2
2
1
1
3
12
3
2
1
1
2
3
2
1
3
2
1
3
0
</pre>
<h3>åºåäŸ</h3>
<pre>
3
12
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n",
"12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n"
]
] |
p00458 | Crossing Black Ice |
<H1>èæ°·æž¡ã</H1>
<h2>åé¡</h2>
<p>
å¬ã®å¯ãããæ¥ïŒJOI倪éåã¯åºå Žã«ã¯ã£ãèæ°·ãå²ã£ãŠéã¶ããšã«ããïŒåºå Žã¯é·æ¹åœ¢ã§ïŒæ±è¥¿æ¹åã« m åïŒååæ¹åã« n åïŒã€ãŸãïŒ m × n ã®åºç»ã«åºåãããŠããïŒãŸãïŒèæ°·ãæãåºç»ãšç¡ãåºç»ãããïŒ JOI倪éåã¯ïŒæ¬¡ã®ã«ãŒã«ã«ãããã£ãŠïŒèæ°·ãå²ããªããåºç»ã移åããããšã«ããïŒ
</p>
<ul>
<li> èæ°·ãããã©ã®åºç»ãããèæ°·ãå²ãå§ããããšãã§ããïŒ</li>
<li> æ±è¥¿ååã®ããããã®æ¹åã«é£æ¥ãïŒ ãŸã å²ãããŠããªãèæ°·ã®ããåºç»ã«ç§»åã§ããïŒ</li>
<li> 移åããå
ã®åºç»ã®èæ°·ãããªããå²ãïŒ</li>
</ul>
<p>
JOI倪éåãèæ°·ãå²ããªãã移åã§ããåºç»æ°ã®æ倧å€ãæ±ããããã°ã©ã ãäœæããïŒãã ãïŒ 1 ≤ m ≤ 90ïŒ1 ≤ n ≤ 90 ã§ããïŒäžããããå
¥åããŒã¿ã§ã¯ïŒç§»åæ¹æ³ã¯20äžéããè¶
ããªãïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã¯n+2è¡ããïŒ 1 è¡ç®ã«ã¯æŽæ° m ãæžãããŠããïŒ 2 è¡ç®ã«ã¯æŽæ° n ãæžãããŠããïŒ 3 è¡ç®ãã n+2 è¡ç®ãŸã§ã®åè¡ã«ã¯ã0 ããã㯠1 ãïŒ ç©ºçœã§åºåãã㊠m åæžãããŠããïŒååºç»ã«èæ°·ããããåŠããè¡šããŠããïŒåãã i çªç®ïŒè¥¿ããjçªç®ã®åºç»ã (i,j) ãšèšè¿°ããããšã«ãããš (1 ≤ i ≤ n, 1 ≤ j ≤ m)ïŒç¬¬ i+2 è¡ç®ã® j çªç®ã®å€ã¯ïŒåºç» (i,j) ã«èæ°·ãååšããå Žå㯠1 ãšãªãïŒåºç» (i,j) ã«èæ°·ãååšããªãå Žå㯠0 ãšãªãïŒ
</p>
<p>
m, n ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«, 移åã§ããåºç»æ°ã®æ倧å€ãïŒè¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3
3
1 1 0
1 0 1
1 1 0
5
3
1 1 1 0 1
1 1 0 0 0
1 0 0 0 1
0
0
</pre>
<h3>åºåäŸ</h3>
<pre>
5
5
</pre>
<p>
1ã€ç®ã®å
¥åäŸã«å¯ŸããŠïŒæ倧å€ãäžãã移åæ¹æ³ã®äŸãã<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-1" alt="å
¥åäŸ1ã®å Žå" width=230 height=230>
</p>
<p>
2ã€ç®ã®å
¥åäŸã«å¯ŸããŠïŒæ倧å€ãäžãã移åæ¹æ³ã®äŸ <br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2" alt="å
¥åäŸ2ã®å Žå" width=324 height=194>
</p>
<p>2ã€ç®ã®å
¥åäŸã«å¯ŸããŠïŒæ倧å€ãäžããªã移åæ¹æ³ã®äŸ<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2-1" alt="å
¥åäŸ2ã®å Žå1" width=324 height=194>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2-2" alt="å
¥åäŸ2ã®å Žå2" width=324 height=194>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2-3" alt="å
¥åäŸ2ã®å Žå3" width=324 height=194>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2-4" alt="å
¥åäŸ2ã®å Žå4" width=324 height=194>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t4-2-5" alt="å
¥åäŸ2ã®å Žå5" width=324 height=194>
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 0 0\n1 0 0 0 1\n0\n0\n",
"3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 0 0\n1 0 0 0 1\n0\n0\n"
]
] |
p00459 | Shuffle |
<H1>ã·ã£ããã« </H1>
<h2>åé¡</h2>
<p>
1 ãã n ãŸã§ã®çªå·ãæžããã n æã®ã«ãŒããããïŒãŸãïŒäžçªäžãçªå· 1 ã®ã«ãŒãïŒäžãã2æç®ãçªå· 2 ã®ã«ãŒãïŒâŠïŒäžçªäžãçªå· n ã®ã«ãŒããšãªãããã«é çªã«éããŠïŒã«ãŒãã®å±±ãäœãïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t5-1"><br>
<br>
<p>
ã«ãŒãã®å±±ã«å¯ŸããŠïŒãã·ã£ããã«(x,y)ããšåŒã°ãã次ã®ãããªæäœãè¡ãããšã§ïŒã«ãŒãã䞊ã³æ¿ããïŒx, y 㯠1 ≤ x < y < n ãã¿ããæŽæ°ïŒïŒ
</p>
<p>
<b>ã·ã£ããã«(x,y)</b><br>
n æã®ã«ãŒããïŒäžçªäžãã x æç®ãŸã§ã®ã«ãŒããããªãå±±AïŒ x+1 æç®ãã y æç®ã®ã«ãŒããããªãå±±BïŒ y+1 æç®ãã n æç®ã®ã«ãŒããããªãå±±C ã®3ã€ã®å±±ã«åããïŒãããŠïŒå±±Aã®äžã«å±±BãéãïŒããã«ãã®äžã«å±±CãéããïŒ
</p>
<p>
äŸãã°ïŒé çªã«äžŠãã§ãã9æã®ã«ãŒãã«å¯ŸããŠãã·ã£ããã«(3,5)ããè¡ããšïŒ 9 æã®ã«ãŒãã«æžãããçªå·ã¯, äžããé çªã« 6, 7, 8, 9, 4, 5, 1, 2, 3 ãšãªãïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t5-2"><br>
<br>
<p>
æåã®å±±ã®ç¶æ
ãã m åã®ã·ã£ããã«ãã·ã£ããã«(x<sub>1</sub>, y<sub>1</sub>)ããã·ã£ããã«(x<sub>2</sub>, y<sub>2</sub>)ã ⊠ãã·ã£ããã«(x<sub>m</sub>, y<sub>m</sub>)ããé çªã«è¡ã£ãåŸã®ã«ãŒãã®å±±ã«ãããŠïŒäžããæ°ã㊠p æç®ãã q æç®ã®ã«ãŒãã®äžã«çªå·ã r 以äžã®ã«ãŒããäœæå«ãŸããŠããããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥å㯠m+3 è¡ãããªãïŒ 1 è¡ç®ã«ã¯ã«ãŒãã®ææ° n ãæžãããŠããïŒ3 ≤ n ≤ 1000000000 = 10<sup>9</sup>ïŒïŒ 2 è¡ç®ã«ã¯ã·ã£ããã«ã®åæ°ãè¡šãæŽæ° m ãæžãããŠããïŒ1 ≤ m ≤ 5000ïŒïŒ 3 è¡ç®ã«ã¯æŽæ° p, q, r ãæžãããŠããïŒ1 ≤ p ≤ q ≤ n, 1 ≤ r ≤ nïŒïŒ i + 3 è¡ç®ïŒ1 ≤ i ≤ mïŒã«ã¯2ã€ã®æŽæ° x<sub>i</sub>, y<sub>i</sub> (1 ≤ x<sub>i</sub> < y<sub>i</sub> < n) ã空çœãåºåããšããŠæžãããŠããïŒ
</p>
<p>
n ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«, m åã®ã·ã£ããã«åŸã®ã«ãŒãã®å±±ã«ãããŠïŒäžããæ°ã㊠p æç®ãã q æç®ã®ã«ãŒãã®äžã«å«ãŸããŠããçªå·ã r 以äžã®ã«ãŒãã®ææ°ãïŒè¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
9
1
3 7 4
3 5
12
3
3 8 5
3 8
2 5
6 10
0
</pre>
<h3>åºåäŸ</h3>
<pre>
2
3
</pre>
<p>
1ã€ç®ã®å
¥åäŸã®å±±ã«å¯ŸããŠ, ãã·ã£ããã«(3,5)ããè¡ããšïŒã«ãŒãã¯äžããé çªã« 6, 7, 8, 9, 4, 5, 1, 2, 3 ãšãªãïŒäžããæ°ã㊠3 æç®ãã 7 æç®ã«å«ãŸããçªå·ã 4 以äžã®ã«ãŒãã¯ïŒçªå· 4 ãšçªå· 1 ã® 2 æã§ããïŒ
</p>
<p>
ãŸãïŒ2ã€ç®ã®å
¥åäŸã®å±±ã«å¯ŸããŠ, ãã·ã£ããã«(3,8)ããã·ã£ããã«(2,5)ããã·ã£ããã«(6,10)ããé çªã«è¡ããšïŒã«ãŒãã¯äžããé çªã« 9, 10, 3, 11, 12, 4, 5, 6, 7, 8, 1, 2 ãšãªãïŒäžããæ°ã㊠3 æç®ãã 8 æç®ã«å«ãŸããçªå·ã 5 以äžã®ã«ãŒã㯠3 æã§ããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"9\n1\n3 7 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0\n",
"9\n1\n3 7 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0\n"
]
] |
p00460 | Bingo |
<H1> ãã³ãŽ</H1>
<h2>åé¡</h2>
<p>
ããããã°ã©ãã³ã°ã³ã³ãã¹ãã§ã¯,競æåŸã®æ芪äŒã§ãã³ãŽã²ãŒã ãããç¿ãããããïŒããã,ãã®ãã³ãŽã²ãŒã ã§äœ¿ããã³ãŽã«ãŒãã¯å°ã
ç¹æ®ã§,以äžã®æ¡ä»¶ã«åŸã£ãŠäœæãããïŒ
</p>
<ul>
<li> ãã³ãŽã«ãŒã㯠N è¡ N åã®ãã¹ç®ã«åºåãããŠããïŒåãã¹ç®ã«ã¯æ£æŽæ°ãïŒã€ãã€æžãããŠããïŒãããã®æŽæ°ã¯å
šãŠç°ãªãïŒ</li>
<li> ãã¹ç®ã«æžãããŠããæŽæ°ã¯ 1 ä»¥äž M 以äžã§ããïŒ</li>
<li> ãã³ãŽã«ãŒãã«æžãããŠããNÃNåã®æŽæ°ã®åèšã¯ S ã§ããïŒ</li>
<li> ã©ã®åãèŠããšããïŒäžããäžã«åãã£ãŠæŽæ°ã¯æé ã«äžŠãã§ããïŒ</li>
<li> ã©ã®ãã¹ç®ã®æŽæ°ãïŒãã®ãã¹ç®ããå·Šã®åã®ã©ã®æŽæ°ããã倧ããïŒ</li>
</ul>
<p>
以äžã¯ïŒ N = 5, M = 50, S = 685 ã®ãšãã®ãã³ãŽã«ãŒãã®äŸã§ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009-yo-t6">
</center>
<br>
<p>
æ芪äŒã®ããã«äžã®æ¡ä»¶ãæºãããã³ãŽã«ãŒããã§ããã ãããããäœãããïŒãã ãïŒåäžã®ã«ãŒãã2æ以äžäœã£ãŠã¯ãªããªãïŒäœãããšãã§ãããã³ãŽã«ãŒãã®ææ°ã®æ倧å€ã 100000 ã§å²ã£ãäœããåºåããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
å
¥åã¯1è¡ãããªã, ãã®è¡ã«ã¯ãã³ãŽã«ãŒãã®ãµã€ãº N (1≤N≤7), ãã¹ç®ã«æžãããŠããæŽæ°ã®äžé M (1≤M≤2000),ãã³ãŽã«ãŒãã«æžãããŠããæŽæ°ã®åèš S (1≤S≤3000) ãè¡šã3ã€ã®æ£æŽæ°ã空çœåºåãã§æžãããŠããïŒãã ã, äžããããã©ã®å
¥åããŒã¿ã«ãããŠãïŒæ¡ä»¶ãæºãããã³ãŽã«ãŒãã1æ以äžäœãããšãã§ããïŒ
</p>
<p>
N, M, S ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«, äœãããšãã§ãããã³ãŽã«ãŒãã®ææ°ã®æ倧å€ã 100000 ã§å²ã£ãäœãã1è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3 9 45
3 100 50
5 50 685
0 0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
1
7
74501
</pre>
<p>
3ã€ç®ã®å
¥åäŸã«å¯ŸããŠïŒäœãããšãã§ãããã³ãŽã«ãŒãã®ææ°ã®æ倧å€ã¯ 642499974501 ã§ããã®ã§ïŒ 100000 ã§å²ã£ãäœãã® 74501 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 9 45\n3 100 50\n5 50 685\n0 0 0\n",
"3 9 45\n3 100 50\n5 50 685\n0 0 0\n"
]
] |
p00461 | IOIOI |
<H1> IOIOI </H1>
<h2>åé¡</h2>
<p>
æŽæ° <i>n</i> (1 ≤ <i>n</i>) ã«å¯Ÿã, <i>n</i> + 1 åã® <span>I</span> ãš <i>n</i> åã® <span>O</span> ã <span>I</span> ããå§ããŠäº€äºã«äžŠã¹ãŠã§ããæååã <i>P<sub>n</sub></I> ãšãã.ãã㧠<span>I</span> ãš <span>O</span> ã¯ããããè±å€§æåã®ã¢ã€ãšãªãŒã§ãã.
</p>
<br><center>
<table>
<tr><td width="40"><i>P</i><sub>1</sub></td><td><span>IOI</span></td></tr>
<tr><td><i>P</i><sub>2</sub></td><td><span>IOIOI</span></td></tr>
<tr><td><i>P</i><sub>3</sub></td><td><span>IOIOIOI</span></td></tr>
<tr><td></td><td>.<td></tr>
<tr><td></td><td>.<td></tr>
<tr><td></td><td>.<td></tr>
<tr><td><i>P</i><sub><i>n</i></sub></td><td><span>IOIOIO ... OI</span> (<span>O</span> ã <i>n</i> å)</td></tr>
</table>
<br>
<p>
å³ 1-1 æ¬åã§èããæåå <i>P<sub>n</sub></i>
</p>
</center>
<br>
<p>
æŽæ° <i>n</i> ãš, I ãš O ã®ã¿ãããªãæåå <i>s</i> ãäžããããæ, <i>s</i> ã®äžã« <i>P<sub>n</sub></i> ãäœã¶æå«ãŸããŠããããåºåããããã°ã©ã ãäœæãã.
</p>
<h2>äŸ</h2>
<p>
<i>n</i> ã 1, <i>s</i> ã <span>OOIOIOIOIIOII</span> ã®å Žå, <i>P</i><sub>1</sub> 㯠<span>IOI</span> ã§ãã,äžå³ 1-2 ã«ç€ºãã 4ã¶æã«å«ãŸããŠãã.ãã£ãŠ,åºå㯠4 ã§ãã.
</p>
<center>
<span>
OO<u>IOI</u>OIOIIOII<br>
OOIO<u>IOI</u>OIIOII<br>
OOIOIO<u>IOI</u>IOII<br>
OOIOIOIOI<u>IOI</u>I<br>
</span>
</center>
<br>
<center>
å³ 1-2 <i>n</i> ã 1, <i>s</i> ã <span>OOIOIOIOIIOII</span> ã®å Žåã®äŸ
</center>
<br>
<p>
<i>n</i> ã 2, <i>s</i> ã <span>OOIOIOIOIIOII</span> ã®å Žå, <i>P</i><sub>2</sub> 㯠<span>IOIOI</span> ã§ãã,äžå³ 1-3 ã«ç€ºãã 2ã¶æã«å«ãŸããŠãã.ãã£ãŠ,åºå㯠2 ã§ãã.
</p>
<center>
<span>
OO<u>IOIOI</u>OIIOII<br>
OOIO<u>IOIOI</u>IOII<br>
</span>
</center>
<br>
<center>
å³ 1-3 <i>n</i> ã 2, <i>s</i> ã <span>OOIOIOIOIIOII</span> ã®å Žåã®äŸ
</center>
<br>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.<br>-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯æŽæ° <i>n</i> (1 ≤ <i>n</i> ≤ 1000000) ãæžãããŠãã.<br>
2 è¡ç®ã«ã¯æŽæ° <i>m</i> (1 ≤ <i>m</i> ≤ 1000000) ãæžãããŠãã. <i>m</i> 㯠<i>s</i> ã®æåæ°ãè¡šã.<br>
3 è¡ç®ã«ã¯æåå <i>s</i> ãæžãããŠãã. <i>s</i> 㯠<span>I</span> ãš <span>O</span> ã®ã¿ãããªã.
</p>
<p>
å
šãŠã®æ¡ç¹çšããŒã¿ã§, 2<i>n</i> + 1 ≤ <i>m</i> ã§ãã.æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 50% åã«ã€ããŠã¯, <i>n</i> ≤ 100, <i>m</i> ≤ 10000 ãæºãã.
</p>
<p>
<i>n</i> ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!-- åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.<br>
output.txt ã¯,æåå <i>s</i> ã«æåå <i>P<sub>n</sub></i> ãäœã¶æå«ãŸããããè¡šã 1 ã€ã®æŽæ°ãå«ã 1 è¡ãããªã.
-->
ããŒã¿ã»ããããšã«,æåå <i>s</i> ã«æåå <i>P<sub>n</sub></i> ãäœã¶æå«ãŸããããè¡šã 1 ã€ã®æŽæ°ã1 è¡ã«åºåãã. <i>s</i> ã« <i>P<sub>n</sub></i> ãå«ãŸããŠããªãå Žåã¯,æŽæ°ãšã㊠<span>0</span> ãåºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
1
13
OOIOIOIOIIOII
2
13
OOIOIOIOIIOII
0
</pre>
<h3>åºåäŸ</h3>
<pre>
4
2
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n",
"1\n13\nOOIOIOIOIIOII\n2\n13\nOOIOIOIOIIOII\n0\n"
]
] |
p00462 | Pizza |
<H1>ã㶠</H1>
<h2>åé¡</h2>
<p>
JOI ãã¶ã§ã¯,åžã®äžå¿éšãéãå
šé· <i>d</i> ã¡ãŒãã«ã®ç°ç¶ç·ã®æ²¿ç·äžã§ãã¶ã®å®
é
販
売ãè¡ã£ãŠãã.
</p>
<p>
JOI ãã¶ã¯,ç°ç¶ç·äžã« <i>n</i> åã®åºè <i>S</i><sub>1</sub>, ... , <i>S<sub>n</sub></i> ãæã€.æ¬åºã¯ <i>S</i><sub>1</sub> ã§ãã. <i>S</i><sub>1</sub> ãã <i>S<sub>i</sub></i> ãŸã§,æèšåãã«ç°ç¶ç·ã移åãããšãã®éã®ãã <i>d<sub>i</sub></i> ã¡ãŒãã«ãšãã. <i>d</i><sub>2</sub>, ... , <i>d<sub>n</sub></i> 㯠1 ä»¥äž <i>d</i> - 1 以äžã®æŽæ°ã§ãã. <i>d</i><sub>2</sub> , ... , <i>d<sub>n</sub></i> ã¯å
šãŠç°ãªã. ãã¶ã®æ³šæãåãããš, ãã¶ãå·ããªãããã«, å®
é
å
ãŸã§ã®ç§»åè·é¢ããã£ãšãçãåºèã§ãã¶ãçŒãå®
é
ãã.
</p>
<p>
å®
é
å
ã®äœçœ®ã¯ 0 ä»¥äž <i>d</i> - 1 以äžã®æŽæ° <i>k</i> ã§è¡šããã.ããã¯, æ¬åº <i>S</i><sub>1</sub> ããå®
é
å
ãŸã§ã«æèšåãã§ç°ç¶ç·ã移åãããšãã®éã®ãã <i>k</i> ã¡ãŒãã«ã§ããããšãæå³ãã. ãã¶ã®å®
é
ã¯ç°ç¶ç·ã«æ²¿ã£ãŠè¡ãã, ãã以å€ã®éãéãããšã¯èš±ãããªã. ãã ã, ç°ç¶ç·äžã¯æèšåãã«ç§»åããŠãåæèšåãã«ç§»åããŠããã.
</p>
<p>
äŸãã°,åºèã®äœçœ®ãšå®
é
å
ã®äœçœ®ãäžå³ã®ããã«ãªã£ãŠããå Žå (ãã®äŸã¯ãå
¥åºåã®äŸãã®äŸ 1 ãšå¯Ÿå¿ããŠãã),
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pizza">
</center>
<br>
<p>
å®
é
å
1 ã«ãã£ãšãè¿ãåºè㯠<i>S</i><sub>2</sub> ãªã®ã§, åºè <i>S</i><sub>2</sub> ããå®
é
ãã.ãã®ãšã, åºèããã®ç§»åè·é¢ã¯ 1 ã§ãã.ãŸã, å®
é
å
2 ã«ãã£ãšãè¿ãåºè㯠<i>S</i><sub>1</sub> (æ¬åº) ãªã®ã§, åºè <i>S</i><sub>1</sub> (æ¬åº) ããå®
é
ãã.ãã®ãšã,åºèããã®ç§»åè·é¢ã¯ 2 ã§ãã.
</p>
<p>
ç°ç¶ç·ã®å
šé· <i>d</i>, JOI ãã¶ã®åºèã®åæ° <i>n</i>, 泚æã®åæ° <i>m</i>, æ¬åºä»¥å€ã®äœçœ®ãè¡šã <i>n</i> - 1 åã®æŽæ° <i>d</i><sub>2</sub>, ... , <i>d<sub>n</sub></i> , å®
é
å
ã®å Žæãè¡šãæŽæ° <i>k</i><sub>1</sub>, ... , <i>k<sub>m</sub></i> ãäžãããããšã, å泚æã«å¯Ÿããå®
é
æã®ç§»åè·é¢ (ããªãã¡,æå¯åºèããå®
é
å
ãŸã§ã®éã®ã) ã®å
šæ³šæã«ãããç·åãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.<br>-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ç°ç¶ç·ã®å
šé·ãè¡šãæ£æŽæ° <i>d</i> (2 ≤ <i>d</i> ≤ 1000000000 = 10<sup>9</sup> ), 2 è¡ç®ã«ã¯åºèã®åæ°ãè¡šãæ£æŽæ° <i>n</i> (2 ≤ <i>n</i> ≤ 100000), 3 è¡ç®ã«ã¯æ³šæã®åæ°ãè¡šãæ£æŽæ° <i>m</i> (1 ≤ <i>m</i> ≤ 10000) ãæžãããŠãã. 4 è¡ç®ä»¥éã® <i>n</i> - 1 è¡ã«ã¯æ¬åºä»¥å€ã®åºèã®äœçœ®ãè¡šãæŽæ° <i>d</i><sub>2</sub>, <i>d</i><sub>3</sub>, ... , <i>d</i><sub>n</sub> (1 ≤ <i>d<sub>i</sub></i> ≤ <i>d</i> - 1) ããã®é ã«æžãããŠãã, <i>n</i> + 3 è¡ç®ä»¥éã® <i>m</i> è¡ã«ã¯å®
é
å
ã®å Žæãè¡šãæŽæ° <i>k</i><sub>1</sub>, <i>k</i><sub>2</sub>, ... , <i>k<sub>m</sub></i> (0 ≤ <i>k<sub>i</sub></i> ≤ <i>d</i> - 1) ããã®é ã«æžãããŠãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 40% åã«ã€ããŠã¯, n ≤ 10000 ãæºãã. ãŸã,é
ç¹ã® 40% åã«ã€ããŠã¯, æ±ãã移åè·é¢ã®ç·åãš <i>d</i> ã®å€ã¯ãšãã« 1000000 以äžã§ãã. ããã«,å
šãŠã®æ¡ç¹çšããŒã¿ã«ãããŠ, æ±ãã移åè·é¢ã®ç·å㯠1000000000 = 10<sup>9</sup>以äžã§ãã.
</p>
<p>
<i>d</i> ã 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.<br>
output.txt ã¯,å®
é
æã®ç§»åè·é¢ã®ç·åãè¡šã 1 ã€ã®æŽæ°ã®ã¿ãå«ã 1 è¡ãããªã.
-->
ããŒã¿ã»ããããšã«,å®
é
æã®ç§»åè·é¢ã®ç·åãè¡šã 1 ã€ã®æŽæ°ã1 è¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
8
3
2
3
1
4
6
20
4
4
12
8
16
7
7
11
8
0
</pre>
<h3>åºåäŸ</h3>
<pre>
3
3
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n12\n8\n16\n7\n7\n11\n8\n0\n",
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n12\n8\n16\n7\n7\n11\n8\n0\n"
]
] |
p00463 | Amidakuji |
<H1>ãã¿ã ãã </H1>
<h2>åé¡</h2>
<p>
ããªã㯠J åãšäžç·ã«ãã¿ã ããã䜿ã£ãŠéãã§ãã.ãã¿ã ãã㯠<i>n</i> æ¬ã®çžŠæ£ãš
<i>m</i> æ¬ã®æšªæ£ãããªã.瞊æ£ã«ã¯å·Šããé ã« 1 ãã <i>n</i> ã®çªå·ãã€ããŠãã,çžŠæ£ <i>i</i> ã®äžç«¯ã«ã¯æ£æŽæ° <i>s<sub>i</sub></i> ãæžãããŠãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amidakuji1">
<p>
å³ 3-1 ãã¿ã ããã®äŸ(<i>n</i> = 4, <i>m</i> = 5, <i>s</i><sub>1</sub> = 20, <i>s</i><sub>2</sub> = 80, <i>s</i><sub>3</sub> = 100, <i>s</i><sub>4</sub> = 50)
</p>
</center>
<p>
çžŠæ£ <i>i</i> ã®äžçªäžããé ã«éããã©ã£ãŠããå°éããäžç«¯ã«æžãããŠããæŽæ°ã, 瞊
æ£ <i>i</i> ãéžãã å Žåã®åŸç¹ã§ãã.äŸãã°,å³ 3-1 ã§ã¯,çžŠæ£ 1 ãéžã¶ãšåŸç¹ã¯ 80 ç¹
ã§ãã,çžŠæ£ 2 ãéžã¶ãšåŸç¹ã¯ 100 ç¹ã§ãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amidakuji2">
<p>
å³ 3-2 éã®ãã©ãæ¹ã®äŸ
</p>
</center>
<p>
J åã¯çžŠæ£ 1 ããçžŠæ£ <i>k</i> ãŸã§ã®é£ç¶ãã <i>k</i> æ¬ãéžã¶ããšã«ãã.ããã <i>k</i> æ¬ã®çžŠæ£ãéžãã ãšãã®ç¹æ°ã®åèšã J åã®åŸç¹ãšãªã.ãã ã,ããªãã¯ãã¿ã ããå
ã®
暪æ£ãäžæ¬éžã³,ãã®æšªæ£ããã¿ã ããããåé€ããããšãã§ãã. (åé€ããªããŠããã.) ãã,ããªãã暪æ£ãäžæ¬åé€ããå Žåã¯,åé€åŸã®ãã¿ã ããã«ãããŠ,
çžŠæ£ 1 ããçžŠæ£ <i>k</i> ãŸã§ã®é£ç¶ãã <i>k</i> æ¬ã®çžŠæ£ãéžãã ãšãã®ç¹æ°ã®åèšã J åã®åŸç¹ãšãªã.
</p>
<p>
å
¥åãšããŠãã¿ã ããã®åœ¢ãš J åã®éžã¶çžŠæ£ã®æ¬æ° <i>k</i> ãäžãããããšã,J åã®åŸ
ç¹ã®æå°å€ãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.<br>-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯ 4 ã€ã®æŽæ° <i>n</i>, <i>m</i>, <i>h</i>, <i>k</i> ã空çœåºåãã§æžãããŠãã. <i>n</i> (2 ≤ <i>n</i> ≤ 1000) ã¯çžŠæ£ã®æ¬æ°ã, <i>m</i> (1 ≤ <i>m</i> ≤ 100000) ã¯æšªæ£ã®æ¬æ°ã, <i>h</i> (2 ≤ <i>h</i> ≤ 1000) ã¯çžŠæ£ã®é·ãã,<i>k</i> (1 ≤ <i>k</i> ≤ n) 㯠J åãéžã¶çžŠæ£ã®æ¬æ°ãè¡šã.
</p>
<p>
ç¶ã <i>n</i> è¡ã«ã¯çžŠæ£ã®äžç«¯ã«æžãããŠããç¹æ°ãæžãããŠãã. <i>i</i> + 1 è¡ç® (1 ≤ <i>i</i> ≤ n)ã«ã¯æ£æŽæ° <i>s<sub>i</sub></i> ãæžãããŠãã. ãŸã, <i>s</i><sub>1</sub> + <i>s</i><sub>2</sub> + ... + <i>s<sub>n</sub></i> ≤ 2000000000 = 2 × 10<sup>9</sup> ãæºãã.
</p>
<p>
ç¶ã <i>m</i> è¡ã«ã¯æšªæ£ã®äœçœ®ãæžãããŠãã.暪æ£ã«ã¯ 1 ãã <i>m</i> ãŸã§ã®çªå·ãã€ããŠãã.<i>i</i> + <i>n</i> + 1 è¡ç® (1 ≤ <i>i</i> ≤ <i>m</i>) ã«ã¯, æšªæ£ <i>i</i> ã®äœçœ®ãè¡šã 2 ã€ã®æŽæ° <i>a<sub>i</sub></i>, <i>b<sub>i</sub></i> (1 ≤ <i>a<sub>i</sub></i> ≤ <i>n</i> - 1, 1 ≤ <i>b<sub>i</sub></i> ≤ <i>h</i> - 1) ã空çœåºåãã§æžãããŠãã,æšªæ£ <i>i</i> ãçžŠæ£ <i>a<sub>i</sub></i> ãšçžŠæ£ <i>a<sub>i</sub></i> + 1 ãçµã³, æšªæ£ <i>i</i> ã®äžç«¯ããã®è·é¢ã <i>b<sub>i</sub></i> ã§ããããšãè¡šã. ãã ã,ã©ã® 2 ã€ã®æšªæ£ã端ç¹ãå
±æããããšã¯ãªã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 20 % åã¯æšªæ£ãåé€ããªãå Žåã« J åã®åŸç¹ãæå°ãšãªã.ãŸã,é
ç¹ã® 30 % å㯠<i>n</i> ≤ 20, <i>m</i> ≤ 30, <i>h</i> ≤ 10 ãæºãã,é
ç¹ã® 60 % å㯠<i>m</i> ≤ 1000 ãæºãã.
</p>
<p>
å
¥åã®çµãã㯠4ã€ã®ãŒããå«ãè¡ã§ç€ºããã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
output.txt 㯠J åã®åŸç¹ã®æå°å€ã®ã¿ãå«ã 1 è¡ãããªã.
-->
ããŒã¿ã»ããããšã«, J åã®åŸç¹ã®æå°å€ã1 è¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
4 5 7 2
20
80
100
50
1 1
2 6
2 3
1 5
3 1
2 2 5 1
10
20
1 1
1 3
0 0 0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
100
10
</pre>
<p>
1ã€ç®ã®äŸ ã¯å³ 3-1 ã«å¯Ÿå¿ã,ããªããæšªæ£ 4 (çžŠæ£ 1 ãšçžŠæ£ 2 ãäžç«¯ããè·é¢ 5 ã®å Žæã§çµã¶æšªæ£)ãåé€ãããšã,J åã®åŸç¹ã¯æå°ã«ãªã.äŸ 2 ã§ã¯,ããªãã暪æ£ãåé€ããªãå Žåã« J åã®åŸç¹ãæå°ã«ãªã. (å³3-3 ãèŠã.)
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amidakuji3">
<p>
å³ 3-3
</p>
</center>
<br>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4 5 7 2\n20\n80\n100\n50\n1 1\n2 6\n2 3\n1 5\n3 1\n2 2 5 1\n10\n20\n1 1\n1 3\n0 0 0 0\n",
"4 5 7 2\n20\n80\n100\n50\n1 1\n2 6\n2 3\n1 5\n3 1\n2 2 5 1\n10\n20\n1 1\n1 3\n0 0 0 0\n"
]
] |
p00464 | Walk |
<H1> æ£æ© </H1>
<h2>åé¡</h2>
<p>
JOI çºã«äœã倪éåã¯, ããæ¥,å¥åº·å¢é²ã®ããã«æ£æ©ãæ¥èª²ã«ããããšæãç«ã£ã.
倪éåã®äœã JOI çºã«ã¯,å³ã®ããã«,æ±è¥¿æ¹åã«èµ°ã (<i>H</i> + 1) æ¬ã®éè·¯ãš,åå
æ¹åã«èµ°ã (<i>W</i> + 1) æ¬ã®éè·¯ãç¢ç€ç®ç¶ã«éã£ãŠãã.倪éåã®å®¶ã¯ãã£ãšãå西ã®
亀差ç¹ã«ãã,ããããæ£æ©ãéå§ãã.
</p>
<p>
以é,åãã <i>a</i> çªç®,西ãã <i>b</i> çªç®ã®äº€å·®ç¹ã (<i>a</i>, <i>b</i>) ã§è¡šã.ããšãã°,倪éåã®å®¶ããã亀差ç¹ã¯ (1, 1) ã§ãã.
</p>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sanpo1">
<p>
å³: JOI çºã®å³ (<i>H</i> = 3, <i>W</i> = 4 ã®å Žå).å³ã®äžãå,å·Šã西ã«å¯Ÿå¿ãã.
</p>
</center>
<p>
倪éåã¯,æ£æ©ã®ã«ãŒããæ¥ã
éã£ãã»ããé¢çœããšèããã®ã§,(1, 1) ãã (<i>H</i>, <i>W</i>) ãŸã§ã® <i>H</i> × <i>W</i> åã®äº€å·®ç¹ã«, ãæ±ããŸãã¯ãåãã®æåãæžã,次ã®ãããªã«ãŒã«ã«åŸã£ãŠæ¯æ¥æ£æ©ãè¡ãããšã«ãã.
</p>
<ul>
<li> æåã®æžããã亀差ç¹ã«ããå Žå,ãã®äº€å·®ç¹ã«æžãããŠããæåããæ±ããª
ããåãã«, ãåããªããæ±ãã«æåãæžãæã,ããšããšæžãããŠããæåã®æ¹è§ã«ãã次ã®äº€å·®ç¹ãŸã§é²ã.</li>
<li> ãã£ãšãæ±ããã£ãšãåã®éè·¯ã«å°éãããæ£æ©ãçµäºãã.</li>
</ul>
<p>
ãã®èšç»ãèããåŸ,倪éåã¯,å°æ¥ã®æ£æ©ã§èªåãã©ã®ãããªã«ãŒãããã©ã
ããšã«ãªãã®ããæ°ã«ãªã£ã.倪éåã®ããã«,倪éåã® <i>N</i> åç®ã®æ£æ©ã®ã«ãŒãã
äºæž¬ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.<br>-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯,3 ã€ã®æ£æŽæ°ã空çœåºåãã§æžãããŠãã.ãããã¯,åé¡æäžã® 3 ã€ã®æ°å€ <i>H</i>, <i>W</i>, <i>N</i> ã®å€ã§ãã. <i>H</i>, <i>W</i>, <i>N</i> ã¯ãããã, 1 ≤ <i>H</i> ≤ 1000, 1 ≤ <i>W</i> ≤ 1000, 1 ≤ <i>N</i> ≤ 10000000 = 10<sup>7</sup> ãã¿ãã. 2 è¡ç®ãã <i>H</i> + 1 è¡ç®ã«ã¯,ãããã <i>W</i> åã®æŽæ°ã空çœåºåãã§æžãããŠãã.ãããã¯,倪éåãæåã«äº€å·®ç¹ã«æžããæåã®æ
å ±ãè¡šã. <i>i</i> + 1 è¡ç®ã® <i>j</i> çªç®ã®æŽæ°ã 0 ãªã,äº€å·®ç¹ (<i>i</i>, <i>j</i>) ã«æžãããæåããåãã§ããããšã, 1 ãªã, äº€å·®ç¹ (<i>i</i>, <i>j</i>) ã«æžãããæåããæ±ãã§ããããšãè¡šã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 30%åã«ã€ããŠã¯, <i>H</i> ≤ 100, <i>W</i> ≤ 100, <i>N</i> ≤ 1000 ãæºãã.
</p>
<p>
<i>H</i>, <i>W</i>, <i>N</i> ããã¹ãŠ 0 ã®ãšãå
¥åã®çµäºã瀺ã. ããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!-- åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.<br>-->
ããŒã¿ã»ããããšã«æ¬¡ã®åœ¢åŒã§åºåãã.<br>
<i>N</i> åç®ã®æ£æ©ã«ãããŠå€ªéåãæ£æ©ãçµäºãã亀差ç¹ã (<i>i</i>, <i>j</i>) ã®ãšã,<i>i</i> ãš <i>j</i> ããã®é ã«ç©ºçœã§åºåã£ãŠåºåãã.
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3 4 3
1 0 1 1
0 1 0 0
1 0 1 0
0 0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
1 5
</pre>
<p>
äžã®äŸã§ã¯,1 åç®ãã 3 åç®ã®æ£æ©ã®ã«ãŒãã¯æ¬¡ã®å³ã®ããã«ãªã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sanpo2">
</center>
<br>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 4 3\n1 0 1 1\n0 1 0 0\n1 0 1 0\n0 0 0\n",
"3 4 3\n1 0 1 1\n0 1 0 0\n1 0 1 0\n0 0 0\n"
]
] |
p00465 | Authentication Level |
<H1> èªèšŒã¬ãã« </H1>
<h2>åé¡</h2>
<p>
ããªã㯠Just Odd Inventions 瀟ãç¥ã£ãŠããã ããã? ãã®äŒç€Ÿã®æ¥åã¯ããã å¥åŠãªçºæ (just odd inventions)ããããããšã§ãã.ããã§ã¯ç¥ã㊠JOI 瀟ãšåŒã¶.
</p>
<p>
JOI 瀟ã«ã¯ 2 ã€ã®äºåæããã,ããããåã倧ããã®æ£æ¹åœ¢ã®éšå±ããã¹ç®ç¶ã«äžŠãã§ã§ããŠãã.蟺ã§æ¥ããŠãããã¹ãŠã®éšå±ã®éã«,身å蚌ã«ããèªèšŒæ©èœã®ä»ããæããã.JOI 瀟ã§ã¯æ§ã
ãªã¬ãã«ã®æ©å¯æ
å ±ãæ±ã£ãŠãããã,éšå±ããšã«æ©å¯ã¬ãã«ãšããæ£ã®æŽæ°ãèšå®ãããŠãã,身å蚌ã®äºåæããšã«å®ããããéè² æŽæ°ã®èªèšŒã¬ãã«ã,æ©å¯ã¬ãã«ä»¥äžã§ãªããšãã®éšå±ã«å
¥å®€ããããšãã§ããªã.åäºåæã®åºå
¥ãå£ã¯å¯äžãããšã¬ããŒã¿ãŒããŒã«ã®ã¿ã§,ãšã¬ããŒã¿ãŒããŒã«ã®éšå±ã®æ©å¯ã¬ãã«ã¯æäœã® 1 ã§ãã.ãã®äºåæã«ã€ããŠã®èªèšŒã¬ãã«ã 0 ã®ãšãã¯ãšã¬ããŒã¿ãŒããŒã«ã«å
¥ãããšããã§ããªã.
</p>
<p>
JOI 瀟ã§ã¯,瀟é·ã®çªçºçãªææ¡ã§,äžè¬ã®äººã«ç€Ÿå
ãèŠåŠããŠããããã¢ãŒãå®æœããããšã«ãªã£ã.ããªãã¯èŠåŠè
ã«æž¡ã身å蚌ã®èªèšŒã¬ãã«ã®çµã¿åããã決ããå¿
èŠããã.èŠåŠè
ã¯éããããæãèŠã€ãããšå¿
ãéããŠäžã«å
¥ã (åãéšå±ãäœåºŠã蚪ããããšãå¯èœã§ãã).ãã®ãã,å¿
èŠä»¥äžã«èŠåŠè
ã®èº«å蚌ã®èªèšŒã¬ãã«ãé«ããããã¯ãªã.ããã,ãã¢ãŒã«é
åãæããããã,ãã¢ãŒã§ã¯ãšã¬ããŒã¿ãŒããŒã«ã®éšå±ãå«ã 2 ã€ã®äºåæã§ããã㊠R å以äžã®éšå±ã蚪ããããšãã§ããããã«ããå¿
èŠããã.身å蚌ã®èªèšŒã¬ãã«ãäœããããããš,ãã®æ¡ä»¶ãæºããããšãã§ããªããããããªã.
</p>
<p>
JOI 瀟ã«ã¯äºåæã 2 åãã,第 <i>k</i> äºåæ (<i>k</i> = 1, 2) ã®éšå±ã¯æ±è¥¿æ¹åã« <i>W<sub>k</sub></i> å,ååæ¹åã« <i>H<sub>k</sub></i> å䞊ãã§ãã,å
šéšã§ <i>W<sub>k</sub></i> × <i>H<sub>k</sub></i> åãã. 西ãã <i>i</i> çªç®,åãã <i>j</i> çªç®ã®éšå±ã (<i>i</i>, <i>j</i>)<sub><i>k</i></sub> ã§è¡šãããšã«ãã.
</p>
<p>
<i>W<sub>k</sub></i> ãš <i>H<sub>k</sub></i> ãš <i>R</i> ã®å€,ãšã¬ããŒã¿ãŒããŒã«ã®äœçœ® (<i>X<sub>k</sub></i>, <i>Y<sub>k</sub></i> )<sub><i>k</i></sub> ,åéšå±ã®æ©å¯ã¬ãã«ãäžãããããšã,èŠåŠè
ã 2 ã€ã®äºåæã§ããã㊠<i>R</i> å以äžã®éšå±ã蚪ããããšãã§ããããã®,èŠåŠè
ã®èº«å蚌ã®èªèšŒã¬ãã«ã®åã®æå°å€ãæ±ããããã°ã©ã ãäœæãã.
</p>
<p>
ãªã,JOI 瀟ãããã å¥åŠãªçºæããããããšã§ã©ããã£ãŠå©çãåŸãŠãããã¯,瀟å
ã§ãæé«æ©å¯ã§ãã瀟é·ä»¥å€ã®èª°ãç¥ããªã.
</p>
<h2>å
¥å</h2>
<p>
<!-- å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.<br>-->
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
1 è¡ç®ã«ã¯æ£æŽæ° R (1 ≤ <i>R</i> ≤ 100000) ãæžãããŠãã.2 è¡ç®ä»¥éã«ã¯,2 ã€ã®äºåæã®ããŒã¿ãé ã«äžãããã.
</p>
<p>
äºåæã®ããŒã¿ã¯,æåã®è¡ã«æ£æŽæ° <i>W<sub>k</sub></i>, <i>H<sub>k</sub></i>, <i>X<sub>k</sub></i>, <i>Y<sub>k</sub></i> (1 ≤ <i>X<sub>k</sub></i> ≤ <i>W<sub>k</sub></i> ≤ 500, 1 ≤ <i>Y<sub>k</sub></i> ≤ <i>H<sub>k</sub></i> ≤ 500), ç¶ã <i>H<sub>k</sub></i> è¡ã® <i>j</i> è¡ç®ã® <i>i</i> çªç®ã«, éšå± (<i>i</i>, <i>j</i>)<sub><i>k</i></sub> ã®æ©å¯ã¬ãã«ãè¡šãæŽæ° <i>L<sub>k, i,j</sub></i> (1 ≤ <i>L<sub>k,i,j</sub></i> < 100000000 = 10<sup>8</sup>) ãšããŠäžãããã.
</p>
<p>
ãŸã, <i>R</i> ≤ <i>W</i><sub>1</sub> × <i>H</i><sub>1</sub> + <i>W</i><sub>2</sub> × <i>H</i><sub>2</sub> ãæºãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡, é
ç¹ã® 30% åã«ã€ããŠã¯, <i>R</i>, <i>W<sub>k</sub></i>, <i>H<sub>k</sub></i> ≤ 100 ãæºãã.
</p>
<p>
<i>R</i> ã 0 ã®ãšãå
¥åã®çµäºã瀺ã.ãããŒã¿ã»ããã®æ°ã¯ 10 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
<!--åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.-->
ããŒã¿ã»ããããšã«,æ±ãã身å蚌ã®èªèšŒã¬ãã«ã®åã®æå°å€ã 1 è¡ã«åºåãã.
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
5
2 2 1 2
9 5
1 17
3 2 2 1
6 1 20
8 18 3
8
5 4 1 3
5 5 4 5 5
8 2 1 9 7
1 1 3 5 1
7 2 7 1 3
6 5 6 2
2 3 5 8 2 7
1 6 9 4 5 1
2 4 5 4 2 2
5 4 2 5 3 3
7 1 5 1 5 6
6
3 3 2 2
2 9 2
9 1 9
2 9 2
2 2 1 1
1 3
5 7
0
</pre>
<h3>åºåäŸ</h3>
<pre>
15
4
9
</pre>
<p>
1ã€ç®ã®äŸ ã§ã¯,èŠåŠè
ã«æž¡ã身å蚌ã®èªèšŒã¬ãã«ã,äºåæ 1 ã®èªèšŒã¬ãã«ã 9,äºåæ 2 ã®èªèšŒã¬ãã«ã 6 ãšãªãããã«èšå®ãããš,èŠåŠè
㯠5 åã®éšå± (äºåæ 1 ã®éšå± (1, 1)<sub>1</sub> , (1, 2)<sub>1</sub> , (2, 1)<sub>1</sub> ãš,äºåæ 2 ã®éšå± (1, 1)<sub>2</sub> , (2, 1)<sub>2</sub> ) ã蚪ããããšãã§ãã.ãã®ãšã,èªèšŒã¬ãã«ã®å㯠15 ãšãªã.ãããåèš 5 å以äžã®éšå±ã蚪ããããšãã§ããããã®èªèšŒã¬ãã«ã®åã®æå°å€ã§ãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_authentication1">
</center>
<br>
<p>
ïŒã€ç®ã®äŸ ã§ã¯,èŠåŠè
ã«æž¡ã身å蚌ã®èªèšŒã¬ãã«ã,äºåæ 1 ã®èªèšŒã¬ãã«ã 9,äºåæ 2 ã®èªèšŒã¬ãã«ã 0 ãšãªãããã«èšå®ãããš,èŠåŠè
㯠9 åã®éšå± (äºåæ 1 ã®éšå± (1, 1)<sub>1</sub>, (1, 2)<sub>1</sub>, (1, 3)<sub>1</sub>, (2, 1)<sub>1</sub>, (2, 2)<sub>1</sub>, (2, 3)<sub>1</sub>, (3, 1)<sub>1</sub>, (3, 2)<sub>1</sub>, (3, 3)<sub>1</sub> ) ã蚪ããããšãã§ãã.äºåæ 2 ã®éšå±ã¯ 1 åã蚪ããããšãã§ããªã.(ãšã¬ããŒã¿ãŒããŒã« (1, 1)<sub>2</sub>ã«ããå
¥ãããšãã§ããªã.) ãã®ãšã,èªèšŒã¬ãã«ã®å㯠9 ãšãªã.ãããåèš 6 å以äžã®éšå±ã蚪ããããšãã§ããããã®èªèšŒã¬ãã«ã®åã®æå°å€ã§ãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_authentication2">
</center>
<br>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\n2 2 1 2\n9 5\n1 17\n3 2 2 1\n6 1 20\n8 18 3\n8\n5 4 1 3\n5 5 4 5 5\n8 2 1 9 7\n1 1 3 5 1\n7 2 7 1 3\n6 5 6 2\n2 3 5 8 2 7\n1 6 9 4 5 1\n2 4 5 4 2 2\n5 4 2 5 3 3\n7 1 5 1 5 6\n6\n3 3 2 2\n2 9 2\n9 1 9\n2 9 2\n2 2 1 1\n1 3\n5 7\n0\n",
"5\n2 2 1 2\n9 5\n1 17\n3 2 2 1\n6 1 20\n8 18 3\n8\n5 4 1 3\n5 5 4 5 5\n8 2 1 9 7\n1 1 3 5 1\n7 2 7 1 3\n6 5 6 2\n2 3 5 8 2 7\n1 6 9 4 5 1\n2 4 5 4 2 2\n5 4 2 5 3 3\n7 1 5 1 5 6\n6\n3 3 2 2\n2 9 2\n9 1 9\n2 9 2\n2 2 1 1\n1 3\n5 7\n0\n"
]
] |
p00466 | Receipt |
<H1>ã¬ã·ãŒã </H1>
<h2>åé¡</h2>
<p>
倪éåã¯10åã®æ¬ã賌å
¥ããïŒ
åŸæ¥ïŒ
ã¬ã·ãŒããããšã«äŸ¡æ Œã調ã¹ãããšãããïŒ
ã¬ã·ãŒãã«ã¯æ±ããããïŒ
ããæ¬ã®äŸ¡æ Œãèªã¿åããªãã£ãïŒ
ãã®æ¬ã®äŸ¡æ ŒãïŒ
10åã®ç·é¡ãšä»ã®9åã®äŸ¡æ Œããèšç®ããããšã«ããïŒ
</p>
<p>
äŸ¡æ Œãèªã¿åããªãã£ãæ¬ã®äŸ¡æ Œãåºåããããã°ã©ã ãæžãïŒ
ãªãïŒæ¬ã®äŸ¡æ Œã¯ãã¹ãŠæ£ã®æŽæ°ã§ããïŒ
ãŸãïŒæ¶è²»çšãèæ
®ããå¿
èŠã¯ãªãïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
åããŒã¿ã»ããã¯10è¡ãããªãïŒ1è¡ã«1ã€ãã€æ£ã®æŽæ°ãæžãããŠããïŒ
1è¡ç®ã®æŽæ°ã¯10åã®ç·é¡ãïŒ
2è¡ç®ãã10è¡ç®ã®æŽæ°ã¯èªã¿åããäŸ¡æ Œãè¡šããŠããïŒ
ãªãïŒ10åã®ç·é¡ã¯10000以äžã§ããïŒ
</p>
<p>
ç·é¡ ã 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2> åºå</h2>
<p>
ããŒã¿ã»ããããšã«ïŒäŸ¡æ Œãèªã¿åããªãã£ãæ¬ã®äŸ¡æ Œã1 è¡ã«åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
9850
1050
800
420
380
600
820
2400
1800
980
0
</pre>
<h3>åºåäŸ</h3>
<pre>
600
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n",
"9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n"
]
] |
p00467 | Sugoroku |
<H1>ãããã</H2>
<h2> åé¡</h2>
<p>
JOI ããã¯äžäººã§ããããéã³ãããŠããïŒ
ãã®ããããã«ã¯äžçŽç·äžã« N åã®ãã¹ãããïŒãããã移åã®æ瀺ãæžãããŠããïŒã¹ã¿ãŒãå°ç¹ã¯ 1 ãã¹ç®ã§ããïŒãŽãŒã«ã¯Nãã¹ç®ã§ããïŒ
JOI ããã¯ãŽãŒã«ãããŸã§æ¬¡ãç¹°ãè¿ãïŒ
</p>
<p>
ãµã€ã³ããæ¯ã£ãŠåºãç®ã®æ°ã ãçŸåšã®ãã¹ããé²ã¿ïŒãã®ãã¹ã®æ瀺ã«åŸãïŒ
æ瀺ã«åŸã£ãŠç§»åããå
ã®ãã¹ã®æ瀺ã«ã¯åŸããªãïŒ
</p>
<p>
ã¡ããã© N ãã¹ç®ã«æ¢ãŸãæã ãã§ãªãïŒç§»åå
ã N ãã¹ç®ãè¶
ããå ŽåããŽãŒã«ãšãªãïŒ
</p>
<p>
ããããã®ç€é¢ãšïŒ M ååã®ãµã€ã³ãã®åºãç®ãäžãããããšãïŒãµã€ã³ããäœåæ¯ã£ããšããã§ãŽãŒã«ããããåºåããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
åããŒã¿ã»ãã㯠1+N+M è¡ãããªãïŒ
</p>
<p>
å
¥åã® 1 è¡ç®ã«ã¯ïŒã€ã®æŽæ° N,M ïŒ2 ≤ N ≤ 1000 ïŒ1 ≤ M ≤ 1000 ïŒã空çœãåºåããšããŠæžãããŠããïŒ
N ã¯ããããã®ãã¹ç®ã®åæ°ãïŒ M ã¯äžãããããµã€ã³ãã®ç®ã®åæ°ãè¡šãïŒ
</p>
<p>
ç¶ã N è¡ã«ã¯ -999 ä»¥äž 999 以äžã®æŽæ°ãïŒã€ãã€æžãããŠããïŒ
1+i è¡ç® ïŒ 1 ≤ i ≤ N ïŒ ã®æŽæ°ã¯ïŒããããã® i çªç®ã®ãã¹ã®æ瀺ãè¡šãïŒ
æžãããŠããæŽæ°ã X ãšããïŒ
X=0 ã®ãšãã¯ãäœãããªãããïŒ X>0 ã®ãšãã¯ã X ãã¹é²ãããïŒX<0 ã®ãšãã¯ã |X| ãã¹æ»ããã®æ瀺ãè¡šãïŒãã ãïŒ |X| 㯠X ã®çµ¶å¯Ÿå€ãè¡šãïŒ
</p>
<p>
ç¶ã M è¡ã«ã¯ 1 ä»¥äž 6 以äžã®æŽæ°ãïŒã€ãã€æžãããŠããïŒ 1+N+j è¡ç® ïŒ 1 ≤ j ≤ M ïŒã®æ°ã¯ j åç®ã«åºããµã€ã³ãã®ç®ãè¡šãïŒ
</p>
<p>
ãã ãïŒ 2 è¡ç®ãš 1+N è¡ç®ã®æ°ã¯å¿
ã 0 ã§ããïŒ
1 ãã¹ç®ãããåã®ãã¹ã«ç§»åãããæ瀺ãæžãããŠãããã¹ã¯ãªãïŒ
ãŸãïŒã©ã®æ¡ç¹çšå
¥åããŒã¿ã«ãããŠããµã€ã³ããæ¯ãåæ°ã M 以äžã§ãŽãŒã«ã§ããïŒ
</p>
<p>
N, M ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2> åºå</h2>
<p>
ããŒã¿ã»ããããšã«ïŒãµã€ã³ããäœåæ¯ã£ããšããã§ãŽãŒã«ããããè¡šãæŽæ°ã 1 è¡ã«åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
10 5
0
0
5
6
-3
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
1
5
2
4
6
5
5
4
1
6
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
5
6
</pre>
<p>次ã®å³ã¯1ã€ç®ã®å
¥åäŸãè¡šãïŒ<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2010-yo-t2-fig01">
</p>
<p>次ã®å³ã¯2ã€ç®ã®å
¥åäŸãè¡šãïŒ<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2010-yo-t2-fig02">
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"10 5\n0\n0\n5\n6\n-3\n8\n1\n8\n-4\n0\n1\n3\n5\n1\n5\n10 10\n0\n-1\n-1\n4\n4\n-5\n0\n1\n-6\n0\n1\n5\n2\n4\n6\n5\n5\n4\n1\n6\n0 0\n",
"10 5\n0\n0\n5\n6\n-3\n8\n1\n8\n-4\n0\n1\n3\n5\n1\n5\n10 10\n0\n-1\n-1\n4\n4\n-5\n0\n1\n-6\n0\n1\n5\n2\n4\n6\n5\n5\n4\n1\n6\n0 0\n"
]
] |
p00468 | Party |
<H1>ããŒãã£ãŒ</H2>
<h2>åé¡</h2>
<p>
ããªãã¯ã¯ãªã¹ãã¹ããŒãã£ãŒã«åŠæ ¡å
ã®èªåã®åéãšïŒèªåã®åéã®åéãæåŸ
ããããšã«ããïŒ
ããªãã®éãåŠæ ¡ã®çåŸæ°ã¯ n 人ã§ããïŒããããã®çåŸã«ã¯ 1 ãã n ãŸã§ã®çªå·ãå²ãæ¯ãããŠããïŒ
ããªãã®çªå·ã¯ 1 ã§ããïŒ
ããªãã®æå
ã«ã¯ïŒèª°ãšèª°ãåéã§ããããèšãããªã¹ããããïŒ
ãã®ãªã¹ããããšã«ïŒ
ããªããã¯ãªã¹ãã¹ããŒãã£ãŒã«æåŸ
ããçåŸæ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
ããŒã¿ã»ããã®1 è¡ç®ã«ã¯åŠæ ¡ã®çåŸæ° n ïŒ2 ≤ n ≤ 500ïŒãïŒ
2 è¡ç®ã«ã¯ãªã¹ãã®é·ã m ïŒ1 ≤ m ≤ 10000ïŒãæžãããŠããïŒ
å
¥åã¯å
šéšã§ 2+m è¡ãããªãïŒ2+i è¡ç®ïŒ1 ≤ i ≤ mïŒã«ã¯ 2 ã€ã®æŽæ° a<sub>i</sub> ãš b<sub>i</sub> ïŒ1 ≤ a<sub>i</sub> < b<sub>i</sub> ≤ nïŒã空çœåºåãã§æžãããŠããïŒçªå· a<sub>i</sub> ãšçªå· b<sub>i</sub> ã®çåŸãåéå士ã§ããããšãè¡šãïŒ
3 è¡ç®ãã 2+m è¡ç®ã«ã¯åãåéé¢ä¿ãè¡šãè¡ãéè€ããŠçŸããããšã¯ãªãïŒ
</p>
<p>
n, m ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«ïŒããªããã¯ãªã¹ãã¹ããŒãã£ãŒã«æåŸ
ããçåŸæ°ã1 è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
6
5
1 2
1 3
3 4
2 3
4 5
6
5
2 3
3 4
4 5
5 6
2 5
0
0
</pre>
<h3>åºåäŸ</h3>
<pre>
3
0
</pre>
<p>
1ã€ç®ã®å
¥åäŸ ã«ãããŠïŒããªãã®åéã¯çªå· 2 ãšçªå· 3 ã®çåŸã® 2 人ã§ããïŒ
ãŸãïŒçªå· 3 ãšçªå· 4 ã®çåŸã¯åéå士ã§ããã®ã§ïŒ
çªå· 4 ã®çåŸã¯ããªãã®åéã®åéã§ããïŒ
çªå· 5 ãšçªå· 6 ã®çåŸã¯ããªãã®åéã§ããªãïŒããªãã®åéã®åéã§ããªãïŒ
ãããã£ãŠïŒããªãã¯çªå· 2,3,4 ã® 3 人ã®çåŸãã¯ãªã¹ãã¹ããŒãã£ãŒã«æåŸ
ããïŒ
</p>
<p>
2ã€ç®ã®å
¥åäŸ ã«ãããŠïŒããªãã«ã¯åéã¯ããªãïŒ
ãããã£ãŠïŒããªããã¯ãªã¹ãã¹ããŒãã£ãŒã«æåŸ
ããçåŸæ°ã¯ 0 人ã§ããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n4 5\n5 6\n2 5\n0\n0\n",
"6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n4 5\n5 6\n2 5\n0\n0\n"
]
] |
p00469 | Lining up the cards |
<H1>ã«ãŒã䞊ã¹</H1>
<h2>åé¡</h2>
<p>
è±åãã㯠n æïŒ4 ≤ n ≤ 10ïŒã®ã«ãŒãã䞊ã¹ãŠéãã§ããïŒ
ããããã®ã«ãŒãã«ã¯ 1 ä»¥äž 99 以äžã®æŽæ°ã 1 ã€ãã€æžãããŠããïŒ
è±åããã¯ïŒãããã®ã«ãŒãã®äžãã k æïŒ2 ≤ k ≤ 4ïŒãéžã³ïŒ
暪äžåã«äžŠã¹ãŠæŽæ°ãäœãããšã«ããïŒ
è±åããã¯å
šéšã§äœçš®é¡ã®æŽæ°ãäœãããšãã§ããã ãããïŒ
</p>
<p>
äŸãã°ïŒ1, 2, 3, 13, 21 ã® 5 æã®ã«ãŒããäžãããïŒãããã 3 æãéžã³æŽæ°ãäœãããšãèããïŒ
2, 1, 13 ããã®é ã«äžŠã¹ããšïŒæŽæ° 2113 ãäœãããšãã§ããïŒ
ãŸãïŒ21, 1, 3 ããã®é ã«äžŠã¹ãŠãïŒåãæŽæ° 2113 ãäœãããšãã§ããïŒ
ãã®ããã«ïŒç°ãªãã«ãŒãã®çµã¿åããããåãæŽæ°ãäœãããããšãããïŒ
</p>
<p>
n æã®ã«ãŒãã«æžãããæŽæ°ãäžãããããšãïŒ
ãã®äžãã k æãéžã³ïŒæšªäžåã«äžŠã¹ãããšã§äœãããšãã§ããæŽæ°ã®åæ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
åããŒã¿ã»ãã㯠2+n è¡ãããªãïŒ
1 è¡ç®ã«ã¯ã«ãŒãã®ææ° n ïŒ4 ≤ n ≤ 10ïŒãïŒ
2 è¡ç®ã«ã¯ã«ãŒããéžã¶ææ° k ïŒ2 ≤ k ≤ 4ïŒãæžãããŠããïŒ
2+i è¡ç®ïŒ1 ≤ i ≤ nïŒã«ã¯ i æç®ã®ã«ãŒãã«æžãããŠãã 1 ä»¥äž 99 以äžã®æŽæ°ãæžãããŠããïŒ
</p>
<p>
n, k ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«ïŒè±åãããäœãããšãã§ããæŽæ°ã®åæ°ã1 è¡ã«åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
4
2
1
2
12
1
6
3
72
2
12
7
2
1
0
0
</pre>
<h3>åºåäŸ</h3>
<pre>
7
68
</pre>
<p>
1ã€ç®ã®å
¥åäŸ ã«ãããŠïŒ
1, 2, 12, 1 ã® 4 æã®ã«ãŒãã®äžãã 2 æãéžã³ïŒæšªäžåã«äžŠã¹ãŠäœãããšãã§ããæŽæ°ã¯ïŒ
11, 12, 21, 112, 121, 122, 212 ã® 7 åã§ããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4\n2\n1\n2\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0\n",
"4\n2\n1\n2\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0\n"
]
] |
p00470 | Commute routes |
<H1>éå€çµè·¯ </H1>
<h2>åé¡</h2>
<p>
JOIãããäœãã«ããã®ããéœåžã¯ïŒååæ¹åã«ãŸã£ããã«äŒžã³ã w æ¬ã®éè·¯ãšïŒæ±è¥¿æ¹åã«ãŸã£ããã«äŒžã³ã h æ¬ã®éè·¯ã«ããïŒç¢ç€ã®ç®ã®åœ¢ã«åºåããããŠããïŒ
</p>
<p>
ååæ¹åã® w æ¬ã®éè·¯ã«ã¯ïŒè¥¿ããé ã« 1, 2, ... , w ã®çªå·ãä»ããããŠããïŒãŸãïŒæ±è¥¿æ¹åã® h æ¬ã®éè·¯ã«ã¯ïŒåããé ã« 1, 2, ... , h ã®çªå·ãä»ããããŠããïŒè¥¿ãã i çªç®ã®ååæ¹åã®éè·¯ãšïŒåãã j çªç®ã®æ±è¥¿æ¹åã®éè·¯ã亀ãã亀差ç¹ã (i, j) ã§è¡šãïŒ
</p>
<p>
JOIããã¯ïŒäº€å·®ç¹ (1, 1) ã®è¿ãã«äœãã§ããïŒäº€å·®ç¹ (w, h) ã®è¿ãã®äŒç€Ÿã«è»ã§éã£ãŠããïŒè»ã¯éè·¯ã«æ²¿ã£ãŠã®ã¿ç§»åããããšãã§ããïŒJOIããã¯ïŒéå€æéãçãããããïŒæ±ãŸãã¯åã«ã®ã¿åãã£ãŠç§»åããŠéå€ããŠããïŒãŸãïŒãã®éœåžã§ã¯ïŒäº€éäºæ
ãæžããããã«ïŒæ¬¡ã®ãããªäº€éèŠåãèšããããŠããïŒ
</p>
<ul>
<li>
亀差ç¹ãæ²ãã£ãè»ã¯ïŒãã®çŽåŸã®äº€å·®ç¹ã§æ²ããããšã¯åºæ¥ãªãïŒ
</li>
</ul>
<p>
ããªãã¡ïŒäº€å·®ç¹ã§æ²ãã£ãããšã«1ãããã¯ã ãé²ãã§åã³æ²ããããšã¯èš±ãããªãïŒãã®ãšãïŒJOIããã®éå€çµè·¯ã¯äœéãèããããã ãããïŒ
</p>
<p>
w ãš h ãäžãããããšãïŒJOIããã®éå€çµè·¯ã®åæ°ã 100000 ã§å²ã£ãäœããåºåããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯1è¡ãããªãïŒç©ºçœãåºåããšããŠ2åã®æŽæ° w, h (2 ≤ w ≤ 100ïŒ 2 ≤ h ≤ 100) ãæžãããŠããïŒw ã¯ååæ¹åã®éè·¯ã®æ¬æ°ïŒ h ã¯æ±è¥¿æ¹åã®éè·¯ã®æ¬æ°ãè¡šãïŒ
</p>
<p>
w, h ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«ïŒJOIããã®éå€çµè·¯ã®åæ°ã 100000 ã§å²ã£ãäœãã1è¡ã«åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3 4
15 15
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
5
43688
</pre>
<p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2010-yo-t5-fig01"><br>1ã€ç®ã®å
¥åäŸã«ãããJOIããã®éå€çµè·¯ ( 5 éã)
</p>
<p>
1ã€ç®ã®å
¥åäŸã«ãããŠïŒJOIããã®éå€çµè·¯ã¯å³ã®ããã« 5 éãèããããïŒãããã£ãŠïŒ5ãåºåããïŒ
</p>
<p>
2ã€ç®ã®å
¥åäŸã«ãããŠïŒJOIããã®éå€çµè·¯ã¯ 143688 éãèããããïŒãããã£ãŠïŒ143688 ã 100000 ã§å²ã£ãäœãã§ãã 43688 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 4\n15 15\n0 0\n",
"3 4\n15 15\n0 0\n"
]
] |
p00471 | Reindeer with no sense of direction |
<H1>æ¹åé³çŽã®ããã«ã€</H1>
<h2> åé¡</h2>
<p>
ä»å¹Žã JOI çºã«ãµã³ã¿ã¯ããŒã¹ã空ãããã£ãŠããïŒJOI çºã«ããå
šãŠã®å®¶ã«ã¯åäŸãããã®ã§ïŒãã®ãµã³ã¿ã¯ããŒã¹ã¯ JOI çºã®å
šãŠã®å®¶ã«ãã¬ãŒã³ããé
ã£ãŠãŸãããªããã°ãªããªãïŒãããïŒä»å¹Žã¯é£ããŠããããã«ã€ãå°ã
æ¹åé³çŽã§ããïŒãŸã建ç©ã®äžä»¥å€ã«éããããšãã§ããªãããïŒå
šãŠã®å®¶ã«ãã¬ãŒã³ããé
ãããã«ã¯å°ã
éé ã工倫ããªããã°ãªããªãããã ïŒ
</p>
<p>
JOI çºã¯æ±è¥¿ååã«åºç»æŽçãããŠããïŒååºç»ã¯å®¶ïŒæäŒïŒç©ºãå°ã®ããããã§ããïŒJOI çºã«ã¯ 1 ã€ã ãæäŒãããïŒæ¬¡ã®ã«ãŒã«ã«åŸãïŒãµã³ã¿ã¯ããŒã¹ãšããã«ã€ã¯æäŒããåºçºãïŒå
šãŠã®å®¶ã« 1 åãã€ãã¬ãŒã³ããé
ã£ãåŸïŒæäŒã«æ»ãïŒ
</p>
<ul>
<li>
ä»å¹Žã®ããã«ã€ã¯å°ã
æ¹åé³çŽã§ããããïŒæ±è¥¿ååããããã®æ¹åã«ãŸã£ããé£ã¶ããšããã§ããïŒç©ºäžã§ã¯æ¹å転æã§ããªãïŒ
<li>
ãŸã ãã¬ãŒã³ããé
ã£ãŠããªã家ã®äžã¯èªç±ã«ééã§ããïŒãŸã ãã¬ãŒã³ããé
ã£ãŠããªã家ã«ã¯éããããšãã§ããïŒå®¶ã«éããæã¯å¿
ããã¬ãŒã³ããé
ãïŒãã®åŸã¯æ±è¥¿ååããããã®æ¹åã«é£ã³ç«ã€ïŒ
<li>
JOI çºã®å®¶ã§ã¯ïŒã¯ãªã¹ãã¹ã®å€ã¯ãµã³ã¿ã¯ããŒã¹ãæ¥ããŸã§ã¯æçãã€ããã«éãããŠãããïŒãµã³ã¿ã¯ããŒã¹ãé£ã³ç«ã£ãåŸã¯æçãã€ããïŒæçãã€ãããšç
çªããç
ãåºãã®ã§ïŒãã¬ãŒã³ããé
ãçµãã家ã®äžãééããããšã¯ã§ããªãïŒ
<li>
æäŒã®äžã¯èªç±ã«ééããããšãã§ããïŒãããïŒæäŒã§ã¯ç€Œæãè¡ãããŠããã®ã§ïŒå
šãŠã®ãã¬ãŒã³ããé
ãçµãããŸã§æäŒã«éããããšã¯ã§ããªãïŒ
<li>
空ãå°ã®äžã¯èªç±ã«ééããããšãã§ãããïŒç©ºãå°ã«éããããšã¯ã§ããªãïŒ
</ul>
<p>
å
¥åãšããŠçºã®æ§é ãäžãããããšãïŒãµã³ã¿ã¯ããŒã¹ãšããã«ã€ããã¬ãŒã³ããé
ãéé ãäœéãããããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥åã¯è€æ°ã®ããŒã¿ã»ãããããªãïŒåããŒã¿ã»ããã¯ä»¥äžã®åœ¢åŒã§äžããããïŒ
</p>
<p>
åããŒã¿ã»ãã㯠n+1 è¡ããïŒ
1 è¡ç®ã«ã¯æŽæ° m (1 ≤ m ≤ 10) ãšæŽæ° n (1 ≤ n ≤ 10) ã空çœã§åºåãããŠæžãããŠããïŒ
2 è¡ç®ãã n+1 è¡ç®ãŸã§ã®åè¡ã«ã¯ïŒ0ïŒ1ïŒ2 ã®ãããããïŒ
空çœã§åºåãã㊠m åæžãããŠããïŒåã
ãååºç»ã®ç¶æ
ãè¡šããŠããïŒ
åãã i çªç®ïŒè¥¿ãã j çªç®ã®åºç»ã (i,j) ãšèšè¿°ããããšã«ãããš
(1 ≤ i ≤ n, 1 ≤ j ≤ m)ïŒ
第 i+1 è¡ç®ã® j çªç®ã®å€ã¯ïŒ
åºç» (i,j) ã空ãå°ã§ããå Žå㯠0 ãšãªãïŒ
家ã§ããå Žå㯠1 ãšãªãïŒ
æäŒã§ããå Žå㯠2 ãšãªãïŒ
æäŒã®åæ°ã¯ 1 ã§ããïŒå®¶ã®åæ°ã¯ 1 ä»¥äž 23 以äžã§ããïŒ
ãã ãïŒæ¡ç¹çšå
¥åããŒã¿ã§ã¯é
ãéé ã 2000000 éãããããããšã¯ãªãïŒ
</p>
<p>
m, n ããšãã« 0 ã®ãšãå
¥åã®çµäºã瀺ã.ããŒã¿ã»ããã®æ°ã¯ 5 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
ããŒã¿ã»ããããšã«,ãã¬ãŒã³ããé
ãéé ãäœéãããããè¡šãæŽæ°ã1 è¡ã«åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
3 2
1 0 1
1 0 2
3 3
1 1 1
1 0 1
1 1 2
0 0
</pre>
<h3>åºåäŸ</h3>
<pre>
2
6
</pre>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2010-yo-t6-fig01"><br>
<p>å³: 2ã€ç®ã®å
¥åäŸ ã«å¯Ÿãã 6 éãå
šãŠã®éé
ïŒæ°åã¯é
ãé åºãè¡šãïŒ
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 2\n1 0 1\n1 0 2\n3 3\n1 1 1\n1 0 1\n1 1 2\n0 0\n",
"3 2\n1 0 1\n1 0 2\n3 3\n1 1 1\n1 0 1\n1 1 2\n0 0\n"
]
] |
p00472 | A Traveler |
<H1>æ
人</H1>
<h2> åé¡</h2>
<p>
ããªã㯠JOI è¡éãæ
ããæ
人ã§ãã.JOI è¡éã¯æ±è¥¿ã«ãŸã£ããã«å»¶ã³ãéè·¯ã§,JOI è¡éäžã«ã¯ n åã®å®¿å Žçºããã.å®¿å Žçºã«ã¯è¥¿ããæ±ã®é ã« 1 ãã n ãŸã§ã®çªå·ãä»ããããŠãã.JOI è¡éäžã®æã西ã®å®¿å Žçºãå®¿å Žçº 1 ã§ãã,æãæ±ã®å®¿å Žçºãå®¿å Žçº n ã§ãã.
</p>
<p>
ããªãã¯,å®¿å Žçº 1 ããåºçºã㊠m æ¥éã®æ
ã«åºãããšã«ãªã£ã.ããªãã®æ
çšã¯æ°å a1 , a2 , . . . , am ã«åŸã,次ã®ããã«æ±ºããããŠãã.ai 㯠i æ¥ç®ã®ç§»åæ¹æ³ãè¡šã 0 ã§ã¯ãªãæŽæ°ã§ãã.i æ¥ç®ã«ããªããåºçºããå®¿å Žçºãå®¿å Žçº k ãšãããš,i æ¥ç®ã«ããªãã¯å®¿å Žçº k ããå®¿å Žçº k + ai ãŸã§ãŸã£ããã«ç§»åããããšãæå³ãã.
</p>
<p>
å®¿å Žçºã®åæ° n,æ
ã®æ¥æ° m,å®¿å Žçºéã®è·é¢ã®æ
å ±ãš,移åæ¹æ³ãè¡šãæ°åa1 , a2 , . . . , am ãäžãããããšã,m æ¥éã®æ
ã«ãããããªãã®ç§»åè·é¢ã®åèšã100000 = 10<sup>5</sup> ã§å²ã£ãäœããæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥åºåã®äŸã«å¯Ÿå¿ããå³</h2>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0549">
</center>
<h2>å
¥å</h2>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.
</p>
-->
<p>
1 è¡ç®ã«ã¯æŽæ° n, m ã空çœåºåãã§æžãããŠãã.n (2 ≤ n ≤ 100000 = 10<sup>5</sup> ) ã¯JOI è¡éäžã®å®¿å Žçºã®åæ°ã,m (1 ≤ m ≤ 100000 = 10<sup>5</sup> ) ã¯æ
ã®æ¥æ°ãè¡šã.
</p>
<p>
ç¶ã n â 1 è¡ã¯ JOI è¡éäžã®å®¿å Žçºéã®è·é¢ãè¡šã.i + 1 è¡ç® (1 ≤ i ≤ n â 1) ã«
ã¯å®¿å Žçº i ãšå®¿å Žçº i + 1 ã®è·é¢ãè¡šãæ£æŽæ° si (1 ≤ si ≤ 100) ãæžãããŠãã.
</p>
<p>
ç¶ã m è¡ã«ã¯ m æ¥éã®ç§»åæ¹æ³ãè¡šãæ°åãæžãããŠãã.i + n è¡ç® (1 ≤ i ≤ m)
ã«ã¯ i æ¥ç®ã®ããªãã®ç§»åæ¹æ³ãè¡šã 0 ã§ã¯ãªãæŽæ° ai ãæžãããŠãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã«ãããŠ,å®¿å Žçº 1 ãã西ã«ç§»åããããšã,å®¿å Žçº n ããæ±ã«ç§»
åããããšã¯ãªã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 50% åã«ã€ããŠã¯,n ≤ 100 ã〠m ≤ 100 ãæºãã.
</p>
<h2> åºå</h2>
<p>
<!--åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.-->
<!--output.txt-->åºå ã¯, m æ¥éã®æ
ã«ãããããªãã®ç§»åè·é¢ã®åèšã 100000 = 10<sup>5</sup> ã§å²ã£ãäœããå«ã 1 è¡ãããªã.
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
7 5
2
1
1
3
2
1
2
-1
3
2
-3
</pre>
<h3>åºåäŸ 1</h3>
<pre>
18
</pre>
<p>
1 æ¥ç®ã«,ããªãã¯å®¿å Žçº 1 ããå®¿å Žçº 3 ãŸã§ç§»åãã.2 æ¥ç®ã«,ããªãã¯å®¿å Ž
çº 3 ããå®¿å Žçº 2 ãŸã§ç§»åãã.ãããŠ,3 æ¥ç®ã«å®¿å Žçº 2 ããå®¿å Žçº 5 ãŸã§ç§»å
ã,4 æ¥ç®ã«å®¿å Žçº 5 ããå®¿å Žçº 7 ãŸã§ç§»åã,5 æ¥ç®ã«å®¿å Žçº 7 ããå®¿å Žçº 4 ãŸ
ã§ç§»åãã.5 æ¥éã®æ
ã«ãããããªãã®ç§»åè·é¢ã®åèšã¯ 18 ã§ãã.
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n3\n2\n-3\n",
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n3\n2\n-3\n"
]
] |
p00473 | Dividing Snacks |
<H1>ãèåã®åå²
ã</H1>
<h2> åé¡</h2>
<p>
é·ã N ããªã¡ãŒãã«ã®æ£ç¶ã®ãèåã 1 æ¬ãã(ãã㧠N ã¯å¶æ°). 2 人㮠JOI
é¢ä¿è
ã,ãã®ãèåãè€æ°æ¬ã«åæããŠ,åèš N/2 ããªã¡ãŒãã«ãã€ã«åããããš
ã«ãã.
</p>
<p>
çç±ã¯äžæã§ããã,ãã®ãèåã¯å Žæã«ãã£ãŠåæã®ãããããç°ãªã£ãŠãã.
2 人ã¯,ãèåãå·Šãã 1 ããªã¡ãŒãã«ããšã«èª¿ã¹,åå Žæã§åæã«äœç§ãããã
ãå²ãåºãã.2 人ããèåãåããããã®åæã«ãããç§æ°ã®æå°å€ãæ±ããã
ãã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.
</p>
-->
<p>
å
¥åã® 1 è¡ç®ã«ã¯,æ£ã®é·ã N(2 ≤ N ≤ 10000 ,ãã ã N ã¯å¶æ°) ãæžãããŠã
ã.å
¥åã® i + 1 è¡ç® (1 ≤ i ≤ N â 1) ã«ã¯,巊端ãã i ããªã¡ãŒãã«ç®ã®å Žæã®å
æã«ãããç§æ°ãè¡šãæŽæ° ti (1 ≤ ti ≤ 10000) ãæžãããŠãã.åæå¯èœãªå Žæã
N â 1 ç®æã§ããããšã«æ³šæãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 5% åã«ã€ããŠã¯,é«ã
2 ã«æãåæããããšã§æ
å°å€ãå®çŸã§ã,10% åã«ã€ããŠã¯,é«ã
3 ã«æãåæããããšã§æå°å€ãå®çŸã§
ãã.é
ç¹ã® 20% åã«ã€ããŠã¯,N ≤ 20 ã§ãã.
</p>
<h2> åºå</h2>
<p>
<!--åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.-->
åºåã¯2 人ããèåãåãããã®åæã«ãããç§æ°ã®æå°å€ãå«ã 1 è¡ãããªã.
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
6
1
8
12
6
2
</pre>
<h3>åºåäŸ 1</h3>
<pre>
7
</pre>
<p>
ãã®å Žå,巊端ãã 1 ããªã¡ãŒãã«ãš 4 ããªã¡ãŒãã«ã®å Žæã§åæãããšããã
ç§æ°ãæå°ãšãªã.ãããç§æ°ã¯ 1 ç§ãš 6 ç§ã§,åèš 7 ç§ã§ãã.
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0550">
</center>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"6\n1\n8\n12\n6\n2\n",
"6\n1\n8\n12\n6\n2\n"
]
] |
p00474 | Icicles |
<H1>ã€ãã</H1>
<h2> åé¡</h2>
<p>
ã«ããã«äœã JOI åã®å®¶ã®è»äžã«ã¯,ç«æŽŸãªã€ãããåºæ¥ãŠãã.ãã£ãããªã®ã§,JOI åã¯ã€ããã«ã€ããŠèª¿ã¹ãŠã¿ãããšã«ãã.
</p>
<p>
JOI åã®å®¶ã®è»äžã«ã¯ N æ¬(2 ≤ N ≤ 100000 = 10<sup>5</sup> )ã®ã€ãããåºæ¥ãŠãã.ãããã®ã€ããã¯äžçŽç·äžã«äžŠãã§ãã,è»äžã®å·Šç«¯ãã i cm(1 ≤ i ≤ N )ã®äœçœ®ã« i æ¬ç®ã®ã€ãããåºæ¥ãŠãã.i æ¬ç®ã®ã€ããã®é·ãã¯æå ai cm(ai 㯠1 以äžã®æŽæ°)ã§ãã.ãããã®ã€ããã¯,次ã®ãããªèŠåã«ãã£ãŠäŒžã³ãŠãã:
</p>
<ul>
<li> i æ¬ç®ã®ã€ããã¯,i â 1 æ¬ç®ã®ã€ãããš i + 1 æ¬ç®ã®ã€ããã®äž¡æ¹ãããé·ãå Žåã«ã®ã¿,1 æéã«ã€ã 1 cm ãã€äŒžã³ã(ãã ã,䞡端ã®ã€ããã«é¢ããŠã¯çæ¹ã®é£ã®ã¿èãã.ããªãã¡,1 æ¬ç®ã®ã€ãã㯠2 æ¬ç®ã®ã€ããããé·ããã°äŒžã³,N æ¬ç®ã®ã€ãã㯠N â 1 æ¬ç®ã®ã€ããããé·ããã°äŒžã³ã).
</li>
<li> ã©ã®ã€ããã,L cm(2 ≤ L ≤ 50000)ã«éããç¬éã«,æ ¹å
ããæãã(æããã€ããã¯,以åŸé·ã 0 cm ã®ã€ãããšã¿ãªã)
.
</li>
</ul>
<p>
æåã®æ®µéã§,é£ãåã 2 æ¬ã®ã€ããã®é·ãã¯ãã¹ãŠç°ãªã£ãŠãã.ãã®ãšã,ååãªæéãçµéããã°,N æ¬ãã¹ãŠã®ã€ãããæããŠé·ã 0 cm ãšãªã.JOI åã¯,ã€ããããã®ãããªç¶æ
ã«ãªããŸã§ã®æéãç¥ããããªã£ã.
</p>
<p>
N æ¬ã®ã€ããã®æåã®é·ããšã€ããã®éçã®é·ã L ãäžãããããš,ãã¹ãŠã®ã€ãããæãããŸã§ã«ãããæéãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.
</p>
-->
<p>
å
¥åã® 1 è¡ç®ã«ã¯,ã€ããã®æ¬æ°ãè¡šãæŽæ° N ãšã€ããã®éçã®é·ããè¡šãæŽæ°
L ã,空çœãåºåããšããŠãã®é ã«æžãããŠãã.å
¥åã® i + 1 è¡ç® (1 ≤ i ≤ N) ã«
ã¯, i æ¬ç®ã®ã€ããã®æåã®é·ããè¡šãæŽæ° ai (1 ≤ ai < L) ãæžãããŠãã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 30% åã«ã€ããŠã¯,N ≤
500 ã〠L ≤
1000 ãæº
ãã.
</p>
<h2> åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
</p>
-->
<p>
<!--output.txt-->åºå ã¯,ãã¹ãŠã®ã€ãããæãããŸã§ã«ãããæéãè¡šã 1 ã€ã®æŽæ°ã®ã¿ãå«ã 1 è¡ãããªã.
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
4 6
4
2
3
5
</pre>
<h3>åºåäŸ 1</h3>
<pre>
8
</pre>
<p>
äŸ 1 ã®å Žå,1, 2, 3, 4 æ¬ç®ã®ã€ããã¯,ãããã 2, 8, 4, 1 æéåŸã«æãã.ãã
ãã£ãŠ,ãã¹ãŠã®ã€ãããæãããŸã§ã«ãããæé㯠8 æéã§ããã®ã§,8 ãåºå
ãã.
</p>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
6 10
3
4
1
9
5
1
</pre>
<h3>åºåäŸ 2</h3>
<pre>
15
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4 6\n4\n2\n3\n5\n",
"4 6\n4\n2\n3\n5\n"
]
] |
p00475 | Exposition |
<H1>å芧äŒ</H1>
<h2> åé¡</h2>
<p>
JOI åžã§ã¯,ãšãã倧èŠæš¡ãªå芧äŒãéå¬ããããšã«ãªã£ã.
</p>
<p>
ä»åã®å芧äŒã«ã¯ 2 ã€ã®ããŒãããã,JOI åžã«ãã N åã®å±ç€ºæœèšã§ãããã,
2 ã€ã®ããŒãã®ãã¡ã©ã¡ããäžæ¹ã«æ²¿ã£ãå±ç€ºãè¡ãäºå®ã§ãã.
</p>
<p>
æœèšã®äœçœ®ã¯å¹³é¢åº§æš (x, y) ã§è¡šããã.äœçœ® (x, y) ã«ããæœèšãã (xâ² , yâ²) ã«ããæœèšãŸã§ç§»åããããã«ã¯, |x â xâ²| + |y â yâ²| ã ãã®æéãããã (æŽæ° a ã«å¯ŸããŠ,
|a| 㧠a ã®çµ¶å¯Ÿå€ãè¡šã).åäžããŒãå
ã§ã®çµ±äžæãåºããã,ããã³äžæ¹ã®ããŒãã®ã¿ã«é¢å¿ãæã€äººã«äžäŸ¿ãæããããªãããã«,åäžã®ããŒãã§å±ç€ºãè¡ã£ãŠãã 2 ã€ã®æœèšã®éã®ç§»åæéããªãã¹ãçããªãããã«ããŒããå²ããµããã.ãã¹ãŠã®å±ç€ºæœèšã«åãããŒããå²ããµããªãéã, ã©ã®ããã«ããŒããå²ããµã£ãŠããã.
</p>
<p>
åäžã®ããŒãã§å±ç€ºãè¡ã£ãŠãã 2 ã€ã®æœèšã®éã®ç§»åæéã®æ倧å€ã M ãšãã. N åã®å±ç€ºæœèšã®äœçœ®ãäžãããããšã, M ã®æå°å€ãæ±ããããã°ã©ã ãäœæãã.
</p>
<h2>å
¥å</h2>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.
</p>
-->
<p>
å
¥åã® 1 è¡ç®ã«ã¯, æœèšã®åæ° N(3 ≤ N ≤ 100000 = 10<sup>5</sup> ) ãæžãããŠãã.å
¥åã®i + 1 è¡ç® (1 ≤ i ≤ N) ã«ã¯,åæœèšã®åº§æšãè¡šã 2 ã€ã®æŽæ° x<sub>i</sub>, y<sub>i</sub> (|x<sub>i</sub>| ≤ 100000 = 10<sup>5</sup>, |y<sub>i</sub>| ≤ 100000 = 10<sup>5</sup> ) ã空çœåºåãã§æžãããŠãã.ããã¯,i åç®ã®æœèšã®åº§æšã(x<sub>i</sub> , y<sub>i</sub>) ã§ããããšãè¡šã. åäžã®åº§æšã« 2 ã€ä»¥äžã®æœèšãååšããããšã¯ãªã.
</p>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 40% åã«ã€ããŠã¯, N ≤ 2000 ã§ãã.
</p>
<h2> åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
</p>
-->
<p>
åºå㯠1 è¡ã®ã¿ãããªã.åäžã®ããŒãã§å±ç€ºãè¡ã£ãŠãã 2 ã€ã®æœèšéã®ç§»åæéã®æå€§å€ M ã®æå°å€ãåºåãã.
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
5
0 0
1 0
-1 -2
0 1
-1 1</pre>
<h3>åºåäŸ 1</h3>
<pre>
3</pre>
<p>
ãã®å Žå,ããšãã°åº§æš (0, 0), (1, 0), (0, 1) ã«ããæœèšã«äžæ¹ã®ããŒãã,(â1, â2),
(â1, 1) ã«ããæœèšã«ããäžæ¹ã®ããŒããå²ããµããš,åäžã®ããŒãã§å±ç€ºãè¡ã 2
ã€ã®æœèšéã®ç§»åæéã¯ãã¹ãŠ 3 以äžã«ãªã.移åæéããã¹ãŠ 2 以äžã«ããããšã¯ã§ããªãã®ã§,3 ãåºåãã.
</p>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5\n0 0\n1 0\n-1 -2\n0 1\n-1 1\n",
"5\n0 0\n1 0\n-1 -2\n0 1\n-1 1\n"
]
] |
p00476 | Dungeon |
<H1>ãã³ãžã§ã³</H1>
<h2>åé¡</h2>
<p>
ããªãã¯ãããã³ãžã§ã³ã®å°äž N éã«ãã財å®ãæã«å
¥ããããšæã£ãŠãã.æå,ããªãã¯å°äž 1 éã«ãã,ããªãã®äœå㯠H(H ã¯æ£æŽæ°) ã§ãã.äžã®éã«éãããšãã«,äœåãæ¶è²»ããã.ãããããåéã«ãããäžã®éã«éãããšãã«æ¶è²»ãããäœåãåãã£ãŠãã.äžæ¹,åéã«ã¯ 1 ã€ã®å埩ã®æ³ããã,æ³ã 1 å䜿ãããšã«å埩ã§ããäœåãããããå®ãŸã£ãŠãã.äœåã 0 以äžã«ãªããšããªãã¯æ»ãã§ããŸã.ãŸã,äœåã H ãããé«ããªãããšã¯ãªã.å埩ã®æ³ã¯äœåã§ã䜿ãããšãã§ããã,å埩ã«ã¯æéããããã®ã§,ããªãã¯æ³ã®äœ¿çšåæ°ãã§ããã ãå°ãªãããããšèããŠãã.
</p>
<p>
N ,H ,åéã®äžã®éã«éãããšãã«æ¶è²»ãããäœå,ãããŠåéã§å埩ã®æ³ã 1 å䜿çšãããšãã«å埩ããäœåãäžãããããšã,äœåã 0 以äžã«ããããšãªãå°äž N éãŸã§å°éããããã«å¿
èŠãªæ³ã®äœ¿çšåæ°ã®æå°å€ãæ±ããããã°ã©ã ãäœæãã.
</p>
<p>
ãŸã,äžåºŠäžã®éã«éãããš,財å®ãæã«å
¥ãããŸã§äžã®éã«æ»ãããšã¯ã§ããªã.
</p>
<h2>å
¥å</h2>
<!--
<p>
å
¥åãã¡ã€ã«ã®ãã¡ã€ã«å㯠input.txt ã§ãã.
</p>
-->
<p>
å
¥å㯠N è¡ãããªã.
å
¥åã® 1 è¡ç®ã«ã¯ 2 ã€ã®æŽæ° N, H(2 ≤ N ≤ 100000 = 10<sup>5</sup>, 1 ≤
H ≤ 10000000 = 10<sup>7</sup> ) ã空çœãåºåããšããŠæžãããŠãã.N ã¯å°äž N éã«è²¡å®ããããšããããšãè¡šã,H ã¯åæäœå ( ãã³ãžã§ã³ã®å°äž 1 éã«å°çãã段éã®äœå ) ã§ãã,ãã€äœåã®æ倧å€ã§ãã ( å埩ã«ãã£ãŠäœåã H ãã倧ãããªãããšã¯ãªã ) .
</p>
<p>
ç¶ã N â 1 è¡ã«ã¯,2 ã€ã®æŽæ°ã空çœãåºåããšããŠæžãããŠãã.1 + i è¡ç®(1 ≤ i ≤ N â 1) ã®æŽæ° di , hi ã«ã€ããŠ, di ã¯å°äž i éããå°äž i + 1 éã«éããéã«æ¶è²»ãããäœåã,hi ã¯å°äž i éã§æ³ã 1 å䜿çšãããšãã«å埩ããäœåãè¡šã(0 ≤ di < H, 1 ≤ hi < H).
</p>
<p>
ã©ã®æ¡ç¹çšããŒã¿ã«ãããŠã,å°äž N éã«ãã©ãçãæ¹æ³ãååšãã.æ¡ç¹çšããŒã¿ã®ãã¡,é
ç¹ã® 10%åã«ã€ããŠã¯,N ≤
1000 ã〠H ≤
1000 ãæºãã.é
ç¹ã®30%åã«ã€ããŠã¯,N ≤1000 ãæºãã.é
ç¹ã® 50%åã«ã€ããŠã¯,æ³ã®äœ¿çšåæ°ã®æå°å€ã 10<sup>6</sup> ãè¶
ããªã.
</p>
<h2> åºå</h2>
<!--
<p>
åºåãã¡ã€ã«ã®ãã¡ã€ã«å㯠output.txt ã§ãã.
</p>
-->
<p>
<!--output.txt-->åºåã¯,äœåã 0 以äžã«ããããšãªãå°äž N éã«å°éããããã«å¿
èŠãª,æ³ã®äœ¿çšåæ°ã®æå°å€ãå«ã 1 è¡ãããªã.
</p>
<h2>泚æ</h2>
<p>
ãã®åé¡ã§ã¯,æ±ãæŽæ°ã®ç¯å²ã 32bit ã«åãŸããªãå¯èœæ§ãããããšã«æ³šæãã.
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
10 10
4 2
2 5
6 1
7 3
6 4
9 6
0 8
4 1
9 4
</pre>
<h3>åºåäŸ 1</h3>
<pre>
10
</pre>
<div class="source">
<p class="source">
äžèšåé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"10 10\n4 2\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4\n",
"10 10\n4 2\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4\n"
]
] |
p00477 | Total Time |
<H1>åèšæé (Total Time)</H1>
<h2>åé¡</h2>
<p>
倪éå㯠3 ã«æã®åºã蚪ããããšãæ¥èª²ã«ããŠããïŒå®¶ãåºçºãïŒæ±ºãŸã£ãé çªã§ 3 ã«æã®åºãåã£ãåŸïŒå®¶ã«åž°ãïŒãšãã©ãïŒã¹ããããŠã©ããã䜿ã£ãŠïŒååºéã移åããã®ã«äœç§ããã£ãããèšãïŒãã®ç§æ°ãèšé²ããïŒ
</p>
<p>
ããæ¥ã®èšæž¬çµæãäžãããããšãïŒãã®æ¥ã®ç§»åæéã®åèšãäœåäœç§ããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥å㯠4 è¡ãããªãïŒ 1 è¡ã« 1 ã€ãã€æ£ã®æŽæ°ãæžãããŠããïŒ<br>
1 è¡ç®ã®æŽæ°ã¯å®¶ãã 1 ã€ç®ã®åºãŸã§ã®ç§»åæéãè¡šãç§æ°ã§ããïŒ<br>
2 è¡ç®ã®æŽæ°ã¯ 1 ã€ç®ã®åºãã 2 ã€ç®ã®åºãŸã§ã®ç§»åæéãè¡šãç§æ°ã§ããïŒ<br>
3 è¡ç®ã®æŽæ°ã¯ 2 ã€ç®ã®åºãã 3 ã€ç®ã®åºãŸã§ã®ç§»åæéãè¡šãç§æ°ã§ããïŒ<br>
4 è¡ç®ã®æŽæ°ã¯ 3 ã€ç®ã®åºãã家ãŸã§ã®ç§»åæéãè¡šãç§æ°ã§ããïŒãã ãïŒäžããããå
¥åããŒã¿ã«ãããŠã¯åèšç§»åæé㯠1 å 0 ç§ä»¥äžã§ 59 å 59 ç§ä»¥äžã§ããããšãä¿èšŒãããŠããïŒ<br>
</p>
<h2>åºå</h2>
<p>
åºå㯠2 è¡ãããªãïŒx å y ç§ (1 ≤ x ≤ 59 , 0 ≤ y ≤ 59 )ã®ãšãïŒ 1è¡ç®ã« x ãïŒ2è¡ç®ã« y ãåºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
31
34
7
151
</pre>
<h3>åºåäŸ 1</h3>
<pre>
3
43
</pre>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
316
430
643
1253
</pre>
<h3>åºåäŸ 2</h3>
<pre>
44
2
</pre>
<br>
<h3>å
¥åäŸ 3</h3>
<pre>
5
10
15
30
</pre>
<h3>åºåäŸ 3</h3>
<pre>
1
0
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
<br>
| [
[
"31\n34\n7\n151\n",
"31\n34\n7\n151\n"
]
] |
p00478 | Ring |
<H1>æ茪 (Ring)</H1>
<h2>åé¡</h2>
<p>
ããªã㯠N åã®æ茪ãæã£ãŠããïŒã©ã®æ茪ã«ãïŒã¢ã«ãã¡ãããã®å€§æå 10 æåãããªãæååãå»å°ãããŠããïŒæ茪ã«ã¯æååã®æåãšæåŸãã€ãªãã£ã圢ã§æåãå»å°ãããŠããïŒæ茪ã«å»å°ãããæååãéé ã«èªãå¿é
ã¯ãªãïŒ
</p>
<p>
æ¢ãããæååãäžãããããšãïŒãã®æååãå«ãæ茪ãäœåããããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥å㯠2+N è¡ãããªãïŒ<br>
1 è¡ç®ã«ã¯ïŒ1 æåä»¥äž 10 æå以äžã®ã¢ã«ãã¡ãããã®å€§æåãããªãæ¢ãããæååãæžãããŠããïŒ<br>
2 è¡ç®ã«ã¯ïŒæ茪ã®åæ° N ( 1 ⊠N ⊠100 )ãæžãããŠããïŒ<br>
2+i è¡ç®(1 ≤ i ≤ N )ã«ã¯ïŒ i åç®ã®æ茪ã«å»å°ãããŠãã 10 æåãããªãæååãæžãããŠããïŒ
</p>
<h2>åºå</h2>
<p>
æ¢ãããæååãå«ãæ茪ã®åæ°ãè¡šãæŽæ°ã 1 è¡ã§åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
ABCD
3
ABCDXXXXXX
YYYYABCDXX
DCBAZZZZZZ
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
</pre>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
XYZ
1
ZAAAAAAAXY
</pre>
<h3>åºåäŸ 2</h3>
<pre>
1
</pre>
<p>
å
¥åäŸ 2 ã®æ茪ã«ã¯ãXYZããšããæååã 1 ã€å«ãŸããŠããïŒããã¯ãæ茪ã®æååã®æåãšæåŸãã€ãªãã£ãŠããããã§ããïŒ
</p>
<br>
<h3>å
¥åäŸ 3</h3>
<pre>
PQR
3
PQRAAAAPQR
BBPQRBBBBB
CCCCCCCCCC
</pre>
<h3>åºåäŸ 3</h3>
<pre>
2
</pre>
<p>
å
¥åäŸ 3 ã® 1 åç®ã®æ茪ã«ã¯ãPQRããšããæååã 2 ã€å«ãŸããŠããïŒ 2 åç®ã®æ茪ã«ã¯ãPQRããšããæååã 1 åå«ãŸããŠããïŒ 3 åç®ã®æ茪ã«ã¯ãPQRããšããæååãå«ãŸããŠããªãïŒãã®ãããPQRããšããæååãå«ãŸããŠããæ茪ã®æ°ã¯ 2 åãšãªãïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
<br> | [
[
"ABCD\n3\nABCDXXXXXX\nYYYYABCDXX\nDCBAZZZZZZ\n",
"ABCD\n3\nABCDXXXXXX\nYYYYABCDXX\nDCBAZZZZZZ\n"
]
] |
p00479 | Tile |
<H1>ã¿ã€ã« (Tile)</H1>
<h2>åé¡</h2>
<p>
JOI é«æ ¡ã§ã¯ïŒ 1 × 1 ã®æ£æ¹åœ¢ã®ã¿ã€ã«ã䜿ã£ãŠ N × N ã®æ£æ¹åœ¢ã®å£ç»ãäœãïŒæåç¥ã§å±ç€ºããããšã«ãªã£ãïŒã¿ã€ã«ã®è²ã¯ïŒèµ€ïŒéïŒé»ã® 3 çš®é¡ã§ããïŒå£ç»ã®ãã¶ã€ã³ã¯æ¬¡ã®éãã§ããïŒãŸãïŒæãå€åŽã®åšã«èµ€ã®ã¿ã€ã«ã貌ãïŒãã®å
åŽã®åšã«éã®ã¿ã€ã«ã貌ãïŒããã«ãã®å
åŽã®åšã«é»è²ã®ã¿ã€ã«ã貌ãïŒããã N × N ã®æ£æ¹åœ¢ãåãå°œãããããŸã§ç¹°ãè¿ãïŒçšããã¿ã€ã«ã®è²ã¯ïŒäžçªå€åŽã®åšããé çªã«èµ€ïŒéïŒé»ïŒèµ€ïŒéïŒé»ïŒâŠã§ããïŒ
</p>
<p>
æåç¥ãè¿ã¥ããŠããããæ¥ïŒå£ç»ã®ãã¡ K æã®ã¿ã€ã«ãã¯ãããŠããããšãå€æããïŒããã§ïŒæ°ããã¿ã€ã«ã賌å
¥ããŠïŒã¯ãããç®æã«æ°ããã¿ã€ã«ã貌ãããšã«ããïŒ
</p>
<p>
å
¥åãšããŠå£ç»ã®äžèŸºã®é·ã N ãšïŒã¯ãããã¿ã€ã«ã®ææ° KïŒ K æã®ã¯ãããã¿ã€ã«ã®äœçœ®ãäžãããããšãïŒã¯ãããã¿ã€ã«ã®è²ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<p>
äŸãã°ïŒN = 11 ã®å ŽåïŒ11 × 11 ã®å£ç»ã®ãã¶ã€ã³ã¯äžå³ã®éãã§ããïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0556_1">
<p>
ãŸãïŒN = 16 ã®å ŽåïŒ16 × 16 ã®å£ç»ã®ãã¶ã€ã³ã¯äžå³ã®éãã§ããïŒ
</p>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0556_2">
<br>
<h2>å
¥å</h2>
<p>
å
¥åã¯å
šéšã§ 2+K è¡ãããªãïŒ 1 è¡ç®ã«ã¯ïŒå£ç»ã®äžèŸºã®é·ã N ïŒ1 ≤ N ≤ 1000000000 = 10<sup>9</sup>ïŒãïŒ 2 è¡ç®ã«ã¯ïŒã¯ãããã¿ã€ã«ã®ææ° K ïŒ1 ≤ K ≤ 1000ïŒãæžãããŠããïŒ 2+i è¡ç®ïŒ1 ≤ i ≤ KïŒã«ã¯ïŒ2 ã€ã®æŽæ° ai ãš bi ïŒ1 ≤ ai ≤ N, 1 ≤ bi ≤ NïŒã空çœåºåãã§æžãããŠããïŒ i æç®ã®ã¯ãããã¿ã€ã«ãïŒå·Šãã ai åç®ïŒäžãã bi è¡ç®ã®ã¿ã€ã«ã§ããããšãè¡šãïŒ
</p>
<p>
å
¥åã® 3 è¡ç®ãã 2+K è¡ç®ã«ã¯åãã¿ã€ã«ãè¡šãè¡ãéè€ããŠçŸããããšã¯ãªãïŒãŸãïŒäžããããå
¥åããŒã¿ 40% ã§ã¯ïŒ N ≤ 1000 ãã¿ãããŠããïŒ
</p>
<h2>åºå</h2>
<p>
åºå㯠K è¡ãããªãïŒåè¡ã¯ 1 ã€ã®æŽæ°ãããªãïŒ i è¡ç®ïŒ1 ≤ i ≤KïŒã®æŽæ°ã¯ïŒi æç®ã®ã¯ãããã¿ã€ã«ãèµ€ã®ãšã㯠1 ãïŒéã®ãšã㯠2 ãïŒé»è²ã®ãšã㯠3 ãè¡šãïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
11
4
5 2
9 7
4 4
3 9
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
3
1
3
</pre>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
16
7
3 7
5 2
11 6
15 2
9 7
8 12
15 16
</pre>
<h3>åºåäŸ 2</h3>
<pre>
3
2
3
2
1
2
1
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
<br>
| [
[
"11\n4\n5 2\n9 7\n4 4\n3 9\n",
"11\n4\n5 2\n9 7\n4 4\n3 9\n"
]
] |
p00480 | A First Grader |
<H1>1幎ç (A First Grader)</H1>
<h2>åé¡</h2>
<p>
JOIåã¯å°åŠ 1 幎çã§ããïŒJOIåã¯æãã£ãã°ããã®è¶³ãç®ïŒåŒãç®ããšãŠã奜ãã§ïŒæ°åã䞊ãã§ããã®ãèŠããšæåŸã® 2 ã€ã®æ°åã®éã«ã=ããå
¥ãïŒæ®ãã®æ°åã®éã«å¿
ãã+ããŸãã¯ã-ããå
¥ããŠçåŒãäœã£ãŠéãã§ããïŒäŸãã°ã8 3 2 4 8 7 2 4 0 8 8ãããïŒçåŒã8+3-2-4+8-7-2-4-0+8=8ããäœãããšãã§ããïŒ
</p>
<p>
JOI åã¯çåŒãäœã£ãåŸïŒãããæ£ããçåŒã«ãªã£ãŠããããèšç®ããŠç¢ºãããïŒãã ãïŒJOIåã¯ãŸã è² ã®æ°ã¯ç¥ããªããïŒ20 ãè¶
ããæ°ã®èšç®ã¯ã§ããªãïŒãããã£ãŠïŒæ£ããçåŒã®ãã¡å·ŠèŸºãå·Šããèšç®ãããšãèšç®ã®éäžã§çŸããæ°ãå
šãŠ 0 ä»¥äž 20 以äžã®çåŒã ããJOIåã確ãããããæ£ããçåŒã§ããïŒäŸãã°ïŒã8+3-2-4-8-7+2+4+0+8=8ã㯠æ£ããçåŒã ãïŒéäžã«çŸãã 8+3-2-4-8 ãè² ã®æ°ãªã®ã§JOIåã¯ãã®çåŒãæ£ãããã©ãã確ãããããšãã§ããªãïŒ
</p>
<p>
å
¥åãšããŠæ°åã®åãäžãããããšãïŒJOIåãäœãïŒç¢ºãããããšãã§ããæ£ããçåŒã®åæ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥åãã¡ã€ã«ã¯ 2 è¡ãããªãïŒ1 è¡ç®ã«ã¯äžŠãã§ããæ°åã®åæ°ãè¡šãæŽæ° N ïŒ3 ≤ N ≤ 100ïŒãæžãããŠããïŒ2 è¡ç®ã«ã¯ 0 ä»¥äž 9 以äžã®æŽæ°ã N åïŒç©ºçœãåºåããšããŠæžãããŠããïŒ
</p>
<p>
äžããããå
¥åããŒã¿ã® 60% ã§ã¯ïŒJOIåãäœãïŒç¢ºãããããšãã§ããæ£ããçåŒã®åæ°ã¯ 2<sup>31</sup>-1 ãè¶
ããªãïŒãŸãïŒäžããããå
¥åããŒã¿ã®å
šãŠã«ãããŠïŒJOIåãäœãïŒç¢ºãããããšãã§ããæ£ããçåŒã®åæ°ã¯ 2<sup>63</sup>-1 ãè¶
ããªãïŒ
</p>
<h2>åºå</h2>
<p>
JOIåãäœãïŒç¢ºãããããšãã§ããæ£ããçåŒã®åæ°ãè¡šãæŽæ°ã 1 è¡ã§åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
11
8 3 2 4 8 7 2 4 0 8 8
</pre>
<h3>åºåäŸ 1</h3>
<pre>
10
</pre>
<p>
å
¥åäŸ 1 ã«ãããŠïŒJOIå㯠10 åã®æ£ããçåŒ
</p>
<pre>
8+3-2-4+8-7-2-4-0+8=8
8+3-2-4+8-7-2-4+0+8=8
8+3+2+4-8-7+2-4-0+8=8
8+3+2+4-8-7+2-4+0+8=8
8+3-2-4+8-7+2+4-0-8=8
8+3-2-4+8-7+2+4+0-8=8
8-3+2+4-8+7+2+4-0-8=8
8-3+2+4-8+7+2+4+0-8=8
8-3+2-4+8+7+2-4-0-8=8
8-3+2-4+8+7+2-4+0-8=8
</pre>
<p>
ãäœãïŒç¢ºãããããšãã§ããã®ã§ 10 ãåºåããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1
</pre>
<h3>åºåäŸ 2</h3>
<pre>
7069052760
</pre>
<p>
å
¥åäŸ 2 ã«ãããŠïŒçãã 32 bit笊å·ä»ãæŽæ°ã®ç¯å²ã«åãŸããªãããšã«æ³šæããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
<br> | [
[
"11\n8 3 2 4 8 7 2 4 0 8 8\n",
"11\n8 3 2 4 8 7 2 4 0 8 8\n"
]
] |
p00481 | Cheese |
<H1>ããŒãº (Cheese)</H1>
<h2>åé¡</h2>
<p>
ä»å¹Žã JOI çºã®ããŒãºå·¥å ŽãããŒãºã®çç£ãå§ãïŒããã¿ãå·£ããé¡ãåºããïŒJOI çºã¯æ±è¥¿ååã«åºç»æŽçãããŠããŠïŒååºç»ã¯å·£ïŒããŒãºå·¥å ŽïŒé害ç©ïŒç©ºãå°ã®ããããã§ããïŒããã¿ã¯å·£ããåºçºããŠå
šãŠã®ããŒãºå·¥å Žã蚪ãããŒãºã 1 åãã€é£ã¹ãïŒ
</p>
<p>
ãã®çºã«ã¯ïŒN åã®ããŒãºå·¥å ŽãããïŒã©ã®å·¥å ŽãïŒçš®é¡ã®ããŒãºã ããçç£ããŠããïŒããŒãºã®ç¡¬ãã¯å·¥å Žã«ãã£ãŠç°ãªã£ãŠããïŒç¡¬ã 1 ãã N ãŸã§ã®ããŒãºãçç£ããããŒãºå·¥å Žãã¡ããã© 1 ã€ãã€ããïŒ
</p>
<p>
ããã¿ã®æåã®äœå㯠1 ã§ããïŒããŒãºã 1 åé£ã¹ãããšã«äœåã 1 å¢ããïŒãã ãïŒããã¿ã¯èªåã®äœåããã硬ãããŒãºãé£ã¹ãããšã¯ã§ããªãïŒ
</p>
<p>
ããã¿ã¯ïŒæ±è¥¿ååã«é£ãåãåºç»ã« 1 åã§ç§»åããããšãã§ãããïŒé害ç©ã®åºç»ã«ã¯å
¥ãããšãã§ããªãïŒããŒãºå·¥å ŽãããŒãºãé£ã¹ãã«éãéããããšãã§ããïŒãã¹ãŠã®ããŒãºãé£ã¹çµãããŸã§ã«ãããæçæéãæ±ããããã°ã©ã ãæžãïŒãã ãïŒããã¿ãããŒãºãé£ã¹ãã®ã«ãããæéã¯ç¡èŠã§ããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥å㯠H+1 è¡ããïŒ1 è¡ç®ã«ã¯ 3 ã€ã®æŽæ° HïŒWïŒN (1 ≤ H ≤ 1000ïŒ1 ≤ W ≤ 1000ïŒ1 ≤ N ≤ 9) ããã®é ã«ç©ºçœã§åºåãããŠæžãããŠããïŒ2 è¡ç®ãã H+1 è¡ç®ãŸã§ã®åè¡ã«ã¯ïŒ'S'ïŒ'1', '2', ..., '9'ïŒ'X'ïŒ'.' ãããªã W æåã®æååãæžãããŠããïŒåã
ãååºç»ã®ç¶æ
ãè¡šããŠããïŒåãã i çªç®ïŒè¥¿ãã j çªç®ã®åºç»ã (i,j) ãšèšè¿°ããããšã«ãããš (1 ≤ i ≤ H, 1 ≤ j ≤ W)ïŒç¬¬ i+1 è¡ç®ã® j çªç®ã®æåã¯ïŒåºç» (i,j) ãå·£ã§ããå Žå㯠'S' ãšãªãïŒé害ç©ã§ããå Žå㯠'X' ãšãªãïŒç©ºãå°ã§ããå Žå㯠'.' ãšãªãïŒç¡¬ã 1, 2, ..., 9 ã®ããŒãºãçç£ããå·¥å Žã§ããå Žåã¯ãããã '1', '2', ..., '9' ãšãªãïŒå
¥åã«ã¯å·£ãšç¡¬ã 1, 2, ..., N ã®ããŒãºãçç£ããå·¥å Žããããã 1 ã€ãã€ããïŒä»ã®ãã¹ã¯é害ç©ãŸãã¯ç©ºãå°ã§ããããšãä¿èšŒãããŠããïŒããã¿ã¯å
šãŠã®ããŒãºãé£ã¹ãããããšãä¿èšŒãããŠããïŒ
</p>
<h2>åºå</h2>
<p>
ãã¹ãŠã®ããŒãºãé£ã¹çµãããŸã§ã«ãããæçæéïŒåïŒãè¡šãæŽæ°ã 1 è¡ã§åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
3 3 1
S..
...
..1
</pre>
<h3>åºåäŸ 1</h3>
<pre>
4
</pre>
<h3>å
¥åäŸ 2</h3>
<pre>
4 5 2
.X..1
....X
.XX.S
.2.X.
</pre>
<h3>åºåäŸ 2</h3>
<pre>
12
</pre>
<h3>å
¥åäŸ 3</h3>
<pre>
10 10 9
.X...X.S.X
6..5X..X1X
...XXXX..X
X..9X...X.
8.X2X..X3X
...XX.X4..
XX....7X..
X..X..XX..
X...X.XX..
..X.......
</pre>
<h3>åºåäŸ 3</h3>
<pre>
91
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
<br> | [
[
"3 3 1\nS..\n...\n..1\n",
"3 3 1\nS..\n...\n..1\n"
]
] |
p00482 | JOI Flag |
<H1>JOI æ (JOI Flag)</H1>
<h2>åé¡</h2>
<p>
æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒã§ã¯ïŒä»å¹Žã®æ¥æ¬æ
å ±ãªãªã³ãã㯠(JOI) ã宣äŒããããã«ïŒ JOI ã®ããŽãã¢ããŒãã«ããæãäœãããšã«ãªã£ãïŒæã¯ãè¯ãæãã§ãªããã°ãªããªãïŒãè¯ãæããšã¯ïŒã¢ã«ãã¡ãããã® J, O, I ã®ããããã®æåãïŒçžŠ M è¡ïŒæšª N åã®é·æ¹åœ¢ç¶ã«äžŠã¹ããã®ã§ïŒ J, O, I ã以äžã®å³ã®ããã« (ããªãã¡ïŒJ ã®å³é£ã« O ãïŒãã® J ã®äžé£ã« I ã) 䞊ãã§ããç®æãæã®å°ãªããšã 1 ãæã«ãããã®ã§ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0559_1">
</center>
<p>
以äžã®å³ã«ïŒãè¯ãæãã®äŸã 2 ã€ç€ºãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0559_2">
</center>
<p>
以äžã®å³ã«ïŒãè¯ãæãã§ã¯ãªãäŸã 2 ã€ç€ºãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0559_3">
</center>
<p>
ã㟠M, N ã®å€ïŒããã³æã®äžéšã®å Žæã«ã€ã㊠J, O, I ã®ã©ã®æåã«ãããã決ãŸã£ãŠããïŒå
¥åãšããŠãã®æ
å ±ãäžããããïŒèãããããè¯ãæãã¯äœéãããããèšç®ãïŒãã®æ°ã 100000 (=10<sup>5</sup>) ã§å²ã£ãäœããåºåããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥å㯠1 + M è¡ãããªãïŒ
</p>
<p>
1 è¡ç®ã«ã¯æã®å€§ãããè¡šã 2 ã€ã®æŽæ° M, N (2 ≤ M ≤ 20, 2 ≤ N ≤ 20) ã空çœã§åºåãããŠæžãããŠããïŒ
</p>
<p>
1 + i è¡ç® (1 ≤ i ≤ M) ã«ã¯ïŒN æåãããªãæååãæžãããŠããïŒåæå㯠J, O, I, ? ã®ããããã§ããïŒ j æåç® (1 ≤ j ≤ N) ã J, O, I ã®ããããã§ããå Žå㯠i è¡ j åã®å Žæã®æåããããã J, O, I ã«æ±ºãŸã£ãŠããããšïŒ ? ã§ããå Žåã¯ãŸã 決ãŸã£ãŠããªãããšãè¡šãïŒ
</p>
<h2>åºå</h2>
<p>
èãããããè¯ãæãã®åæ°ã 100000 (=10<sup>5</sup>) ã§å²ã£ãäœãã 1 è¡ã§åºåããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
2 3
??O
IIJ
</pre>
<h3>åºåäŸ 1</h3>
<pre>
4
</pre>
<p>
å
¥åäŸ 1 ã«ãããŠã¯ïŒä»¥äžã®å³ã® 4 éãã®ãè¯ãæããèããããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_0559_4">
</center>
<h3>å
¥åäŸ 2</h3>
<pre>
2 2
??
??
</pre>
<h3>åºåäŸ 2</h3>
<pre>
3
</pre>
<br>
<h3>å
¥åäŸ 3</h3>
<pre>
3 3
??I
???
O?J
</pre>
<h3>åºåäŸ 3</h3>
<pre>
53
</pre>
<br>
<h3>å
¥åäŸ 4</h3>
<pre>
5 4
JOI?
????
????
????
?JOI
</pre>
<h3>åºåäŸ 4</h3>
<pre>
28218
</pre>
<p>
å
¥åäŸ 4 ã«ãããŠã¯ïŒãè¯ãæã㯠2428218 éãèããããã®ã§ïŒããã 100000 (=10<sup>5</sup>) ã§å²ã£ãäœãã§ãã 28218 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"2 3\n??O\nIIJ\n",
"2 3\n??O\nIIJ\n"
]
] |
p00483 | Planetary Exploration |
<H1> æææ¢æ»(Planetary Exploration) </H1>
<p>
ããªããä¹ããè¶
æ空移æ°è¹ã¯é·æ
ã®æ«ïŒã€ãã«å±
äœå¯èœãšæãããææãçºèŠããïŒJOI æãšåä»ãããããã®ææã¯ïŒãã®åã®éãããžã£ã³ã°ã«(Jungle)ãïŒãæµ·(Ocean)ãïŒãæ°·(Ice)ãã®3 çš®é¡ã®å°åœ¢ãå
¥ãçµãã éé
·ãªææã§ããïŒç°¡åãªèª¿æ»ã«ããïŒå±
äœäºå®å°è¿èŸºã®å°å³ãäœæãããïŒå±
äœäºå®å°ã¯åå<i>M</i> km, æ±è¥¿<i>N</i> km ã®é·æ¹åœ¢ã®åœ¢ãããŠããïŒ 1 km åæ¹ã®æ£æ¹åœ¢ã®åºç»ã«åããããŠããïŒåºç»ã¯å
šéšã§<i>MN</i> åããïŒåãã<i>p</i> è¡ç®ïŒè¥¿ãã<i>q</i> åç®ã®åºç»ã(<i>p</i>, <i>q</i>) ã§è¡šãïŒå西ã®è§ã®åºç»ã(1, 1) ã§ããïŒåæ±ã®è§ã®åºç»ã(<i>M</i>, <i>N</i>) ã§ããïŒååºç»ã®å°åœ¢ã¯ïŒããžã£ã³ã°ã«ãïŒãæµ·ãïŒãæ°·ãã®ããããã§ããïŒããžã£ã³ã°ã«ãã¯J, ãæµ·ãã¯O, ãæ°·ãã¯I ã®è±å1 æåã§è¡šããã.
</p>
<p>
ããŠïŒè©³çŽ°ãªç§»äœèšç»ãç«ãŠãã«ãããïŒ K ç®æã®é·æ¹åœ¢é åå
ã«ããžã£ã³ã°ã«ãïŒãæµ·ãïŒãæ°·ããããããäœåºç»å«ãŸãããã調ã¹ãããšã«ããïŒ
</p>
<h2>課é¡</h2>
<p>
å±
äœäºå®å°ã®æ
å ±ãšïŒèª¿æ»å¯Ÿè±¡ãšãªãé åã®æ
å ±ãäžãããããšãïŒããããã®é åã«ã€ããŠïŒ ããžã£ã³ã°ã«ãïŒãæµ·ãïŒãæ°·ããäœåºç»å«ãŸããŠããããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>M</i> ≤ 1000 å±
äœäºå®å°ã®ååã®é·ã(km)<br>
1 ≤ <i>N</i> ≤ 1000 å±
äœäºå®å°ã®æ±è¥¿ã®é·ã(km)<br>
1 ≤ <i>K</i> ≤ 100000 調æ»å¯Ÿè±¡ãšãªãé åã®åæ°
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>M</i>, <i>N</i> ã空çœãåºåããšããŠæžãããŠããïŒå±
äœäºå®å°ãååã«<i>M</i> km ïŒæ±è¥¿ã«<i>N</i> km ã®åºãã§ããããšãè¡šãïŒ</li>
<li> 2 è¡ç®ã«ã¯æŽæ°<i>K</i> ãæžãããŠããïŒèª¿æ»å¯Ÿè±¡ãšãªãé åã®åæ°ãè¡šãïŒ</li>
<li> ç¶ã<i>M</i> è¡ã«ã¯å±
äœäºå®å°ã®æ
å ±ãæžãããŠããïŒ<i>i</i> + 2 è¡ç®(1 ≤ <i>i</I> ≤ <i>M</i>) ã«ã¯ïŒå±
äœäºå®å°ã®åãã<i>i</i>è¡ç®ã«äœçœ®ãã<i>N</i> åºç»ã®æ
å ±ãè¡šãJïŒOïŒI ãããªã<i>N</i> æåã®æååãæžãããŠããïŒ</li>
<li> ç¶ã<i>K</i> è¡ã«ã¯èª¿æ»å¯Ÿè±¡ãšãªãé åãæžãããŠããïŒ<i>j</i> + <i>M</i> + 2 è¡ç®(1 ≤ <i>j</i> ≤ <i>K</i>) ã«ã¯ïŒ <i>j</i> çªç®ã®é åãè¡šãæ£æŽæ°<i>a<sub>j</sub></i>, <i>b<sub>j</sub></i>, <i>c<sub>j</sub></i>, <i>d<sub>j</sub></i> ã空çœãåºåããšããŠæžãããŠããïŒ(<i>a<sub>j</sub></i>, <i>b<sub>j</sub></i>) ã¯èª¿æ»é åã®å西ã®è§ã®åºç»ãïŒ(<i>c<sub>j</sub></i>, <i>d<sub>j</sub></i>) ã¯èª¿æ»é åã®åæ±ã®è§ã®åºç»ãè¡šãïŒãã ãïŒ<i>a<sub>j</sub></i>, <i>b<sub>j</sub></i>, <i>c<sub>j</sub></i>, <i>d<sub>j</sub></i> ã¯ïŒ1 ≤ <i>a<sub>j</sub></i> ≤ <i>c<sub>j</sub></i> ≤ <i>M</i>, 1 ≤ <i>b<sub>j</sub></i> ≤ <i>d<sub>j</sub></i> ≤ <i>N</i>ãæºããïŒ
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«èª¿æ»ã®çµæãè¡šã<i>K</i> è¡ãåºåããïŒåºåã®<i>j</i> è¡ç®ã«ã¯ïŒ j çªç®ã®èª¿æ»é åã«å«ãŸããããžã£ã³ã°ã«ã(J) ã®åºç»æ°ïŒãæµ·ã(O) ã®åºç»æ°ïŒãæ°·ã(I) ã®åºç»æ°ãè¡šã3 ã€ã®æŽæ°ãïŒãã®é ã«ç©ºçœãåºåããšããŠæžãïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®30%åã«ã€ããŠã¯ïŒ<i>M</i> ≤ 50 ãã€<i>K</i> ≤ 100 ãæºããïŒé
ç¹ã®50%åã«ã€ããŠã¯ïŒ<i>M</i> ≤ 50 ãæºããïŒ
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
4 7
4
JIOJOIJ
IOJOIJO
JOIJOOI
OOJJIJO
3 5 4 7
2 2 3 6
2 2 2 2
1 1 4 7
</pre>
<h3>åºåäŸ</h3>
<pre>
1 3 2
3 5 2
0 1 0
10 11 7
</pre>
<br>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_planetaryExploration">
<br>
<p>
ãã®å
¥åäŸã§ã¯ïŒ 2 çªç®ã®é åã¯äžå³ã®ããã«ããžã£ã³ã°ã«ãã3 åºç»ïŒãæµ·ãã5 åºç»ïŒãæ°·ãã2 åºç»å«ãïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4 7\n4\nJIOJOIJ\nIOJOIJO\nJOIJOOI\nOOJJIJO\n3 5 4 7\n2 2 3 6\n2 2 2 2\n1 1 4 7\n",
"4 7\n4\nJIOJOIJ\nIOJOIJO\nJOIJOOI\nOOJJIJO\n3 5 4 7\n2 2 3 6\n2 2 2 2\n1 1 4 7\n"
]
] |
p00484 | Books |
<H1>å€æ¬å±(Books) </H1>
<p>
ããªãã®çºã«ã¯JOI å€æ¬åºãšããèèã®å€æ¬å±ãããïŒããªãã¯JOI å€æ¬åºãããå©çšããŠããïŒããããã®æ¬ã«ã¯åºæºäŸ¡æ Œãå®ãŸã£ãŠããïŒJOI å€æ¬åºã«è¡ãã°ãã®äŸ¡æ Œã§è²·ãåã£ãŠããããïŒ
</p>
<p>
JOI å€æ¬åºã§ã¯ïŒæ¬ãå°èª¬,挫ç»,éèªãªã©10 çš®é¡ã®ãžã£ã³ã«ã«åé¡ããŠæ±ã£ãŠããïŒãžã£ã³ã«ã«ã¯1ãã10 ãŸã§ã®çªå·ãä»ããããŠããïŒJOI å€æ¬åºã«ã¯ïŒåããžã£ã³ã«ã®æ¬ããŸãšããŠè²·ãåã£ãŠããããšé«å€ã§è²·ãåã£ãŠããããšãããµãŒãã¹ãããïŒå
·äœçã«ã¯ïŒåããžã£ã³ã«ã®æ¬ããŸãšããŠT åè²·ãåã£ãŠãããå ŽåïŒãã®ãžã£ã³ã«ã®æ¬ã®äžåãããã®è²·åäŸ¡æ ŒãåºæºäŸ¡æ ŒããT - 1 åé«ããªãïŒäŸãã°ïŒåããžã£ã³ã«ã§åºæºäŸ¡æ Œ100 åïŒ120 åïŒ150 åã®æ¬ããŸãšããŠJOI å€æ¬åºã«å£²ã£ããšãããšïŒè²·åäŸ¡æ Œã¯ãããã102 åïŒ122 åïŒ152 åãšãªãïŒ
</p>
<p>
ããŠïŒããªãã¯äžèº«äžã®éœåã§æ¥éœåŒè¶ããããããšã«ãªã£ãïŒããªãã¯N åã®æ¬ãæã£ãŠãããïŒæ°ããäœå±
ã«ãã¹ãŠã®æ¬ãæã£ãŠããããšã¯å°é£ãªããïŒ<i>N</i> åã®æ¬ã®ãã¡<i>K</i> åãJOI å€æ¬åºã«å£²ãããšã«ããïŒ
</p>
<h2>課é¡</h2>
<p>
<i>N</i> åã®æ¬ããããã®åºæºäŸ¡æ Œãšãžã£ã³ã«ã®çªå·ãäžãããããšãïŒåèšè²·åäŸ¡æ Œã®æ倧å€ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
2 ≤ <i>N</i> ≤ 2000 ããªããæã£ãŠããæ¬ã®åæ°<br>
1 ≤ <i>K</i> < <i>N</i> JOI å€æ¬åºã«å£²ãæ¬ã®åæ°<br>
1 ≤ <i>C<sub>i</sub></i> ≤ 100000 = 10<sup>5</sup> <i>i</i> çªç®ã®æ¬ã®åºæºäŸ¡æ Œ<br>
1 ≤ <i>G<sub>i</sub></i> ≤ 10 <i>i</i> çªç®ã®æ¬ã®ãžã£ã³ã«ã®çªå·
</ul>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>N</i>, <i>K</i> ã空çœãåºåããšããŠæžãããŠããïŒããªãã®æã£ãŠããæ¬ã®åæ°ã<i>N</i> ã§ïŒãã®ãã¡<i>K</i> åãJOI å€æ¬åºã«å£²ãããšãè¡šãïŒ
</li>
<li> ç¶ã<i>N</i> è¡ã«ã¯ããªãã®æã£ãŠããæ¬ã®æ
å ±ãæžãããŠããïŒ<i>i</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>N</i>) ã«ã¯ïŒæŽæ°<i>C<sub>i</sub></i>,<i>G<sub>i</sub></i>ã空çœãåºåããšããŠæžãããŠããïŒ<i>i</i> çªç®ã®æ¬ã®åºæºäŸ¡æ Œã<i>C<sub>i</sub></i> ã§ïŒãžã£ã³ã«ã®çªå·ã<i>G<sub>i</sub></i> ã§ããããšãè¡šãïŒ</li>
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒåèšè²·åäŸ¡æ Œã®æ倧å€ãè¡šãæŽæ°ã1 è¡ã§åºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒ<br>
é
ç¹ã®20% åã«ã€ããŠã¯ïŒ<i>N</i> ≤ 20 ãæºããïŒ<br>
é
ç¹ã®20% åã«ã€ããŠã¯ïŒãã¹ãŠã®æ¬ã®ãžã£ã³ã«ã¯1 ãŸãã¯2 ã§ããïŒ<br>
é
ç¹ã®10% åã«ã€ããŠã¯ïŒããã2 ã€ã®æ¡ä»¶ã®äž¡æ¹ãæºããïŒ<br>
é
ç¹ã®30% åã«ã€ããŠã¯ïŒããã2 ã€ã®æ¡ä»¶ã®å°ãªããšãäžæ¹ãæºããïŒ<br>
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
7 4
14 1
13 2
12 3
14 2
8 2
16 3
11 2
</pre>
<h3>åºåäŸ</h3>
<pre>
60
</pre>
<p>
ãã®å
¥åäŸã§ã¯ïŒ2 çªç®ïŒ4 çªç®ïŒ6 çªç®ïŒ7 çªç®ã®4 åã®æ¬ã売ã£ããšãïŒãžã£ã³ã«2 ã®æ¬ã®è²·åäŸ¡æ Œã1 åããã2 åé«ããªãã®ã§ïŒãããã®æ¬ã®è²·åäŸ¡æ Œã¯ä»¥äžã®ããã«ãªãïŒ
</p>
<table style="margin-left: 50px; margin-right: 50px;">
<tr>
<th width="100" align="left">çªå·</th>
<th width="100" align="left">åºæºäŸ¡æ Œ</th>
<th width="100" align="left">ãžã£ã³ã«</th>
<th width="100" align="left">è²·åäŸ¡æ Œ</th>
</tr>
<tr>
<td>
<pre>
2
4
6
7
</pre>
</td>
<td>
<pre>
13
14
16
11
</pre>
</td>
<td>
<pre>
2
2
3
2
</pre>
</td>
<td>
<pre>
15
16
16
13
</pre>
</td>
</tr>
</table>
<p>
ãã£ãŠåèšè²·åäŸ¡æ Œã¯15 + 16 + 16 + 13 = 60 åã§ããïŒãã®ãšãåèšè²·åäŸ¡æ Œã¯æ倧ãšãªãïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"7 4\n14 1\n13 2\n12 3\n14 2\n8 2\n16 3\n11 2\n",
"7 4\n14 1\n13 2\n12 3\n14 2\n8 2\n16 3\n11 2\n"
]
] |
p00485 | Shopping in JOI Kingdom |
<H1> JOI åœã®è²·ãç©äºæ
(Shopping in JOI Kingdom) </H1>
<p>
JOI åœã«ã¯<i>N</i> åã®çºãããïŒãããã®éã¯<i>M</i> æ¬ã®åæ¹åã«éè¡å¯èœãªéè·¯ã§çµã°ããŠããïŒ<i>K</i> åã®çºã«ã¯ã·ã§ããã³ã°ã¢ãŒã«ãããïŒåœæ°ã¯éè·¯ãéã£ãŠãããã®çºã®ããããã«è¡ãè²·ãç©ãããïŒ
</p>
<p>
家ã®å Žæã«ãã£ãŠã¯ïŒè²·ãç©ã«è¡ãããã«é·ãè·é¢ã移åããå¿
èŠãããïŒããã¯éåžžã«äžäŸ¿ã§ããïŒåœçã¯ãã®å®æ
ãææ¡ããããïŒã·ã§ããã³ã°ã¢ãŒã«ã®ããçºãŸã§ã®æçè·é¢ã家ã®å Žæã«ãã£ãŠã©ãã ãé·ããªãããã®ãã調ã¹ãããšã«ããïŒå®¶ã¯éè·¯ã®éäžã«å»ºãŠãããããšãããã®ã§(å
¥åäŸ1 ã®èª¬æãåç
§)ïŒãã®èª¿æ»ã¯éåžžã«å€§å€ã§ããïŒããã§åœçã¯ïŒåªç§ãªããã°ã©ããŒã§ããããªãã«ïŒèª¿æ»ãè¡ãããã°ã©ã ã®äœæãäŸé ŒããïŒ
</p>
<h2>課é¡</h2>
<p>
éè·¯ã®æ
å ±ãšã·ã§ããã³ã°ã¢ãŒã«ã®ããçºã®æ
å ±ãäžãããããšãïŒã·ã§ããã³ã°ã¢ãŒã«ã®ããçºãããã£ãšãé ãéè·¯äžã®ç¹(端ç¹ãå«ã) ãŸã§ã®è·é¢ãæ±ããããã°ã©ã ãäœæããïŒçºã®äžã移åããã®ã«ãããè·é¢ã¯ç¡èŠããŠããïŒ
</p>
<h2>å¶é</h2>
<p>
2 ≤ <i>N</i> ≤ 3000 JOI åœã®çºã®åæ°<br>
1 ≤ <i>M</i> ≤ 100000 = 10<sup>5</sup> JOI åœã®éè·¯ã®æ¬æ°<br>
1 ≤ <i>K</i> ≤ <i>N</i> ã·ã§ããã³ã°ã¢ãŒã«ãããçºã®åæ°<br>
1 ≤ <i>l<sub>i</sub></i> ≤ 1000 <i>i</i> çªç®ã®éè·¯ã®é·ã<br>
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>N</i>, <i>M</i>, <i>K</i> ã空çœåºåãã§æžãããŠããïŒ<i>N</i> ã¯JOI åœã®çºã®åæ°ãïŒ<i>M</i> ã¯JOI åœã®éè·¯ã®æ¬æ°ãïŒi>K</i> ã¯ã·ã§ããã³ã°ã¢ãŒã«ãããçºã®åæ°ãããããè¡šãïŒçºã«ã¯1, 2, ..., <i>N</i> ã®çªå·ãã€ããããŠããïŒ
</li>
<li> ç¶ã<i>M</i> è¡ã¯éè·¯ã®æ
å ±ãè¡šãïŒ<i>i</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>M</i>) ã«ã¯æŽæ°<i>a<sub>i</sub></i>, <i>b<sub>i</sub></i>, <i>l<sub>i</sub></i> (1 ≤ <i>a<sub>i</sub></i> ≤ <i>N</i>, 1 ≤ <i>b<sub>i</sub></i> ≤ <i>N</i>, 1 ≤ <i>l<sub>i</sub></i> ≤ 1000) ã空çœåºåãã§æžãããŠããïŒããã¯ïŒ<i>i</i> æ¬ç®ã®éè·¯ãçº<i>a<sub>i</sub></i> ãšçº<i>b<sub>i</sub></i> ãçµãã§ããïŒé·ãã<i>l<sub>i</sub></i> ã§ããããšãè¡šãïŒéè·¯ã®äž¡ç«¯ãåãçºã§ããããšã¯ãªãïŒãŸãïŒä»»æã®2 ã€ã®çº<i>p</i>, <i>q</i> ã«å¯ŸãïŒ<i>p</i>ãš<i>q</i> ãçµã¶éè·¯ã¯2 æ¬ä»¥äžååšããªãïŒã©ã®çºããã©ã®çºãžãããã€ãã®éè·¯ããã©ã£ãŠè¡ãããšãã§ããïŒ
<li>ç¶ã<i>K</i> è¡ã¯ã·ã§ããã³ã°ã¢ãŒã«ã®æ
å ±ãè¡šãïŒ<i>i</i>+<i>M</i>+1 è¡ç®(1 ≤ <i>i</i> ≤ <i>K</i>) ã«ã¯1 ã€ã®æŽæ°<i>s<sub>i</sub></i> (1 ≤ <i>s<sub>i</sub></i> ≤ <i>N</i>)ãæžãããŠããïŒããã¯çº<i>s<sub>i</sub></i> ã«ã·ã§ããã³ã°ã¢ãŒã«ãããããšãè¡šãïŒ<i>s</i><sub>1</sub>, ..., <i>s<sub>K</sub></i> ã®äžã«åãå€ã2
å以äžçŸããããšã¯ãªãïŒ
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒã·ã§ããã³ã°ã¢ãŒã«ã®ããçºãŸã§ã®æçè·é¢ã®æ倧å€ã®å°æ°ç¹ä»¥äžãåæšäºå
¥ããæŽæ°1
ã€ãåºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®40% åã«ã€ããŠã¯ïŒ<i>K</i> = 1 ãæºããïŒ
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ1</h3>
<pre>
3 3 1
1 2 1
2 3 1
3 1 1
1
</pre>
<h3>åºåäŸ1</h3>
<pre>
2
</pre>
<p>
å
¥åäŸ1 ã¯æ¬¡ã®ãããªçºãè¡šãïŒéè·¯ã®é·ãã¯ãã¹ãŠ1 ã§ããïŒã·ã§ããã³ã°ã¢ãŒã«ã¯çº1 ã«ãããªãïŒ
</p>
<p>
ã·ã§ããã³ã°ã¢ãŒã«ã®ããçºãŸã§ãã£ãšãé ãç¹ã¯ïŒçº2 ãšçº3 ãçµã¶éè·¯äžã®ïŒçº2 ããè·é¢0.5 ã®äœçœ®ã«ããç¹ã§ããïŒã·ã§ããã³ã°ã¢ãŒã«ã®ããçºãŸã§ã®è·é¢ã¯1.5 ã§ããïŒãã£ãŠïŒãããåæšäºå
¥ããå€ã§ãã2 ãåºåããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_shoppingInJOIKingdom">
</center>
<br>
<h3>å
¥åäŸ2</h3>
<pre>
4 5 2
1 2 4
1 3 1
2 3 2
2 4 2
3 4 1
2
4
</pre>
<h3>åºåäŸ2</h3>
<pre>
3
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n",
"3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n"
]
] |
p00486 | Walking Santa |
<H1>æ©ããµã³ã¿ã¯ããŒã¹(Walking Santa) </H1>
<p>
æšå¹Žæ«ïŒãµã³ã¿ã¯ããŒã¹ã¯JOI æã®åäŸãã¡ã«ã¯ãªã¹ãã¹ãã¬ãŒã³ããæž¡ãã®ãå¿ããŠããŸã£ãïŒããã§ïŒãè©«ã³ã®æ°æã¡ãšããŠåäŸãã¡ã«ãã§ã³ã¬ãŒãã±ãŒããå±ããããšã«ããïŒå±ããã¹ãæ¥ã¯ææ¥ã«è¿«ã£ãŠããã®ã§ïŒãããã移åèšç»ãèããªããã°ãªããªãïŒ
</p>
<p>
JOI æã¯ïŒååæ¹åã«ãŸã£ããã«äŒžã³ã<i>W</i> æ¬ã®éè·¯ãšïŒæ±è¥¿æ¹åã«ãŸã£ããã«äŒžã³ã<i>H</i> æ¬ã®éè·¯ã«ããïŒç¢ç€ã®ç®ã®åœ¢ã«åºåããããŠãã. ååæ¹åã®<i>W</i> æ¬ã®éè·¯ã«ã¯ïŒè¥¿ããé ã«1, 2, ... , <i>W</i> ã®çªå·ãä»ããããŠããïŒæ±è¥¿æ¹åã®<i>H</i> æ¬ã®éè·¯ã«ã¯ïŒåããé ã«1, 2, ... , <i>H</i> ã®çªå·ãä»ããããŠãã. 西ãã<i>x</i> çªç®ã®ååæ¹åã®éè·¯ãšïŒåãã<i>y</i> çªç®ã®æ±è¥¿æ¹åã®éè·¯ã亀ãã亀差ç¹ã(<i>x</i>, <i>y</i>) ã§è¡šã. JOI æã«ã¯<i>N</i> è»ã®å®¶ãããïŒãããã¯ããããã®äº€å·®ç¹ã«äœçœ®ããŠãã. ãµã³ã¿ã¯ããŒã¹ã¯éè·¯ã«æ²¿ã£ãŠã®ã¿ç§»åããããšãã§ãã. é£ãåã亀差ç¹ã®éã移åããã®ã«ãããæéã1 ãšãã.
</p>
<p>
JOI æã®ãã¹ãŠã®å®¶ã«ã¯åäŸãããã®ã§ïŒãµã³ã¿ã¯ããŒã¹ã¯JOI æã®ãã¹ãŠã®å®¶ã«1 åãã€ãã§ã³ã¬ãŒãã±ãŒããå±ããŠãŸãããªããã°ãªããªã. 倧åãªãã§ã³ã¬ãŒãã±ãŒããæã£ãŠããã«ã€ãšç©ºãé£ã³ãŸããã®ã¯ããå±éºã§ããã®ã§ïŒãµã³ã¿ã¯ããŒã¹ãšããã«ã€ã¯JOI æã®ããããã®äº€å·®ç¹ã«éãç«ã¡ïŒãµã³ã¿ã¯ããŒã¹ãããããæ©ããŠãã§ã³ã¬ãŒãã±ãŒããå±ããããšã«ãã. ãµã³ã¿ã¯ããŒã¹ã¯åæã«2 å以äžã®ãã§ã³ã¬ãŒãã±ãŒããéãã§æ©ãããšã¯ããªãïŒã€ãŸãïŒãµã³ã¿ã¯ããŒã¹ã¯ãã§ã³ã¬ãŒãã±ãŒãã1 è»ã®å®¶ã«å±ãããã³ã«éãç«ã£ã亀差ç¹ã«æ»ãïŒ
</p>
<p>
ãµã³ã¿ã¯ããŒã¹ã¯ïŒJOI æã«éãç«ã£ãŠãããã¹ãŠã®å®¶ã«ãã§ã³ã¬ãŒãã±ãŒããå±ãããŸã§ã®æèŠæéãæå°ã«ãªããããªç§»åèšç»ãéžã¶ããšã«ããïŒããã§ïŒæåŸã®å®¶ã«ãã§ã³ã¬ãŒãã±ãŒããå±ããŠããéãç«ã£ã亀差ç¹ã«æ»ããŸã§ã®æéã¯æèŠæéã«å«ããªãããšã«æ³šæããïŒãŸãïŒç§»åã«ãããæé以å€ã¯èããªãïŒ
</p>
<h2>課é¡</h2>
<p>
家ã®äœçœ®ã®æ
å ±ãäžãããããšãïŒãµã³ã¿ã¯ããŒã¹ãéãç«ã€äº€å·®ç¹ãããŸãéžãã å Žåã®ïŒJOI æã«éãç«ã£ãŠãããã¹ãŠã®å®¶ã«ãã§ã³ã¬ãŒãã±ãŒããå±ãããŸã§ã®æèŠæéã®æå°å€ãšïŒæèŠæéãæå°ã«ããããã«éãç«ã€ã¹ã亀差ç¹ã®äœçœ®ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>W</i> ≤ 1000000000 = 10<sup>9</sup> ååæ¹åã«äŒžã³ãéè·¯ã®æ¬æ°<br>
1 ≤ <i>H</i> ≤ 1000000000 = 10<sup>9</sup> æ±è¥¿æ¹åã«äŒžã³ãéè·¯ã®æ¬æ°<br>
1 ≤ <i>N</i> ≤ 100000 = 10<sup>5</sup> 家ã®æ°<br>
1 ≤ <i>X<sub>i</sub></i> ≤ <i>W</i> <i>i</i> çªç®ã®å®¶ã®äœçœ®ã®, ååæ¹åã«äŒžã³ãéè·¯ã®çªå·<br>
1 ≤ <i>Y<sub>i</sub></i> ≤ <i>H</i> <i>i</i> çªç®ã®å®¶ã®äœçœ®ã®, æ±è¥¿æ¹åã«äŒžã³ãéè·¯ã®çªå·
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯åæ¹åã®éè·¯ã®æ¬æ°ãè¡šãæŽæ° <i>W</i>, <i>H</i> ã空çœãåºåããšããŠæžãããŠããïŒ</li>
<li> 2 è¡ç®ã«ã¯å®¶ã®æ°ãè¡šãæŽæ°<i>N</i> ãæžãããŠããïŒ</li>
<li> ç¶ã<i>N</i> è¡ã«ã¯ïŒå®¶ã®äœçœ®ã®æ
å ±ãæžãããŠããïŒ<i>i</i> + 2 è¡ç®(1 ≤ <i>i</i> ≤ <i>N</i>) ã«ã¯æŽæ°<i>X<sub>i</sub></i>, <i>Y<sub>i</sub></i> ã空çœãåºåããšããŠæžãããŠããïŒ<i>i</i> çªç®ã®å®¶ã亀差ç¹(<i>X<sub>i</sub></i>, <i>Y<sub>i</sub></i>) ã«äœçœ®ããŠããããšãè¡šãïŒããã<i>N</i> åã®äº€å·®ç¹ã¯ãã¹ãŠç°ãªãïŒ
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ä»¥äžã®ããŒã¿ãåºåããïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æèŠæéã®æå°å€ãè¡šã1 ã€ã®æŽæ°ãæžãããŠããªããã°ãªããªãïŒ</li>
<li> 2 è¡ç®ã«ã¯æèŠæéãæå°ã«ããããã«éãç«ã€ã¹ã亀差ç¹ã(<i>x</i>, <i>y</i>) ã§ãããšãïŒ2 ã€ã®æŽæ°<i>x</i>, <i>y</i> ããã®é ã«ç©ºçœãåºåããšããŠæžãããŠããªããã°ãªããªãïŒé©åãªäº€å·®ç¹ãè€æ°ããå Žåã¯ïŒãã®ãã¡æã西ã«ãã(ã€ãŸãïŒ<i>x</i> ã®å€ãå°ãã) 亀差ç¹ã, ããã§ã1 ã€ã«å®ãŸããªãå Žåã¯, ããã«ãã®ãã¡ã§æãåã«ãã(ã€ãŸãïŒ<i>y</i> ã®å€ãå°ãã) 亀差ç¹ãéžã¹.
</ul>
<h2>泚æ</h2>
<p>
ãã®åé¡ã§ã¯ïŒæ±ãæŽæ°ã®ç¯å²ã32 ãããã«åãŸããªãå¯èœæ§ãããããšã«æ³šæããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®40%åã«ã€ããŠã¯ïŒ<i>N</i> ≤ 1000 ãæºããïŒ<br>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®10%åã«ã€ããŠã¯ïŒ<i>W</i> ≤ 50, <i>H</i> ≤ 50, <i>N</i> ≤ 1000 ãæºããïŒ
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ1</h3>
<pre>
5 4
3
1 1
3 4
5 3
</pre>
<h3>åºåäŸ1</h3>
<pre>
10
3 3
</pre>
<p>
ããšãã°ïŒæ¬¡ã®ãããªç§»åèšç»ã«ããæèŠæéãæå°ã«ã§ããïŒ
</p>
<ul>
<li> 亀差ç¹(3; 3) ã«éãç«ã€ïŒ</li>
<li> 亀差ç¹(3; 4) ã«äœçœ®ããŠãã家ã«ãã§ã³ã¬ãŒãã±ãŒããå±ããïŒãããŸã§ã®çµéæéã¯1 ã§ããïŒ</li>
<li> 亀差ç¹(3; 3) ã«æ»ãïŒãããŸã§ã®çµéæéã¯2 ã§ããïŒ</li>
<li> 亀差ç¹(5; 3) ã«äœçœ®ããŠãã家ã«ãã§ã³ã¬ãŒãã±ãŒããå±ããïŒãããŸã§ã®çµéæéã¯4 ã§ããïŒ</li>
<li> 亀差ç¹(3; 3) ã«æ»ãïŒãããŸã§ã®çµéæéã¯6 ã§ããïŒ</li>
<li> 亀差ç¹(1; 1) ã«äœçœ®ããŠãã家ã«ãã§ã³ã¬ãŒãã±ãŒããå±ããïŒãããŸã§ã®çµéæéã¯10 ã§ããïŒ</li>
</ul>
<br>
<h3>å
¥åäŸ2</h3>
<pre>
4 6
8
1 3
3 2
4 4
2 5
2 3
3 3
3 4
2 4
</pre>
<h3>åºåäŸ2</h3>
<pre>
21
2 3
</pre>
<p>
家ããã亀差ç¹ã«éãç«ã£ãŠãããããšã«æ³šæããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"5 4\n3\n1 1\n3 4\n5 3\n",
"5 4\n3\n1 1\n3 4\n5 3\n"
]
] |
p00487 | Bug Party |
<H1> 埮çç©å®éš(Bug Party)</H1>
<p>
ããªãã¯Just Odd Inventions 瀟ãç¥ã£ãŠããã ããã? ãã®äŒç€Ÿã®æ¥åã¯ããã å¥åŠãªçºæ(just odd inventions)ããããããšã§ããïŒããã§ã¯ç¥ããŠJOI 瀟ãšåŒã¶ïŒ
</p>
<p>
JOI 瀟ã§ã¯å€ãã®åŸ®çç©ã1 ã€ã®ã·ã£ãŒã¬ã«çãããŸãŸéã蟌ããç 究ãããŠããïŒèª¿æ»å¯Ÿè±¡ã®åŸ®çç©ã¯<i>N</i> å¹ååšãïŒ1, 2, ... , <i>N</i> ãšããçªå·ãã€ããŠããïŒå埮çç©ã¯ã·ã£ãŒã¬ã«éã蟌ãããããšïŒfoo (fatally odd object) ãšåŒã°ããæ害ç©è³ªãäžç¬ã®ãã¡ã«ã·ã£ãŒã¬å
ã«æŸåºããïŒå埮çç©ãæŸåºããfoo ã®éã¯ç¥ãããŠããïŒã·ã£ãŒã¬ã«éã蟌ããããå
šåŸ®çç©ãæŸåºããfoo ã¯ã·ã£ãŒã¬å
ã®å埮çç©ãåçã«æåããïŒå埮çç©ã®foo 蚱容éã¯ç¥ãããŠããïŒãã®éãè¶
ããŠfoo ãæåãããšåŸ®çç©ã¯æ»ãã§ããŸãïŒ
</p>
<p>
埮çç©<i>i</i> ã®foo æŸåºéã¯<i>a<sub>i</sub></i> ããªã°ã©ã ïŒfoo 蚱容éã¯<i>b<sub>i</sub></i> ããªã°ã©ã ã§ããïŒããªãã¡ïŒã·ã£ãŒã¬ã«åŸ®çç©<i>i</i><sub>1</sub>, <i>i</i><sub>2</sub>, ... , <i>i<sub>k</sub></i> ãéã蟌ãããšãïŒã·ã£ãŒã¬å
ã®å埮çç©ã¯ãããã(<i>a</i><sub><i>i</i><sub>1</sub></sub> + <i>a</i><sub><i>i</i><sub>2</sub></sub> + ... + <i>a<sub>i<sub>k</sub></sub></i>)/<i>k</i> ããªã°ã©ã ã®foo ãæåãïŒã·ã£ãŒã¬å
ã®åŸ®çç©<i>i</i> ã¯ïŒãã®æåéãbi ãã倧ãããšæ»ãã§ããŸãïŒ
</p>
<p>
JOI 瀟ããã®å§èšã«ããïŒããªãã¯åºæ¥ãã ãå€ãã®åŸ®çç©ãã·ã£ãŒã¬ã«çãããŸãŸéã蟌ããªããã°ãªããªãïŒãã ãïŒåŸ®çç©ã®æ»éªžã¯ã·ã£ãŒã¬å
ã®ç°å¢ã«æªåœ±é¿ãåãŒãããïŒã·ã£ãŒã¬å
ã®ã©ã®åŸ®çç©ãfoo ã®æåã§æ»ãã§ã¯ãªããªãïŒ
</p>
<p>
ãªãïŒJOI 瀟ãããã å¥åŠãªçºæããããããšã§ã©ããã£ãŠå©çãåŸãŠãããã¯ïŒä»ãã£ãŠè¬ã§ããïŒJOI瀟å
ã§ã瀟é·ä»¥å€ã®èª°ãç¥ããªãïŒ
</p>
<h2>課é¡</h2>
<p>
調æ»å¯Ÿè±¡ã®åŸ®çç©æ°ãšïŒå埮çç©ã®foo æŸåºéãšfoo 蚱容éãäžãããããšãïŒ1 ã€ã®ã·ã£ãŒã¬ã«éã蟌ããããšãã§ãã埮çç©æ°ã®æ倧å€ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>N</i> ≤ 300000 = 3 × 10<sup>5</sup> 調æ»å¯Ÿè±¡ã®åŸ®çç©ã®æ°<br>
1 ≤ <i>a<sub>i</sub></i> ≤ 100000 = 10<sup>5</sup> 埮çç©<i>i</i> ã®foo æŸåºé(ããªã°ã©ã )<br>
1 ≤ <i>b<sub>i</sub></i> ≤ 100000 = 10<sup>5</sup> 埮çç©<i>i</i> ã®foo 蚱容é(ããªã°ã©ã )
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>N</i> ãæžãããŠããïŒèª¿æ»å¯Ÿè±¡ã®åŸ®çç©ã<i>N</i> å¹ååšããããšãè¡šãïŒ</li>
<li> ç¶ãN è¡ã«ã¯å埮çç©ã®æ
å ±ãæžãããŠããïŒ<i>i</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>N</i>) ã«ã¯ïŒæ£æŽæ° <i>a<sub>i</sub></i>, <i>b<sub>i</sub></i> ã空çœãåºåããšããŠæžãããŠããïŒåŸ®çç©i ã®foo æŸåºéã<i>a<sub>i</sub></i> ããªã°ã©ã ã§foo 蚱容éã<i>b<sub>i</sub></i> ããªã°ã©ã ã§ããããšãè¡šã.
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒ1 ã€ã®ã·ã£ãŒã¬ã«éã蟌ããããšãã§ãã埮çç©æ°ã®æ倧å€ã1 è¡ã§åºåããïŒ
</p>
<h2>泚æ</h2>
<p>
ãã®åé¡ã§ã¯ïŒæ±ãæŽæ°ã®ç¯å²ã32 ãããã«åãŸããªãå¯èœæ§ãããããšã«æ³šæããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®30% ã«ã€ããŠã¯ïŒ<i>N</i> ≤ 1000 ãæºããïŒ
</p>
<h2>å
¥åºåã®äŸ</h2>
<h3>å
¥åäŸ</h3>
<pre>
6
12 8
5 9
2 4
10 12
6 7
13 9
</pre>
<h3>åºåäŸ</h3>
<pre>
3
</pre>
<p>
ãã®äŸã§ã¯ïŒåŸ®çç©2, 4, 5 ãã·ã£ãŒã¬ã«å
¥ããã°ïŒæŸåºãããfoo ã®åèšéã¯5 + 10 + 6 = 21 ããªã°ã©ã ãšãªãïŒããããã®åŸ®çç©ãæåããfoo ã®éã¯21/3 = 7 ããªã°ã©ã ãšãªãïŒåŸ®çç©2, 4, 5 ã®foo 蚱容éã¯ãããã9, 12, 7 ããªã°ã©ã ãªã®ã§ïŒã·ã£ãŒã¬å
ã®ã©ã®åŸ®çç©ãæ»ãªãªãïŒãŸãïŒ4 å¹ä»¥äžã®åŸ®çç©ãã©ã®åŸ®çç©ãæ»ãªãªãããã«ã·ã£ãŒã¬ã«å
¥ããããšã¯ã§ããªãïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"6\n12 8\n5 9\n2 4\n10 12\n6 7\n13 9\n",
"6\n12 8\n5 9\n2 4\n10 12\n6 7\n13 9\n"
]
] |
p00488 | Lunch |
<H1>ã©ã³ã (Lunch) </H1>
<h2>åé¡</h2>
<p>
JOI ãã¹ã¿åºã§ã¯ïŒã©ã³ãã®ãããããã¹ã¿ãšæŸãããŠãžã¥ãŒã¹ã®ã»ããã¡ãã¥ãŒã奜è©ã§ããïŒãã®ã»ããã¡ãã¥ãŒã泚æãããšãã¯ïŒãã®æ¥ã® 3 çš®é¡ã®ãã¹ã¿ãš 2 çš®é¡ã®ãžã¥ãŒã¹ãã 1 ã€ãã€éžã¶ïŒãã¹ã¿ãšãžã¥ãŒã¹ã®å€æ®µã®åèšãã 50 åãåŒããéé¡ã代éãšãªãïŒ
</p>
<p>
ããæ¥ã®ãã¹ã¿ãšãžã¥ãŒã¹ã®å€æ®µãäžãããããšãïŒãã®æ¥ã®ã»ããã¡ãã¥ãŒã®ä»£éã®æå°å€ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥å㯠5 è¡ãããªãïŒ1 è¡ã« 1 ã€ãã€æ£ã®æŽæ°ãæžãããŠããïŒ<br>
1 è¡ç®ã®æŽæ°ã¯ 1 ã€ç®ã®ãã¹ã¿ã®å€æ®µã§ããïŒ<br>
2 è¡ç®ã®æŽæ°ã¯ 2 ã€ç®ã®ãã¹ã¿ã®å€æ®µã§ããïŒ<br>
3 è¡ç®ã®æŽæ°ã¯ 3 ã€ç®ã®ãã¹ã¿ã®å€æ®µã§ããïŒ<br>
4 è¡ç®ã®æŽæ°ã¯ 1 ã€ç®ã®ãžã¥ãŒã¹ã®å€æ®µã§ããïŒ<br>
5 è¡ç®ã®æŽæ°ã¯ 2 ã€ç®ã®ãžã¥ãŒã¹ã®å€æ®µã§ããïŒ<br>
ãã ãïŒäžããããå
¥åããŒã¿ã«ãããŠã¯å
šãŠã®ãã¹ã¿ãšãžã¥ãŒã¹ã®å€æ®µã¯ 100 åä»¥äž 2000 å以äžã§ããããšãä¿èšŒãããŠããïŒ
</p>
<h2>åºå</h2>
<p>
ãã®æ¥ã®ã»ããã¡ãã¥ãŒã®ä»£éã®æå°å€ã 1 è¡ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
800
700
900
198
330
</pre>
<h3>åºåäŸ 1</h3>
<pre>
848
</pre>
<p>
å
¥åºåäŸ 1 ã§ã¯ïŒ2 ã€ç®ã®ãã¹ã¿ãš 1 ã€ç®ã®ãžã¥ãŒã¹ãçµã¿åãããå Žåã®
700 + 198 - 50 = 848 ããã®æ¥ã®ã»ããã¡ãã¥ãŒã®ä»£éã®æå°å€ã§ããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
1999
1999
100
189
100
</pre>
<h3>åºåäŸ 2</h3>
<pre>
150
</pre>
<p>
å
¥åºåäŸ 2 ã§ã¯ïŒ3 ã€ç®ã®ãã¹ã¿ãš 2 ã€ç®ã®ãžã¥ãŒã¹ãçµã¿åãããå Žåã®
100 + 100 - 50 = 150 ããã®æ¥ã®ã»ããã¡ãã¥ãŒã®ä»£éã®æå°å€ã§ããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"800\n700\n900\n198\n330\n",
"800\n700\n900\n198\n330\n"
]
] |
p00489 | Soccer |
<H1>ãµãã«ãŒ (Soccer) </H1>
<h2> åé¡</h2>
<p>
JOI åœã§ã¯ãµãã«ãŒã人æ°ã§ããïŒJOI ãªãŒã°ãšãããªãŒã°æŠãæ¯é±è¡ãããŠããïŒ
</p>
<p>
JOI ãªãŒã°ã«ã¯ N åã®ããŒã ãæå±ããŠããŠïŒ1 ãã N ãŸã§ã®çªå·ãã€ããããŠããïŒãã¹ãŠã®çµã¿åããã®è©Šåãã¡ããã©äžåºŠãã€è¡ãããïŒã€ãŸãïŒ <nobr>N à (N - 1) / 2</nobr> è©Šåãè¡ãããïŒåè©Šåã®åæã¯ããããã®ããŒã ã®åŸç¹ã§æ±ºãŸãïŒåã£ãããŒã ã®åã¡ç¹ã¯ 3 ç¹ã§ããïŒè² ããããŒã ã®åã¡ç¹ã¯ 0 ç¹ã§ããïŒåŒãåãã®å ŽåïŒäž¡ããŒã ã®åã¡ç¹ã¯ 1 ç¹ã§ããïŒé äœã¯åããŒã ã®ç²åŸããåã¡ç¹ã®åèšã§æ±ºå®ãïŒåŸå€±ç¹å·®ã¯èããªãïŒåã¡ç¹ã®åèšãçããããŒã ã®é äœã¯äžäœã«æããïŒ
</p>
<p>
äŸãšããŠïŒ 4 ããŒã ã§ã®ãªãŒã°æŠãèããïŒ<nobr>4 à (4 - 1) / 2 = 6</nobr> è©Šåãè¡ãããïŒãããã®çµæã以äžã®è¡šã®ããã«ãªã£ããšããïŒãã€ãã³ã®å·ŠåŽã¯ãã®æšªã®ããŒã ã®åŸç¹ã§ããïŒå³åŽã¯ãã®çžŠã®ããŒã ã®åŸç¹ã§ããïŒ
</p>
<table style="margin-left: 50px; margin-right: 50px; border-style:solid; border-color:#000000;" border="1" cellspacing="1">
<tr>
<th></th>
<th align="center"> ããŒã 1 </th>
<th align="center"> ããŒã 2 </th>
<th align="center"> ããŒã 3 </th>
<th align="center"> ããŒã 4 </th>
<th align="center"> åã¡æ° </th>
<th align="center"> è² ãæ° </th>
<th align="center"> åŒãåãæ° </th>
<th align="center"> åã¡ç¹ </th>
</tr>
<tr>
<th align="center"> ããŒã 1 </th>
<td align="center">---</td>
<td align="center">0 - 1</td>
<td align="center">2 - 1</td>
<td align="center">2 - 2</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">4</td>
</tr>
<tr>
<th align="center"> ããŒã 2 </th>
<td align="center">1 - 0</td>
<td align="center">---</td>
<td align="center">1 - 1</td>
<td align="center">3 - 0</td>
<td align="center">2</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">7</td>
</tr>
<tr>
<th align="center"> ããŒã 3 </th>
<td align="center">1 - 2</td>
<td align="center">1 - 1</td>
<td align="center">---</td>
<td align="center">1 - 3</td>
<td align="center">0</td>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<th align="center"> ããŒã 4 </th>
<td align="center">2 - 2</td>
<td align="center">0 - 3</td>
<td align="center">3 - 1</td>
<td align="center">---</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">4</td>
</tr>
</table>
<br>
<p>
ãã®ãšãïŒåã¡ç¹ã®æãå€ãããŒã 2 ã 1 äœã§ããïŒ</br>
ãã®æ¬¡ã«åã¡ç¹ãå€ãããŒã ã¯ããŒã 1 ãšããŒã 4 ã§ããïŒãããã®ããŒã ã®é äœã¯å
±ã« 2 äœã§ããïŒ</br>
ãããŠåã¡ç¹ãæãå°ãªãããŒã 3 ã 4 äœã§ããïŒ
</p>
<p>
å
šãŠã®è©Šåã®çµæãäžãããããšãïŒåããŒã ã®é äœãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥åãã¡ã€ã«ã® 1 è¡ç®ã«ã¯ããŒã ã®åæ° N (2 ⊠N ⊠100) ãæžãããŠããïŒç¶ã <nobr>N à (N - 1) / 2</nobr> è¡ã«ã¯åè©Šåã®çµæãæžãããŠããïŒi + 1 è¡ç® (1 ⊠i ⊠<nobr>N à (N - 1) / 2</nobr>) ã«ã¯æŽæ° A<sub>i</sub>ïŒB<sub>i</sub>ïŒC<sub>i</sub>ïŒD<sub>i</sub> (1 ⊠A<sub>i</sub> ⊠NïŒ1 ⊠B<sub>i</sub> ⊠NïŒ0 ⊠C<sub>i</sub> ⊠100ïŒ0 ⊠D<sub>i</sub> ⊠100) ã空çœãåºåããšããŠæžãããŠããïŒããŒã A<sub>i</sub> ãšããŒã B<sub>i</sub> ã察æŠãïŒããŒã A<sub>i</sub> ã®åŸç¹ã C<sub>i</sub> ç¹ïŒããŒã B<sub>i</sub> ã®åŸç¹ã D<sub>i</sub> ç¹ã§ãã£ãããšãè¡šãïŒå
šãŠã® i ã«ã€ã㊠A<sub>i</sub> â B<sub>i</sub> ã§ããïŒåãçµã¿åããã®å¯ŸæŠãæžãããŠããããšã¯ãªãïŒ
</p>
<h2> åºå</h2>
<p>
åºå㯠N è¡ãããªãïŒåè¡ã¯ 1 ã€ã®æŽæ°ãããªãïŒ i è¡ç® (1 ⊠i ⊠N) ã®æŽæ°ã¯ããŒã i ã®é äœãè¡šãïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
4
1 2 0 1
1 3 2 1
1 4 2 2
2 3 1 1
2 4 3 0
3 4 1 3
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
1
4
2
</pre>
<p>
å
¥åºåäŸ 1 ã¯åé¡æäžã®äŸã«å¯Ÿå¿ããŠããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
5
1 2 1 1
3 4 3 1
5 1 1 2
2 3 0 0
4 5 2 3
1 3 0 2
5 2 2 2
4 1 4 5
3 5 4 0
2 4 0 1
</pre>
<h3>åºåäŸ 2</h3>
<pre>
2
4
1
4
3
</pre>
<p>
å
¥åºåäŸ 2 ã«ãããçµæã¯ä»¥äžã®éãã§ããïŒ
</p>
<table style="margin-left: 50px; margin-right: 50px;" border="1" cellspacing="1">
<tr>
<th></th>
<th align="center"> åã¡æ° </th>
<th align="center"> è² ãæ° </th>
<th align="center"> åŒãåãæ° </th>
<th align="center"> åã¡ç¹ </th>
</tr>
<tr>
<th align="center"> ããŒã 1 </th>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">7</td>
</tr>
<tr>
<th align="center"> ããŒã 2 </th>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">3</td>
<td align="center">3</td>
</tr>
<tr>
<th align="center"> ããŒã 3 </th>
<td align="center">3</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">10</td>
</tr>
<tr>
<th align="center"> ããŒã 4 </th>
<td align="center">1</td>
<td align="center">3</td>
<td align="center">0</td>
<td align="center">3</td>
</tr>
<tr>
<th align="center"> ããŒã 5 </th>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">4</td>
</tr>
</table>
<br>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n",
"4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n"
]
] |
p00490 | Best Pizza |
<H1>ãæé«ã®ã㶠(Best Pizza) </H1>
<h2> åé¡</h2>
<p>
K çäºé·ã¯ïŒJOI åžã®äžå¿éšã«ãã JOI ãã¶åºã®åžžé£å®¢ã§ããïŒåœŒã¯ããäºæ
ã«ããïŒä»æããç¯çŽç掻ãå§ããããšã«ããïŒããã§åœŒã¯ïŒJOI ãã¶åºã§æ³šæã§ãããã¶ã®ãã¡ïŒ1 ãã«ãããã®ã«ããªãŒãæ倧ãšãªããããªãã¶ã泚æããããšæã£ãïŒãã®ãããªãã¶ããæé«ã®ãã¶ããšåŒã¶ããšã«ãããïŒãæé«ã®ãã¶ã㯠1 çš®é¡ãšã¯éããªãïŒ
</p>
<p>
JOI ãã¶ã§ã¯ N çš®é¡ã®ãããã³ã°ããäœçš®é¡ããèªç±ã«éžã³ïŒåºæ¬ã®çå°ã®äžã«èŒãããã®ã泚æããããšãã§ããïŒåçš®ã®ãããã³ã°ã 2 ã€ä»¥äžèŒããããšã¯ã§ããªãïŒçå°ã«ãããã³ã°ã 1 çš®é¡ãèŒããªããã¶ã泚æã§ããïŒçå°ã®å€æ®µã¯ A ãã«ã§ããïŒãããã³ã°ã®å€æ®µã¯ãããã B ãã«ã§ããïŒãã¶ã®å€æ®µã¯ïŒçå°ã®å€æ®µãšèŒãããããã³ã°ã®å€æ®µã®åèšã§ããïŒããªãã¡ïŒãããã³ã°ã k çš®é¡ (0 ⊠k ⊠N) èŒãããã¶ã®å€æ®µã¯ <nobr>A + k à B</nobr> ãã«ã§ããïŒãã¶å
šäœã®ã«ããªãŒã¯ïŒçå°ã®ã«ããªãŒãšèŒãããããã³ã°ã®ã«ããªãŒã®åèšã§ããïŒ
</p>
<p>
çå°ã®å€æ®µãšãããã³ã°ã®å€æ®µïŒããã³ïŒçå°ãšåãããã³ã°ã®ã«ããªãŒã®å€ãäžãããããšãïŒãæé«ã®ãã¶ãã® 1 ãã«ãããã®ã«ããªãŒæ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥å㯠N + 3 è¡ãããªãïŒ
</p>
<p>
1 è¡ç®ã«ã¯ãããã³ã°ã®çš®é¡æ°ãè¡šã 1 ã€ã®æŽæ° N (1 ⊠N ⊠100) ãæžãããŠããïŒ2 è¡ç®ã«ã¯ 2 ã€ã®æŽæ° A, B (1 ⊠A ⊠1000ïŒ1 ⊠B ⊠1000) ã空çœãåºåããšããŠæžãããŠããïŒA ã¯çå°ã®å€æ®µïŒB ã¯ãããã³ã°ã®å€æ®µãè¡šãïŒ3 è¡ç®ã«ã¯ïŒçå°ã®ã«ããªãŒæ°ãè¡šã 1 ã€ã®æŽæ° C (1 ⊠C ⊠10000) ãæžãããŠããïŒ
</p>
<p>
3 + i è¡ç® (1 ⊠i ⊠N) ã«ã¯ïŒi çªç®ã®ãããã³ã°ã®ã«ããªãŒæ°ãè¡šã 1 ã€ã®æŽæ° D<sub>i</sub> (1 ⊠D<sub>i</sub> ⊠10000) ãæžãããŠããïŒ
</p>
<h2> åºå</h2>
<p>
ãæé«ã®ãã¶ãã® 1 ãã«ãããã®ã«ããªãŒæ°ã 1 è¡ã§åºåããïŒãã ãïŒå°æ°ç¹ä»¥äžã¯åãæšãŠãŠæŽæ°å€ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
3
12 2
200
50
300
100
</pre>
<h3>åºåäŸ 1</h3>
<pre>
37
</pre>
<p>
å
¥åºåäŸ 1 ã§ã¯ïŒ2 çªç®ãš 3 çªç®ã®ãããã³ã°ãèŒãããšïŒ200 + 300 + 100 = 600 ã«ããªãŒã§ 12 + 2 à 2 = 16 ãã«ã®ãã¶ã«ãªãïŒ
<br>
ãã®ãã¶ã¯ 1 ãã«ããã 600 / 16 = 37.5 ã«ããªãŒã«ãªãïŒããããæé«ã®ãã¶ããšãªãã®ã§ïŒ37.5 ã®å°æ°ç¹ä»¥äžãåãæšãŠã 37 ãåºåããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
4
20 3
900
300
100
400
1300
</pre>
<h3>åºåäŸ 2</h3>
<pre>
100
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"3\n12 2\n200\n50\n300\n100\n",
"3\n12 2\n200\n50\n300\n100\n"
]
] |
p00491 | Pasta |
<H1>ãã¹ã¿ (Pasta) </H1>
<h2> åé¡</h2>
<p>
ããªãã¯ãã¹ã¿ã倧奜ç©ã§ããïŒæ¯æ¥ïŒæ©åŸ¡é£¯ã«ãã¹ã¿ãäœã£ãŠé£ã¹ãŠããïŒããªãã¯ããããœãŒã¹ïŒã¯ãªãŒã ãœãŒã¹ïŒããžã«ãœãŒã¹ã® 3 çš®é¡ã®ãã¹ã¿ãäœãããšãã§ããïŒ
</p>
<p>
N æ¥éã®æ©åŸ¡é£¯ã®äºå®ãèããããšã«ããïŒããããã®æ¥ã« 3 çš®é¡ã®ãã¹ã¿ãã 1 çš®é¡ãéžã¶ïŒãã ãïŒåããã¹ã¿ãç¶ããšé£œããŠããŸãã®ã§ïŒ3 æ¥ä»¥äžé£ç¶ããŠåããã¹ã¿ãéžãã§ã¯ãããªãïŒãŸãïŒN æ¥ã®ãã¡ã® K æ¥åã®ãã¹ã¿ã¯ãã§ã«æ±ºããŠããïŒ
</p>
<p>
å
¥åãšã㊠N ã®å€ãšïŒK æ¥åã®ãã¹ã¿ã®æ
å ±ãäžãããããšãïŒæ¡ä»¶ãã¿ããäºå®ãäœéããããã 10000 ã§å²ã£ãäœããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥å㯠K + 1 è¡ãããªãïŒ
</p>
<p>
1 è¡ç®ã«ã¯ 2 ã€ã®æŽæ° N, K (3 ⊠N ⊠100ïŒ1 ⊠K ⊠N) ã空çœãåºåããšããŠæžãããŠããïŒ
<p>
1 + i è¡ç® (1 ⊠i ⊠K) ã«ã¯ 2 ã€ã®æŽæ° A<sub>i</sub>, B<sub>i</sub> (1 ⊠A<sub>i</sub> ⊠NïŒ1 ⊠B<sub>i</sub> ⊠3) ã空çœãåºåããšããŠæžãããŠããïŒããã¯ïŒA<sub>i</sub> æ¥ç®ã®ãã¹ã¿ã¯ãã§ã«æ±ºãŸã£ãŠããïŒB<sub>i</sub> = 1 ã®ãšãã¯ããããœãŒã¹ã§ããïŒB<sub>i</sub> = 2 ã®ãšãã¯ã¯ãªãŒã ãœãŒã¹ã§ããïŒB<sub>i</sub> = 3 ã®ãšãã¯ããžã«ãœãŒã¹ã§ããããšãè¡šãïŒA<sub>i</sub> (1 ⊠i ⊠K) ã¯å
šãŠç°ãªãïŒäžããããå
¥åããŒã¿ã«ãããŠïŒæ¡ä»¶ãã¿ããäºå®ã¯ 1 éã以äžããããšãä¿èšŒãããŠããïŒ
</p>
<h2> åºå</h2>
<p>
æ¡ä»¶ãã¿ããäºå®ãäœéããããã 10000 ã§å²ã£ãäœãã 1 è¡ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
5 3
3 1
1 1
4 2
</pre>
<h3>åºåäŸ 1</h3>
<pre>
6
</pre>
<p>
å
¥åºåäŸ 1 ã«ãããŠïŒããªã㯠5 æ¥éã®äºå®ãèããïŒ1 æ¥ç®ãš 3 æ¥ç®ã¯ããããœãŒã¹ã§ããïŒ4 æ¥ç®ã¯ã¯ãªãŒã ãœãŒã¹ã§ããïŒãŸãïŒ3 æ¥ä»¥äžé£ç¶ããŠåããã¹ã¿ãéžãã§ã¯ãããªãïŒãããã®æ¡ä»¶ãã¿ããäºå®ã¯ 6 éãããïŒ
</p>
<table style="margin-left: 50px; margin-right: 50px;">
<tr>
<th></th>
<th> 1æ¥ç® </th>
<th> 2æ¥ç® </th>
<th> 3æ¥ç® </th>
<th> 4æ¥ç® </th>
<th> 5æ¥ç® </th>
</tr>
<tr>
<th>äºå® 1 </th>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
</tr>
<tr>
<th>äºå® 2 </th>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">2</td>
</tr>
<tr>
<th>äºå® 3 </th>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">3</td>
</tr>
<tr>
<th>äºå® 4 </th>
<td align="center">1</td>
<td align="center">3</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">1</td>
</tr>
<tr>
<th>äºå® 5 </th>
<td align="center">1</td>
<td align="center">3</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">2</td>
</tr>
<tr>
<th>äºå® 6 </th>
<td align="center">1</td>
<td align="center">3</td>
<td align="center">1</td>
<td align="center">2</td>
<td align="center">3</td>
</tr>
</table>
<br>
<p>
ãã®è¡šã§ã¯ïŒ1 ã¯ããããœãŒã¹ãïŒ2 ã¯ã¯ãªãŒã ãœãŒã¹ãïŒ3 ã¯ããžã«ãœãŒã¹ãè¡šãïŒ
</p>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
20 5
10 2
4 3
12 1
13 2
9 1
</pre>
<h3>åºåäŸ 2</h3>
<pre>
2640
</pre>
<p>
å
¥åºåäŸ 2 ã«ãããŠïŒæ¡ä»¶ãã¿ããäºå®ã¯å
šéšã§ 4112640 éãããïŒããã 10000 ã§å²ã£ãäœãã§ãã 2640 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 3\n3 1\n1 1\n4 2\n",
"5 3\n3 1\n1 1\n4 2\n"
]
] |
p00492 | Illumination |
<H1>ã€ã«ãããŒã·ã§ã³ (Illumination) </H1>
<h2> åé¡</h2>
<p>
JOI 瀟ã®å»ºç©ã¯å³ã®ãã㪠1 蟺 1 ã¡ãŒãã«ã®æ£å
è§åœ¢ãã€ãªãåããã圢ã§ããïŒã¯ãªã¹ãã¹ãè¿ã¥ããŠããã®ã§ïŒJOI 瀟ã§ã¯å»ºç©ã®å£é¢ãã€ã«ãããŒã·ã§ã³ã§é£Ÿãä»ããããšã«ããïŒãã ãïŒå€ããèŠããªãéšåã«ã€ã«ãããŒã·ã§ã³ãæœãã®ã¯ç¡é§ãªã®ã§ïŒã€ã«ãããŒã·ã§ã³ã¯å€ãã建ç©ã®äžãéããã«è¡ãããšã®ã§ããå£é¢ã«ã®ã¿é£Ÿãä»ããããšã«ããïŒ
</p>
<center>
<p><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_2012-yo-t5-fig01"><br>å³: JOI 瀟ã®å»ºç©ã®é
眮ã®äŸ</p>
</center>
<p>
äžã®å³ã¯äžç©ºããèŠã JOI 瀟ã®å»ºç©ã®é
眮ã®äŸã§ããïŒæ£å
è§åœ¢å
ã®æ°åã¯åº§æšãè¡šãïŒç°è²ã®æ£å
è§åœ¢ã¯å»ºç©ãããå Žæãè¡šãïŒçœè²ã®æ£å
è§åœ¢ã¯å»ºç©ããªãå Žæãè¡šãïŒãã®äŸã§ã¯ïŒèµ€ã®å®ç·ã§ç€ºãããéšåãã€ã«ãããŒã·ã§ã³ã§é£Ÿãä»ããè¡ãå£é¢ãšãªãïŒãã®å£é¢ã®é·ãã®åèšã¯ 64 ã¡ãŒãã«ãšãªãïŒ
</p>
<p>
JOI 瀟ã®å»ºç©ã®é
眮ãè¡šãå°å³ãäžãããããšãïŒé£Ÿãä»ããè¡ãå£é¢ã®é·ãã®åèšãæ±ããããã°ã©ã ãäœæããïŒãã ãïŒå°å³ã®å€åŽã¯èªç±ã«è¡ãæ¥ã§ãããã®ãšãïŒé£æ¥ãã建ç©ã®éã¯éãããšã¯ã§ããªããã®ãšããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥åãã¡ã€ã«ã® 1 è¡ç®ã«ã¯ 2 ã€ã®æŽæ° W, H (1 ⊠W ⊠100ïŒ1 ⊠H ⊠100) ã空çœãåºåããšããŠæžãããŠããïŒç¶ã H è¡ã«ã¯ JOI 瀟ã®å»ºç©ã®é
眮ãæžãããŠããïŒi + 1 è¡ç® (1 ⊠i ⊠H) ã«ã¯ W åã®æŽæ°ã空çœãåºåããšããŠæžãããŠããïŒj åç® (1 ⊠j ⊠W) ã®æŽæ°ã¯åº§æš (j, i) ã®æ£å
è§åœ¢ã«å»ºç©ãããæ㯠1 ã§ããïŒãªãæ㯠0 ã§ããïŒãŸãïŒäžããããå
¥åããŒã¿ã«ã¯å»ºç©ãå¿
ã 1 ã€ä»¥äžããïŒ
</p>
<p>
å°å³ã¯ä»¥äžã®èŠåã«ãã£ãŠèšè¿°ãããŠããïŒ
</p>
<ul>
<li>å°å³ã®æãåã®è¡ã®æã西ã®æ£å
è§åœ¢ã¯åº§æš (1, 1) ã§ããïŒ</li>
<li>åº§æš (x, y) ã®æ£å
è§åœ¢ã«é£æ¥ããæ±é£ã®æ£å
è§åœ¢ã¯åº§æš (x + 1, y) ã§ããïŒ</li>
<li>y ãå¥æ°ã®æïŒåº§æš (x, y) ã®æ£å
è§åœ¢ã«é£æ¥ããå西ã®æ£å
è§åœ¢ã®åº§æšã¯ (x, y + 1) ã§ããïŒ</li>
<li>y ãå¶æ°ã®æïŒåº§æš (x, y) ã®æ£å
è§åœ¢ã«é£æ¥ããåæ±ã®æ£å
è§åœ¢ã®åº§æšã¯ (x, y + 1) ã§ããïŒ</li>
</ul>
<h2> åºå</h2>
<p>
ã€ã«ãããŒã·ã§ã³ã§é£Ÿãä»ããè¡ãå£é¢ã®é·ãã®åèšã 1 è¡ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
8 4
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 0
1 0 1 0 1 1 1 1
0 1 1 0 1 0 1 0
</pre>
<h3>åºåäŸ 1</h3>
<pre>
64
</pre>
<p>
å
¥åºåäŸ 1 ã¯åé¡æäžã®äŸã«å¯Ÿå¿ããŠããïŒã€ã«ãããŒã·ã§ã³ã§é£Ÿãä»ããè¡ãå£é¢ã®é·ãã®åèšã¯ 64 ã¡ãŒãã«ã§ããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
8 5
0 1 1 1 0 1 1 1
0 1 0 0 1 1 0 0
1 0 0 1 1 1 1 1
0 1 0 1 1 0 1 0
0 1 1 0 1 1 0 0
</pre>
<h3>åºåäŸ 2</h3>
<pre>
56
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"8 4\n0 1 0 1 0 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0\n",
"8 4\n0 1 0 1 0 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0\n"
]
] |
p00493 | Zig-Zag Numbers |
<H1>ãžã°ã¶ã°æ° (Zig-Zag Numbers) </H1>
<h2> åé¡</h2>
<p>
æ£ã®æŽæ°ã (å
é ã« 0 ãã€ããã«) 10 é²æ³ã§æžããŠæ¡ã®æ°åãé çªã«èŠãŠãããšå¢å ãšæžå°ã亀äºã«ç¹°ãè¿ããŠãããšãïŒãã®æ°ã¯ããžã°ã¶ã°æ°ãã§ãããšåŒã¶ããšã«ãããïŒããšãã°ïŒ2947 ã¯æ¡ã®æ°åã 2 â 9 â 4 â 7 ãšïŒå¢å â æžå° â å¢å ã®é ã«ãªã£ãŠããã®ã§ãžã°ã¶ã°æ°ã§ããïŒãŸãïŒ71946 㯠æžå° â å¢å â æžå° â å¢å ã®é ãªã®ã§ãžã°ã¶ã°æ°ã§ããïŒäžæ¹ïŒ123 ã 71446 ã 71442 ã 88 ã¯ãžã°ã¶ã°æ°ã§ã¯ãªãïŒãªãïŒ1 æ¡ã®æ£ã®æŽæ°ã¯ãžã°ã¶ã°æ°ã§ãããšèããããšãšããïŒ
</p>
<p>
A ä»¥äž B 以äžã® M ã®åæ°ã®ãã¡ïŒãžã°ã¶ã°æ°ã®åæ°ã 10000 ã§å²ã£ãäœããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2> å
¥å</h2>
<p>
å
¥å㯠3 è¡ãããªãïŒ1 è¡ã« 1 ã€ãã€æ£ã®æŽæ°ãæžãããŠããïŒ
</p>
<p>
1 è¡ç®ã®æŽæ°ã¯ A ãïŒ2 è¡ç®ã®æŽæ°ã¯ B ãïŒ3 è¡ç®ã®æŽæ°ã¯ M ãè¡šãïŒããã㯠1 ⊠A ⊠B ⊠10<sup>500</sup>ïŒ1 ⊠M ⊠500 ãæºããïŒ
</p>
<p>
â» A ã B ã®å€ã¯ïŒéåžžã®æŽæ°ãè¡šãããŒã¿åã«ã¯åãŸããªãå¯èœæ§ãããããšã«æ³šæããïŒ
</p>
<h2> åºå</h2>
<p>
A ä»¥äž B 以äžã® M ã®åæ°ã®ãã¡ïŒãžã°ã¶ã°æ°ã®åæ°ã 10000 ã§å²ã£ãäœãã 1 è¡ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
100
200
5
</pre>
<h3>åºåäŸ 1</h3>
<pre>
13
</pre>
<p>
å
¥åºåäŸ 1 ã«ãããŠïŒ100 ä»¥äž 200 以äžã® 5 ã®åæ°ã§ãããžã°ã¶ã°æ°ã¯ïŒ105, 120, 130, 140, 150, 160, 165, 170, 175, 180, 185, 190, 195 ã® 13 åã§ããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
6
1234567
3
</pre>
<h3>åºåäŸ 2</h3>
<pre>
246
</pre>
<p>
å
¥åºåäŸ 2 ã«ãããŠïŒ6 ä»¥äž 1234567 以äžã® 3 ã®åæ°ã§ãããžã°ã¶ã°æ°ã¯ 50246 åããã®ã§ïŒããã 10000 ã§å²ã£ãäœãã§ãã 246 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"100\n200\n5\n",
"100\n200\n5\n"
]
] |
p00494 | JJOOII |
<H1>JJOOII (JJOOII) </H1>
<p>
JOI (æ¥æ¬æ
å ±ãªãªã³ããã¯) ã®æ¬éžã«åããŠããã°ã©ãã³ã°ã®ç·Žç¿ãããŠããããªãã¯ïŒä»å¹ŽåºŠã®JOI ã®äºéžã®åé¡ã«ã¯æ°å€ãæ±ãåé¡ã°ãããåºé¡ããïŒæååãæ±ãåé¡ããªãã£ãããšã«æ°ãã€ããïŒããã§ããªãã¯ïŒãã£ããæååã®åé¡ã«åŒ·ããªã£ãŠã©ã€ãã«ãã¡ã«å·®ãã€ããããšã«ããïŒ
</p>
<p>
JOI ã®éå»åãçºããŠãããšïŒJ, O, I ã®3 çš®é¡ã®æåãããªãæååã«æ
£ããŠããå¿
èŠããããããªããšãããã£ãïŒããã§ïŒãã®ãããªæååã«ã€ããŠèãããïŒããªãã¯ãäžããããæååãJOI ãšããéšåæååããã€ãã©ãããçããããšããåé¡ãæãã€ãããã®ã®ïŒããã¯ããã«è§£ããŠããŸã£ãïŒãã£ãšã¬ãã«ã®é«ãåé¡ã解ãããããªãã¯ïŒä»¥äžã®ãããªåé¡ãäœã£ãïŒ
</p>
<p>
æåå<i>t</i> ãæåå<i>s</i> ã®<b>éšåæåå</b>ã§ãããšã¯ïŒ<i>t</i> ã®å
é ããã³æ«å°Ÿã«äœæåã(0 æåã§ããã) ãä»ã足ããš<i>s</i> ã«ãªãããšã§ããïŒããšãã°ïŒJJOOII ã¯OJJOOIIOJOI ã®éšåæååã§ããïŒäžæ¹ïŒJOI ã¯JOOI ã®éšåæååã§ã¯ãªãïŒ
</p>
<p>
ãŸãïŒ0 以äžã®æŽæ°<i>k</i> ã«å¯ŸãïŒ<b>ã¬ãã«<i>k</i> ã®JOI å</b>ãšã¯ïŒ<i>k</i> åã®æåJïŒ<i>k</i> åã®æåOïŒ<i>k</i> åã®æåI ããã®é ã«äžŠã¹ãæååã®ããšã§ãããšããïŒããšãã°ïŒJJOOII ã¯ã¬ãã«2 ã®JOI åã§ããïŒäžããããæååã®éšåæååã§ããJOI åã®ãã¡ïŒã¬ãã«ãæ倧ã®ãã®ãæ±ãããïŒ
</p>
<h2>課é¡</h2>
<p>
J, O, I ã®3 çš®é¡ã®æåãããªãé·ã<i>N</i> ã®æåå<i>S</i> ãäžãããããšãïŒã¬ãã«<i>k</i> ã®JOI åã<i>S</i> ã®éšåæååã§ãããããªæ倧ã®<i>k</i> ã®å€ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>N</i> ≤ 1000000 (= 10<sup>6</sup>) <i>S</i> ã®é·ã
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®ããŒã¿ãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯J, O, I ã®3 çš®é¡ã®æåãããªãæåå<i>S</i> ãæžãããŠããïŒ</li>
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒã¬ãã«<i>k</i> ã®JOI åã<i>S</i> ã®éšåæååã§ãããããªæ倧ã®<i>k</i> ã®å€ãè¡šãæŽæ°ã1 è¡ã§åºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®20%åã«ã€ããŠã¯ïŒ<i>N</i> ≤ 100 ãæºããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
OJJOOIIOJOI
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
</pre>
<p>
OJJOOIIOJOI ã¯ã¬ãã«2 ã®JOI åã§ããJJOOII ãéšåæååãšããŠå«ãã§ããïŒã¬ãã«3 以äžã®JOIåã¯éšåæååãšããŠå«ãŸãªãïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
IJJIIJJJ
</pre>
<h3>åºåäŸ 2</h3>
<pre>
0
</pre>
<h3>å
¥åäŸ 3</h3>
<pre>
JOIJOIJOIJOIJOI
</pre>
<h3>åºåäŸ 3</h3>
<pre>
1
</pre>
<h3>å
¥åäŸ 4</h3>
<pre>
OOJJJJJJJOOOOIIIII
</pre>
<h3>åºåäŸ 4</h3>
<pre>
4
</pre>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"OJJOOIIOJOI\n",
"OJJOOIIOJOI\n"
]
] |
p00495 | Card Game is Fun |
<H1> ãã®ããã«ãŒãã²ãŒã (Card Game is Fun) </H1>
<p>
1 ãã1000 ãŸã§ã®ã©ããã®æŽæ°ãæžãããã«ãŒããããããããïŒã¢ã³ããšãã«ãŒãã¯ãããã®ã«ãŒããçšããŠïŒæ¬¡ã®ãããªã²ãŒã ãããïŒ
</p>
<p>
ã¢ã³ãã¯<i>A</i> æïŒãã«ãŒãã¯<i>B</i> æã®ã«ãŒããããªãå±±ãæã€ïŒã¢ã³ãã¯<i>A</i> æã®ã«ãŒãã®äžããä»»æã®äœæãïŒ0 æã§ãããïŒãæšãŠãŠæ°ããå±±ãäœãïŒãã«ãŒãã¯<i>B,</i> æã®ã«ãŒããããªãå±±ã®äžçªäžããäœæãïŒ0æã§ãããïŒãšïŒäžçªäžããäœæãïŒ0 æã§ãããïŒãæšãŠãŠæ°ããå±±ãäœãïŒãã ãïŒæšãŠãéã«æ®ã£ãã«ãŒãã®äžŠã³æ¿ãã¯è¡ããªãïŒãã®ããã«äœã£ã2 ã€ã®å±±ãäžèŽããŠãããïŒäžæ¹ã®å±±ã«å«ãŸããã«ãŒãã®ææ°ã2 人ã®åŸç¹ã«ãªãïŒãã ãïŒ2 ã€ã®å±±ãäžèŽãããšã¯ïŒå±±ã«å«ãŸããã«ãŒãã®ææ°n ãåãã§ïŒãã€äžããi çªç®(1 ≤ <i>i</i> ≤ <i>n</i>) ã«æžãããã«ãŒãã®æŽæ°ãå
šãŠåãã§ããããšã§ããïŒ
</p>
<p>
äŸãã°ïŒã¢ã³ãã5 æã®ã«ãŒãã®å±±ãæã¡ïŒæžãããŠããæŽæ°ã¯äžããé ã«1,2,3,4,5 ã§ããïŒãã«ãŒãã4 æã®ã«ãŒãã®å±±ãæã¡ïŒæžãããŠããæŽæ°ãäžããé ã«3,1,4,1 ã§ãã£ããšããïŒãã®ãšãïŒã¢ã³ãã2,3,5 ã®ã«ãŒããæšãŠïŒãã«ãŒããäžçªäžã®3 ãšäžçªäžã®1 ã®ã«ãŒããæšãŠããš2 人ã®å±±ãäžèŽããïŒãã®ãšãïŒæ®ã£ãå±±ã®äžæ¹ã«å«ãŸããã«ãŒãã®ææ°ã¯2 æãªã®ã§ïŒ2 人ã¯åŸç¹2 ãåŸãïŒ
</p>
<p>
2 人ã®åŸç¹ã®æ倧å€ãæ±ãããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_cardGameIsFun">
</center>
<h2>課é¡</h2>
<p>
ã¢ã³ããšãã«ãŒããæã£ãŠããã«ãŒãã®å±±ã®æ
å ±ãäžãããããšãã«ïŒ2 人ã®åŸç¹ã®æ倧å€ãæ±ããã
ãã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>A</i> ≤ 5000<br>
1 ≤ <i>B</i> ≤ 5000<br>
ã«ãŒãã«æžãããŠããæŽæ°ã¯1 以äž1000 以äžã§ããïŒ<br>
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®ããŒã¿ãèªã¿èŸŒãïŒ
</p>
<p>
1 è¡ç®ã«ã¯ïŒæŽæ°<i>A</i>, <i>B</i> ã空çœãåºåããšããŠæžãããŠããïŒ
</p>
<p>
2 è¡ç®ã«ã¯ïŒ<i>A</i> åã®æŽæ°ã空çœãåºåããšããŠæžãããŠããïŒ<i>i</i> çªç®ã®æŽæ°(1 ≤ <i>i</i> ≤ <i>A</i>) ã¯ã¢ã³ãã®æã£ãŠããå±±ã®äžãã<i>i</i> çªç®ã®ã«ãŒãã«æžãããŠããæŽæ°ãè¡šãïŒ
</p>
<p>
3 è¡ç®ã«ã¯ïŒ<i>B</i> åã®æŽæ°ã空çœãåºåããšããŠæžãããŠããïŒ<i>j</i> çªç®ã®æŽæ°(1 ≤ <i>j</i> ≤ <i>B</i>) ã¯ãã«ãŒãã®æã£ãŠããå±±ã®äžããj çªç®ã®ã«ãŒãã«æžãããŠããæŽæ°ãè¡šãïŒ
</p>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒåŸç¹ã®æ倧å€ãè¡šãæŽæ°ã1 è¡ã§åºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®10%åã«ã€ããŠã¯ïŒ<i>A</i> ≤ 10, <i>B</i> ≤ 10 ãæºããïŒ<br>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®50%åã«ã€ããŠã¯ïŒ<i>A</i> ≤ 100, <i>B</i> ≤ 100 ãæºããïŒ<br>
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
5 4
1 2 3 4 5
3 1 4 1
</pre>
<h3>åºåäŸ 1</h3>
<pre>
2
</pre>
<p>
ãã®å
¥åºåäŸã¯åé¡æäžã®äŸã«å¯Ÿå¿ããŠããïŒ
</p>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
6 5
4 1 5 2 3 4
4 5 4 2 3
</pre>
<h3>åºåäŸ 2</h3>
<pre>
3
</pre>
<p>
ãã®å
¥åºåäŸã§ã¯ïŒ2 人ãåŸç¹3 ãåŸãæ¹æ³ã2 éãååšããïŒã¢ã³ãã1, 2, 3 ã®ã«ãŒããæšãŠãã«ãŒãã2, 3 ã®ã«ãŒããæšãŠããšã, 2 人ã®å±±ã¯äžããé ã«4, 5, 4 ãšãªã, 2 人ã®åŸç¹ã¯3 ç¹ãšãªã. ãŸã, ã¢ã³ãã1, 5, 4 ã®ã«ãŒããæšãŠãã«ãŒããäžçªäžã®4 ãš5 ã®ã«ãŒããæšãŠããšã, 2 人ã®å±±ã¯äžããé ã«4, 2, 3ãšãªã, 2 人ã®åŸç¹ã¯3 ç¹ãšãªã.
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 4\n1 2 3 4 5\n3 1 4 1\n",
"5 4\n1 2 3 4 5\n3 1 4 1\n"
]
] |
p00496 | Night Market |
<H1>å€åº(Night Market) </H1>
<p>
倪éããã¯ïŒJOI ç¥ç€Ÿã§éãããå€ç¥ãã«è¡ãããšã«ããïŒ
</p>
<p>
JOI ç¥ç€Ÿã«åããéã«æ²¿ã£ãŠïŒ<i>N</i> åã®å€åºãéãããŠããïŒããããã®å€åºã«ã¯ïŒ1 ãã<i>N</i> ãŸã§ã®çªå·ãé çªã«ã€ããŠããïŒéãã æã®æ¥œãããšéã¶ã®ã«ãããæéãããããæŽæ°ã§æ±ºãŸã£ãŠããïŒå€åº<i>i</i> ã§éãã æã®æ¥œããã¯<i>A<sub>i</sub></i> ã§ïŒå€åº<i>i</i> ã§éã¶ã®ã«ãããæéã¯<i>B<sub>i</sub></i> ã§ããïŒ
</p>
<p>
ãŸãïŒå€ç¥ãã®ã€ãã³ããšããŠè±ç«å€§äŒãããïŒæå»<i>S</i> ã«æã倧ããªè±ç«ãæã¡äžããããïŒå€ªéããã¯ãã®æã倧ããªè±ç«ãèŠãããšæã£ãŠããïŒ
</p>
<p>
倪éããã¯å€åºãšè±ç«ã®äž¡æ¹ã楜ããããã«ïŒå€ç¥ãã«å°çããæå»0 ããå€ç¥ããçµããæå»<i>T</i> ãŸã§ã®äºå®ãç«ãŠãããšã«ããïŒ
</p>
<p>
倪éããã¯å€åºã®äžãã<i>k</i> å(1 ≤ <i>k</i> ≤ <i>N</i>) ã®å€åºãéžã³ïŒããããã«å¯ŸããŠèšªããæå»ãæŽæ°ã§æ±ºããïŒåãå€åºã2 床éžã¶ããšã¯ã§ããªãïŒéžã°ããå€åºã®çªå·ãå°ããé ã«<i>y</i><sub>1</sub>, <i>y</i><sub>2</sub>, ... <i>y<sub>k</sub></i> ãšãïŒå€åº<i>y<sub>i</sub></i> ã蚪ããæå»ã<i>x<sub>y<sub>i</sub></sub></i> ãšãããšïŒå€ªéããã¯å€åº<i>y<sub>i</sub></i> ã§æå»<i>x<sub>y<sub>i</sub></sub></i> ããæå»<i>x<sub>y<sub>i</sub></sub></i> + <i>B<sub>y<sub>i</sub></sub></i> ãŸã§éã¶ïŒ
</p>
<p>
倪éããã¯å€åºã®çªå·ã®å°ããé ã«éã³ïŒåæã«2 ã€ã®å€åºã§ã¯éã¹ãªãïŒãŸãïŒå€åºãšå€åºã®éã®ç§»
åã«ãããæéã¯ç¡èŠã§ããïŒ
</p>
<p>
æå»<i>T</i> ãè¶
ãããšå€ç¥ããçµããã®ã§ïŒå€åºã§éã¶ããšã¯ã§ããªãïŒãŸãïŒå€åºã§éãã§ããéã¯è±ç«ãèŠãããšã¯ã§ããªãïŒãã ãïŒæå»<i>S</i> ãããå€åºã§éã³å§ããæå»ãéã³çµããæå»ã§ãã£ãå Žåã¯ïŒå€ªéããã¯è±ç«ãèŠãããšãã§ãããã®ãšããïŒ
</p>
<p>
ããªãã¡ïŒäºå®ã¯ä»¥äžã®æ¡ä»¶ãæºãããŠããªããã°ãªããªãïŒ
</p>
<ul>
<li> <i>y</i><sub>1</sub> < <i>y</i><sub>2</sub> < ... < <i>y<sub>k</sub></i></li>
<li> <i>x</i><sub><i>y</i><sub>1</sub></sub>, <i>x</i><sub><i>y</i><sub>2</sub></sub>, ... <i>x<sub>y<sub>k</sub></sub></i> ã¯æŽæ°ïŒ</li>
<li> 0 ≤ <i>x</i><sub><i>y</i><sub>1</sub></sub> < <i>x</i><sub><i>y</i><sub>1</sub></sub> + <i>B</i><sub><i>y</i><sub>1</sub></sub> ≤ <i>x</i><sub><i>y</i><sub>2</sub></sub> < <i>x</i><sub><i>y</i><sub>2</sub></sub> + <i>B</i><sub><i>y</i><sub>2</sub></sub> ≤ ... ≤ <i>x<sub>y<sub>k</sub></sub></i> < <i>x<sub>y<sub>k</sub></sub></i> + <i>B<sub>y<sub>k</sub></sub></i> ≤ <i>T</i></li>
<li> <i>x<sub>y<sub>i</sub></sub></i> < <i>S</i> < <i>x<sub>y<sub>i</sub></sub></i> + <i>B<sub>y<sub>i</sub></sub></i> ãšãªããããª<i>i</i> ã¯ååšããªãïŒ</li>
</ul>
<p>
éžã°ããå€åºã®æ¥œãã<i>A</i><sub><i>y</i><sub>1</sub></sub>, <i>A</i><sub><i>y</i><sub>2</sub></sub>, ... <i>A<sub>y<sub>k</sub></sub></i> ã®åèšã<i>M</i> ãšããïŒå€ªéããã¯<i>M</i> ãã§ããã ã倧ãããªãããã«äºå®ãç«ãŠãããšæã£ãŠããïŒ
</p>
<h2>課é¡</h2>
<p>
<i>N</i> åã®å€åºã®æ
å ±ãšæå»<i>S</i>, <i>T</i> ãäžããããæïŒ<i>M</i> ã®æ倧å€ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
1 ≤ <i>N</i> ≤ 3000 å€åºã®æ°<br>
1 ≤ <i>T</i> ≤ 3000 å€ç¥ããçµããæå»<br>
0 ≤ <i>S</i> ≤ <i>T</i> æã倧ããªè±ç«ãæã¡äžããããæå»<br>
0 ≤ <i>A<sub>i</sub></i> ≤ 100000 (= 10<sup>5</sup>) å€åºi ã§éãã æã®æ¥œãã<br>
1 ≤ <i>B<sub>i</sub></i> ≤ 3000 å€åº<i>i</i> ã§éã¶ã®ã«ãããæé<br>
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®å
¥åãèªã¿èŸŒãïŒ
</p>
<p>
å
¥åã®1 è¡ç®ã«ã¯æŽæ°<i>N</i>, <i>T</i>, <i>S</i> ã空çœãåºåããšããŠæžãããŠããïŒå€åºã®æ°ã<i>N</i> åïŒå€ç¥ããçµããæå»ã<i>T</i>ïŒæã倧ããªè±ç«ãæã¡äžããããæå»ã<i>S</i> ã§ããããšãè¡šãïŒ
</p>
<p>
ç¶ã<i>N</i> è¡ã«ã¯å€åºã®æ
å ±ãæžãããŠããïŒå
¥åã®<i>i</i> + 1 (1 ≤ <i>i</i> ≤ <i>N</i>) è¡ç®ã«ã¯æŽæ°<i>A<sub>i</sub></i>, <i>B<sub>i</sub></i> ã空çœãåºåããšããŠæžãããŠããïŒå€åº<i>i</i> ã§éãã æã®æ¥œããã<i>A<sub>i</sub></i> ã§ïŒå€åº<i>i</i> ã§éã¶ã®ã«ãããæéã<i>B<sub>i</sub></i> ã§ããããšãè¡šãïŒ
</p>
<p>
ãŸãïŒãã¹ãŠã®å
¥åã«ãããŠïŒïŒã€ä»¥äžã®äºå®ãç«ãŠãããããšãä¿èšŒãããŠããïŒ
</p>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒ<i>M</i> ã®æ倧å€ãè¡šãæŽæ°ã1 è¡ã§åºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒ<br>
é
ç¹ã®10%åã«ã€ããŠã¯ïŒ<i>N</i> ≤ 20 ãæºããïŒ<br>
é
ç¹ã®20%åã«ã€ããŠã¯ïŒ<i>S</i> = 0 ãæºããïŒ<br>
é
ç¹ã®30%åã«ã€ããŠã¯ïŒããã2 ã€ã®æ¡ä»¶ã®å°ãªããšãäžæ¹ãæºããïŒãŸãïŒããã2 ã€ã®æ¡ä»¶ã®äž¡æ¹ãæºãããããªæ¡ç¹çšããŒã¿ã¯ãªãïŒ<br>
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
5 20 14
8 9
2 4
7 13
6 3
5 8
</pre>
<h3>åºåäŸ 1</h3>
<pre>
16
</pre>
<p>
ãã®äŸã«ãããŠïŒ<br>
å€åº1 ãæå»0 ã«èšªãïŒ<br>
å€åº2 ãæå»9 ã«èšªãïŒ<br>
å€åº4 ãæå»14 ã«èšªãããããªäºå®ãç«ãŠããšïŒ<i>M</i> ãæã倧ããããããšãã§ããïŒ<br>
ãã®ãšãïŒ<i>M</i> = 8 + 2 + 6 = 16 ã§ããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div> | [
[
"5 20 14\n8 9\n2 4\n7 13\n6 3\n5 8\n",
"5 20 14\n8 9\n2 4\n7 13\n6 3\n5 8\n"
]
] |
p00497 | Nails |
<H1>é(Nails)</H1>
<p>
JOI ããã¯æ¿ã«éãåºããŠéãã§ããïŒäžå³ã®ããã«ïŒJOI ããã¯äžèŸº<i>N</i> æ¬ã®æ£äžè§åœ¢ã®åœ¢ã«éã䞊ã¹ãŠåºããïŒäžãã<i>a</i> è¡ç®(1 ≤ <i>a</i> ≤ <i>N</i>) ã«ã¯<i>a</i> æ¬ã®éã䞊ãã§ããïŒãã®ãã¡å·Šãã<i>b</i> æ¬ç®(1 ≤ <i>b</i> ≤ <i>a</i>) ã®éã(<i>a</i>, <i>b</i>) ã§è¡šãïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_nails1"><br>
<b>
å³1: éã®äžŠã³æ¹ïŒ<i>N</i> = 5 ã®å ŽåïŒ
</b>
</center>
<br>
<p>
éãé ç¹ãšããæ£äžè§åœ¢ãïŒãå蟺ãå
šäœã®æ£äžè§åœ¢ã®èŸºã®ãããããšå¹³è¡ã§ïŒå
šäœã®æ£äžè§åœ¢ãšåãåããã§ãããšãïŒãã®æ£äžè§åœ¢ãã<b>ããæ£äžè§åœ¢</b>ããšåŒã¶ïŒããªãã¡ïŒãããæ£äžè§åœ¢ããšã¯ïŒ3 æ¬ã®é(<i>a</i>, <i>b</i>), (<i>a</i> + <i>x</i>, <i>b</i>), (<i>a</i> + <i>x</i>, <i>b</i> + <i>x</i>) ãé ç¹ãšããæ£äžè§åœ¢ã®ããšã§ããïŒãã ã<i>a</i>, <i>b</i>, <i>x</i> ã¯1 ≤ <i>a</i> < <i>N</i>, 1 ≤ <i>b</i> ≤ <i>a</i>, 1 ≤ <i>x</i> ≤ <i>N</i> - <i>a</i>) ãã¿ããïŒïŒ
</p>
<p>
JOI ããã¯ïŒèŒªãŽã ã䜿ã£ãŠïŒãããæ£äžè§åœ¢ãã®åšããå²ãããšã«ããïŒ
</p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_nails2"><br>
<b>
å³2: 茪ãŽã ã«ãããããæ£äžè§åœ¢ãã®å²ãæ¹ã®äŸ
</b>
</center>
<br>
<h2>課é¡</h2>
<p>
æ£äžè§åœ¢ã®äžèŸºã«äžŠãã§ããéã®æ¬æ°<i>N</i> ãšïŒJOI ãããæã£ãŠãã茪ãŽã ã®æ°<i>M</i> ãšïŒ<i>M</i> æ¬ã®èŒªãŽã ã«ãããããæ£äžè§åœ¢ãã®å²ãæ¹ãäžãããããšãïŒ1 æ¬ä»¥äžã®èŒªãŽã ã§å²ãããéã®æ¬æ°ãæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å¶é</h2>
<p>
2 ≤ <i>N</i> ≤ 5000 äžèŸºã«äžŠãã§ããéã®æ¬æ°<br>
1 ≤ <i>M</i> ≤ 500000 (= 5 × 10<sup>5</sup>) 茪ãŽã ã®æ°
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®ããŒã¿ãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>N</i>, <i>M</i> ã空çœãåºåããšããŠæžãããŠããïŒ<i>N</i> ã¯æ£äžè§åœ¢ã®äžèŸºã«äžŠãã§ããéã®æ¬æ°ãïŒ<i>M</i> ã¯JOI ããã®æã£ãŠãã茪ãŽã ã®æ°ãããããè¡šãïŒ</li>
<li> ç¶ã<i>M</i> è¡ã¯èŒªãŽã ã«ãããããæ£äžè§åœ¢ãã®å²ãæ¹ã®æ
å ±ãè¡šãïŒ<i>i</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>M</i>) ã«ã¯æŽæ°<i>A<sub>i</sub></i>, <i>B<sub>i</sub></i>, <i>X<sub>i</sub></i> (1 ≤ <i>A<sub>i</sub></i> < <i>N</i>, 1 ≤ <i>B<sub>i</sub></i> ≤ <i>A<sub>i</sub></i>, 1 ≤ <i>X<sub>i</sub></i> ≤ <i>N</i> - <i>A<sub>i</sub></i>) ã空çœãåºåããšããŠæžãããŠããïŒããã¯ïŒ<i>i</i>æ¬ç®ã®èŒªãŽã ã¯3 æ¬ã®é(<i>A<sub>i</sub></i>, <i>B<sub>i</sub></i>), (<i>A<sub>i</sub></i> + <i>X<sub>i</sub></i>, <i>B<sub>i</sub></i>), (<i>A<sub>i</sub></i> + <i>X<sub>i</sub></i>, <i>B<sub>i</sub></i> + <i>X<sub>i</sub></i>) ãé ç¹ãšãããããæ£äžè§åœ¢ããå²ã£ãŠããããšãè¡šãïŒ
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒ1 æ¬ä»¥äžã®èŒªãŽã ã«å²ãããŠããéã®æ¬æ°ã1 è¡ã§åºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒé
ç¹ã®30% åã«ã€ããŠã¯ïŒ<i>M</i> ≤ 10000 ãæºããïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
5 2
2 2 1
2 1 3
</pre>
<h3>åºåäŸ 1</h3>
<pre>
12
</pre>
<p>
ãã®äŸã¯å³2 ã®ãããªãããæ£äžè§åœ¢ãã®å²ãæ¹ã«å¯Ÿå¿ããŠããïŒãã®äŸã«ãããŠïŒ(1, 1), (4, 4), (5, 5) 以å€ã®12 æ¬ã®éã1 æ¬ä»¥äžã®èŒªãŽã ã§å²ãããŠããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"5 2\n2 2 1\n2 1 3\n",
"5 2\n2 2 1\n2 1 3\n"
]
] |
p00498 | Festivals in JOI Kingdom |
<H1> JOI åœã®ãç¥ãäºæ
(Festivals in JOI Kingdom) </H1>
<p>
JOI åœã«ã¯N åã®è¡ãããïŒãããã®éã¯<i>M</i> æ¬ã®åæ¹åã«éè¡å¯èœãªéè·¯ã§çµã°ããŠããïŒåœæ°ã¯éè·¯ãéã£ãŠãããã®è¡ã移åããïŒ
</p>
<p>
JOI åœã®åœæ°ã«ã¯ïŒãç¥ãã奜ããªäººãå€ãïŒçŸåšïŒ<i>K</i> åã®è¡ã§ãç¥ããéå¬ãããŠããïŒéåžžã«è³ãã£ãŠããïŒäžæ¹ã§ïŒäžéšã®åœæ°ã¯ãç¥ããéšããããšããŠå«ãïŒãç¥ãã«ã§ããã ãè¿ã¥ããããªããšæã£ãŠããïŒ
</p>
<p>
ããã§åœçã¯ïŒåªç§ãªããã°ã©ããŒã§ããããªãã«ïŒãã®ãããªãç¥ããå«ãåœæ°ã®ããïŒããè¡ããããè¡ã«ç§»åããããã«ïŒãç¥ããéå¬ãããŠããè¡ã«ã©ãã ãè¿ã¥ããã«ç§»åããããšãã§ããããé«éã«èª¿ã¹ãããšã®ã§ããããã°ã©ã ã®äœæãäŸé ŒããïŒ
</p>
<h2>課é¡</h2>
<p>
éè·¯ã®æ
å ±ãšãç¥ããéå¬ãããŠããè¡ã®æ
å ±ïŒããã³<i>Q</i> åã®ã¯ãšãªïŒåºçºããè¡<i>S<sub>i</sub></i> ãšè¡ãããè¡<i>T<sub>i</sub></i>ã®çµïŒãäžããããïŒåã¯ãšãª<i>i</i> ã«å¯ŸãïŒè¡<i>S<sub>i</sub></i> ããè¡<i>T<sub>i</sub></i> ãžã®ãã¹ãŠã®çµè·¯ã®ãã¡ïŒãç¥ããŸã§ã®è·é¢ãæ倧ãšãªãçµè·¯ã®ïŒãç¥ããŸã§ã®è·é¢ãæ±ããããã°ã©ã ãäœæããïŒãã ãïŒããçµè·¯ã®ãç¥ããŸã§ã®è·é¢ãšã¯ïŒçµè·¯äžã®è¡ãããç¥ããéå¬ãããŠããè¡ãŸã§ã®ç§»åè·é¢ã®æå°å€ã®ããšã§ããïŒ
</p>
<h2>å¶é</h2>
<p>
2 ≤ <i>N</i> ≤ 100000 (= 10<sup>5</sup>) JOI åœã®è¡ã®åæ°<br>
1 ≤ <i>M</i> ≤ 200000 (= 2 × 10<sup>5</sup>) JOI åœã®éè·¯ã®æ¬æ°<br>
1 ≤ <i>K</i> ≤ <i>N</i> ãç¥ããéå¬ãããŠããè¡ã®åæ°<br>
1 ≤ <i>Q</i> ≤ 100000 (= 10<sup>5</sup>) ã¯ãšãªã®åæ°<br>
1 ≤ <i>L<sub>i</sub></i> ≤ 1000 <i>i</i> çªç®ã®éè·¯ã®é·ã<br>
</p>
<h2>å
¥å</h2>
<p>
æšæºå
¥åãã以äžã®ããŒã¿ãèªã¿èŸŒãïŒ
</p>
<ul>
<li> 1 è¡ç®ã«ã¯æŽæ°<i>N</i>, <i>M</i>, <i>K</i>, <i>Q</i> ã空çœãåºåããšããŠæžãããŠããïŒ<i>N</i> ã¯JOI åœã®è¡ã®åæ°ãïŒ<i>M</i> ã¯JOIåœã®éè·¯ã®æ¬æ°ãïŒ<i>K</i> ã¯ãç¥ããéå¬ãããŠããè¡ã®åæ°ãïŒ<i>Q</i> ã¯ã¯ãšãªã®åæ°ãããããè¡šãïŒè¡ã«ã¯1, 2, ... , <i>N</i> ã®çªå·ãã€ããããŠããïŒ
</li>
<li> ç¶ã<i>M</i> è¡ã¯éè·¯ã®æ
å ±ãè¡šãïŒ<i>i</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>M</i>) ã«ã¯æŽæ°<i>A<sub>i</sub></i>, <i>B<sub>i</sub></i>, <i>L<sub>i</sub></i> (1 ≤ <i>A<sub>i</sub></i> ≤ <i>N</i>, 1 ≤ <i>B<sub>i</sub></i> ≤ <i>N</i>) ã空çœãåºåããšããŠæžãããŠããïŒããã¯ïŒ<i>i</i> çªç®ã®éè·¯ãè¡<i>A<sub>i</sub></i> ãšè¡<i>B<sub>i</sub></i> ãçµãã§ããïŒé·ãã<i>L<sub>i</sub></i> ã§ããããšãè¡šãïŒéè·¯ã®äž¡ç«¯ãåãè¡ã§ããããšã¯ãªãïŒãŸãïŒä»»æã®2 ã€ã®è¡<i>p</i>, <i>q</i> ã«å¯ŸãïŒ<i>p</i> ãš<i>q</i>ãçµã¶éè·¯ã¯2 æ¬ä»¥äžååšããªãïŒã©ã®è¡ããã©ã®è¡ãžãããã€ãã®éè·¯ããã©ã£ãŠè¡ãããšãã§ããïŒ</li>
<li> ç¶ã<i>K</i> è¡ã¯ãç¥ããéå¬ãããŠããè¡ã®æ
å ±ãè¡šãïŒ<i>i</i> + <i>M</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>K</i>) ã«ã¯1 ã€ã®æŽæ°<i>F<sub>i</sub></i>(1 ≤ <i>F<sub>i</sub></i> ≤ <i>N</i>) ãæžãããŠããïŒããã¯è¡<i>F<sub>i</sub></i> ã§ãç¥ããéå¬ãããŠããããšãè¡šãïŒ<i>F</i><sub>1</sub>, ..., <i>F<sub>K</sub></i> ã®äžã«åãå€ã2 å以äžçŸããããšã¯ãªãïŒ
</li>
<li> ç¶ã<i>Q</i> è¡ã¯ã¯ãšãªãè¡šãïŒ<i>i</i> + <i>M</i> + <i>K</i> + 1 è¡ç®(1 ≤ <i>i</i> ≤ <i>Q</i>) ã«ã¯2 ã€ã®æŽæ°<i>S<sub>i</sub></i>, <i>T<sub>i</sub></i> (1 ≤ <i>S<sub>i</sub></i> ≤ <i>N</i>, 1 ≤ <i>T<sub>i</sub></i> ≤ <i>N</i>, <i>S<sub>i</sub></i> ≠ <i>T<sub>i</sub></i>) ã空çœãåºåããšããŠæžãããŠããïŒããã¯<i>i</i> çªç®ã®ã¯ãšãªã®åºçºããè¡ã<i>S<sub>i</sub></i> ã§ããè¡ãããè¡ã<i>T<sub>i</sub></i> ã§ããããšãè¡šãïŒ</li>
</ul>
<h2>åºå</h2>
<p>
æšæºåºåã«ïŒå
šã¯ãšãªãžã®çãã<i>Q</i> è¡ã§åºåããïŒããªãã¡ïŒ<i>i</i> è¡ç®ã«ïŒè¡<i>S<sub>i</sub></i> ããè¡<i>T<sub>i</sub></i> ãžã®ãã¹ãŠã®çµè·¯ã®ãã¡ïŒãç¥ããŸã§ã®è·é¢ãæ倧ãšãªãçµè·¯ã®ïŒãç¥ããŸã§ã®è·é¢ãè¡šãæŽæ°ãåºåããïŒ
</p>
<h2>æ¡ç¹åºæº</h2>
<p>
æ¡ç¹çšããŒã¿ã®ãã¡ïŒ<br>
é
ç¹ã®10% åã«ã€ããŠã¯ïŒ<i>Q</i> = 1 ãæºããïŒ<br>
é
ç¹ã®20% åã«ã€ããŠã¯ïŒ<i>N</i> ≤ 5000, <i>Q</i> ≤ 5000 ãæºããïŒ<br>
é
ç¹ã®30% åã«ã€ããŠã¯ïŒããã2 ã€ã®æ¡ä»¶ã®å°ãªããšãäžæ¹ãæºããïŒãŸãïŒããã2 ã€ã®æ¡ä»¶ã®äž¡æ¹ãæºãããããªæ¡ç¹çšããŒã¿ã¯ãªãïŒ
</p>
<h2>å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
6 6 2 3
1 2 5
2 3 4
2 4 6
3 5 9
4 5 3
5 6 7
1
6
3 4
5 2
1 4
</pre>
<h3>åºåäŸ 1</h3>
<pre>
7
5
0
</pre>
<p>
6 ã€ã®è¡ã6 æ¬ã®éè·¯ã§çµã°ããŠããïŒãç¥ãã¯è¡1, 6 ã®2 ã€ã®è¡ã§éå¬ãããŠããïŒã¯ãšãªã¯ä»¥äžã®3 ã€ã§ããïŒ
</p>
<ul>
<li> 1 ã€ç®ã®ã¯ãšãªã¯è¡3 ããè¡4 ãžè¡ããšãããã®ã§ããïŒè¡2 ãçµç±ããçµè·¯ã§ã¯ãç¥ããŸã§ã®è·é¢ã¯5ïŒè¡5 ãçµç±ããçµè·¯ã§ã¯ãç¥ããŸã§ã®è·é¢ã¯7 ãšãªãããïŒçãã¯7 ã§ããïŒ
</li>
<li> 2 ã€ç®ã®ã¯ãšãªã¯è¡5 ããè¡2 ãžè¡ããšãããã®ã§ããïŒè¡3 ãšè¡4 ã®ã©ã¡ããçµç±ããŠãïŒè¡2 ã§ãç¥ããŸã§ã®è·é¢ãæå°ãšãªãïŒçãã¯5 ã§ããïŒ
</li>
<li> 3 ã€ç®ã®ã¯ãšãªã¯è¡1 ããè¡4 ãžè¡ããšãããã®ã§ããïŒè¡1 ã¯ãç¥ããéå¬ãããŠããè¡ã§ããããïŒçãã¯0 ãšãªãïŒ
</li>
</ul>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_festivalsInJOIKingdom1"><br>
<b>
å³1: å
¥åäŸ1
</b>
</center>
<br>
<h3>å
¥åäŸ 2</h3>
<pre>
12 17 2 5
1 3 6
1 6 7
2 3 8
2 4 4
2 8 11
2 12 2
3 6 3
3 7 8
3 11 2
4 12 2
5 10 3
6 10 5
8 9 6
8 12 7
9 10 6
11 9 10
12 9 5
8
7
2 6
5 2
1 10
8 9
9 4
</pre>
<h3>åºåäŸ 2</h3>
<pre>
8
8
11
0
6
</pre>
<br>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_festivalsInJOIKingdom2"><br>
<b>
å³1: å
¥åäŸ2
</b>
</center>
<br>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"6 6 2 3\n1 2 5\n2 3 4\n2 4 6\n3 5 9\n4 5 3\n5 6 7\n1\n6\n3 4\n5 2\n1 4\n",
"6 6 2 3\n1 2 5\n2 3 4\n2 4 6\n3 5 9\n4 5 3\n5 6 7\n1\n6\n3 4\n5 2\n1 4\n"
]
] |
p00499 | Homework |
<H1>å®¿é¡ (Homework) </H1>
<br/>
<h2>åé¡</h2>
<p>
å¬äŒã¿ã®å®¿é¡ã«æ¯åèŠãããããŠãã JOI åãïŒä»åã¯å®¿é¡ãèšç»çã«å®è¡ããããšã«ããïŒå®¿é¡ã¯åœèªãšç®æ°ã®ããªã«ã§ããïŒåœèªã®ããªã«ã¯ A ããŒãžïŒç®æ°ã®ããªã«ã¯ B ããŒãžããïŒ
</p>
<p>
JOI åã¯ïŒ1 æ¥ã«åœèªã®ããªã«ãæ倧 C ããŒãžãšïŒç®æ°ã®ããªã«ãæ倧 D ããŒãžé²ããããšãã§ãããïŒå®¿é¡ããããšãã®æ¥ã¯éã¶ããšãã§ããªãïŒ
</p>
<p>
å¬äŒã¿ã¯ L æ¥ããïŒJOI åã¯å¬äŒã¿äžã«å®¿é¡ãçµããããªããã°ãªããªãïŒJOI åãå¬äŒã¿äžã«æ倧ã§äœæ¥éã¹ãããæ±ããããã°ã©ã ãäœæããïŒ
</p>
<h2>å
¥å</h2>
<p>
å
¥å㯠5 è¡ãããªãïŒ1 è¡ã« 1 ã€ãã€æ£ã®æŽæ°ãæžãããŠããïŒ
</p>
<p>
1 è¡ç®ã«ã¯æŽæ° L (2 ⊠L ⊠40) ãæžãããŠããïŒå¬äŒã¿ã®æ¥æ°ãè¡šãïŒ
</p>
<p>
2 è¡ç®ã«ã¯æŽæ° A (1 ⊠A ⊠1000) ãæžãããŠããïŒåœèªã®ããªã«ã®ããŒãžæ°ãè¡šãïŒ
</p>
<p>
3 è¡ç®ã«ã¯æŽæ° B (1 ⊠B ⊠1000) ãæžãããŠããïŒç®æ°ã®ããªã«ã®ããŒãžæ°ãè¡šãïŒ
</p>
<p>
4 è¡ç®ã«ã¯æŽæ° C (1 ⊠C ⊠100) ãæžãããŠããïŒJOI åã 1 æ¥ã«é²ããããšãã§ããåœèªã®ããªã«ã®æ倧ããŒãžæ°ãè¡šãïŒ
</p>
<p>
5 è¡ç®ã«ã¯æŽæ° D (1 ⊠D ⊠100) ãæžãããŠããïŒJOI åã 1 æ¥ã«é²ããããšãã§ããç®æ°ã®ããªã«ã®æ倧ããŒãžæ°ãè¡šãïŒ
</p>
<p>
ãã ãïŒäžããããå
¥åããŒã¿ã«ãããŠã¯ïŒJOI åãå¬äŒã¿äžã«å®¿é¡ãå¿
ãçµããããããšãã§ãïŒ
å°ãªããšã 1 æ¥ã¯éã¹ãããšãä¿èšŒãããŠããïŒ
</p>
<h2> åºå</h2>
<p>
JOI åãå¬äŒã¿äžã«éã¹ãæ¥æ°ã®æ倧å€ã 1 è¡ã§åºåããïŒ
</p>
<h2> å
¥åºåäŸ</h2>
<h3>å
¥åäŸ 1</h3>
<pre>
20
25
30
6
8
</pre>
<h3>åºåäŸ 1</h3>
<pre>
15
</pre>
<p>
å
¥åºåäŸ 1 ã§ã¯ïŒå¬äŒã¿ã¯ 20 æ¥éããïŒåœèªã®ããªã«ã 25 ããŒãžïŒç®æ°ã®ããªã«ã 30 ããŒãžããïŒJOI å㯠1 æ¥ã«åœèªã®ããªã«ãæ倧 6 ããŒãžïŒç®æ°ã®ããªã«ãæ倧 8 ããŒãžé²ããããšãã§ããïŒäŸãã° JOI åãå¬äŒã¿åæ¥ããåœèªã®ããªã«ã 6 ããŒãžïŒç®æ°ã®ããªã«ã 8 ããŒãžãã€é²ãããšãããšïŒåœèªã®ããªã«ã 5 æ¥ç®ã«ïŒç®æ°ã®ããªã«ã 4 æ¥ç®ã«çµããããããšãã§ãïŒ15 æ¥ééã¶ããšãã§ããïŒããã JOI åãå¬äŒã¿äžã«éã¹ãæ¥æ°ã®æ倧å€ãªã®ã§ïŒ15 ãåºåããïŒ
</p>
<h3>å
¥åäŸ 2</h3>
<pre>
15
32
48
4
6
</pre>
<h3>åºåäŸ 2</h3>
<pre>
7
</pre>
<p>
å
¥åºåäŸ 2 ã§ã¯ïŒ
äŸãã° JOI åãåæ¥ããåœèªã®ããªã«ã 4 ããŒãžïŒç®æ°ã®ããªã«ã 6 ããŒãžãã€é²ãããšãããšïŒ8 æ¥ç®ã«äž¡æ¹ã®ããªã«ãçµããããããšãã§ãïŒ7 æ¥ééã¶ããšãã§ããïŒããã JOI åãå¬äŒã¿äžã«éã¹ãæ¥æ°ã®æ倧å€ãªã®ã§ïŒ7 ãåºåããïŒ
</p>
<div class="source">
<p class="source">
åé¡æãšèªå審å€ã«äœ¿ãããããŒã¿ã¯ã<a href="http://www.ioi-jp.org">æ
å ±ãªãªã³ããã¯æ¥æ¬å§å¡äŒ</a>ãäœæãå
¬éããŠããåé¡æãšæ¡ç¹çšãã¹ãããŒã¿ã§ãã
</p>
</div>
| [
[
"20\n25\n30\n6\n8\n",
"20\n25\n30\n6\n8\n"
]
] |