JOIä¸æ¬¡äºé¸
å¤é for æã®ç·´ç¿ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 2 ã¤ã®æ°å ã ãä¸ãããããæ°å ãããããã 1 åãã¤é¸ãã§ã§ãã åã®ãã¢ã«ã¤ã㦠ããã®åãã¨ããã®æ大å¤ãã®ç© ãæ±ãã¦ããããã®ç·åãæ±ããã å¶ç´ èããã㨠2 ã¤ã®æ°åããããããè¦ç´ ãã¨â¦
for æ㨠if æã®ç·´ç¿ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå J, O, I ãããªãé·ã ã®æåå ãä¸ããããã ãã®æååã«ããã¦ãJ ã O ã«ãO ã I ã«ãI ã J ã«ç½®æããæååãçããã è§£æ³ for æãç¨ãããã¨ã§ã ã®åæåã«ã¢ã¯ã»ã¹ãããã¨ãã§ãããå·¦â¦
ã¡ãã£ã¨ããç®æ°çãªèãæ¹ãå¿ è¦ã«ãªãåé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ JOI åã¯ä»¥ä¸ã®è¡åãè¡å A â è¡å B â è¡å A â ⯠ã®ããã«äº¤äºã«ç¹°ãè¿ãã è¡å Aï¼3m åã«é²ã è¡å Bï¼2m å¾ãã«æ»ã è¡åãåãã㦠åè¡ãã¨ããä½mé²ããï¼ è§£æ³ ãã®ãããªåâ¦
ã¨ã¦ãæããç®æ°ã®åé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åãã£ã¦ããã 1 å 5 åã®éçãä½æ¬è²·ãããï¼ è§£æ³ çãã¯ã ã 5 ã§å²ã£ãåãã¨ãªãã¾ãããã㯠C++ ã§ã¯ A / 5 ã¨æ¸ãã¾ãã ã³ã¼ã #include <bits/stdc++.h> using namespace std; int main() { int A; cin >> </bits/stdc++.h>â¦
ã®å¶ç´ãå°ããã®ã§ããåºéããæãåã£ã¦å ¨é¨æ¢ç´¢ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ°å ãä¸ããããã ãæºãããã㪠ã«ã¤ãã¦ã®ã ã®å¤ã®æ大å¤ãæ±ããã å¶ç´ è§£æ³ ãã®æã®åé¡ã§æ©ãã§ãã¾ãã®ã¯ãã£ãããªãã¨è¨ãã¾ãï¼ ã¾ãã¯ãã³ã³ãâ¦
for æã§é£æ¥ããè¦ç´ ãè¦ãªããå¦çãã¦ããç³»ã®åé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ãä¸ããããã ãå·¦ããè¦ã¦ãããæåå "joi" ãå«ã¾ãããªãã°ãããã "JOI" ã«å¤æãã¦ããå¦çãç¹°ãè¿ããæä½å¾ã®æååãåºåããã è§£æ³ æ¬¡ã®ããã«â¦
ããããªè§£æ³ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä»¥ä¸ ä»¥ä¸ã®æ´æ°ã®ãã¡ã ã¨ã®å·®ã®çµ¶å¯¾å¤ãæãå°ãããã®ãæ±ããã å¶ç´ è§£æ³ (1)ï¼for æ ä¸çªç¢ºå®ãªæ¹æ³ã¯ãfor æãç¨ãã¦ã ããã¹ã¦èª¿ã¹ããã¨ã ã¨æããã¾ãã ãæå°ã¨ãªããã㪠ãæ±ããã°ããã§ãâ¦
éè¨å¦çãç·´ç¿ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä»¥ä¸ ä»¥ä¸ã®æ´æ°ãããªããé·ã ã®æ°å ãä¸ããããã é·ã ã®æ°ããªæ°å ã次ã®ããã«å®ç¾©ããã å ã«å¯¾ãã¦ã ãã ãæºãã ã®åæ° ã®æ大å¤ãæ±ããã å¶ç´ è§£æ³ åé¡ã®æå³ã解éããã®ãé£ããããâ¦
reverse ããç³»ã®åé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ã«ã¤ãã¦ã æåç®ãã æåç®ã¾ã§ãå転ãã¦å¾ãããæååãåºåããã å¶ç´ è§£æ³ C++ ã§ããã°ã©ã ãæ¸ãã¨ãã¯ãé常æåå㯠0 å§ã¾ãã§ãã®ã§ã ããããããã 1 å¼ãã¦ããã¾ãã ãã®â¦
ãã¼ã¸ã½ã¼ãã®ãã¼ã¸ã®é¨åãå®è£ ããåé¡ã§ããã æ·»åãé ã«é²ãã¦ãããããªå¦çãå®è£ ãã¾ãï¼ ãã®å®è£ ã¯ãã®ã¡ã«ãããã¨ãæ³ãå¦ã¶éã®åèã«ããªãã¾ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ å¶ç´ è§£æ³ åé¡æãè¤éã§ãä½ãããã°ããã®ããç解ããã®ã大å¤â¦
for æã®ç·´ç¿ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ãä¸ããããã ã®ãã¡æ¯é³åã®åæ°ãã¤ã¾ã aï¼iï¼uï¼eï¼o ã®åæ°ã®ç·åãæ±ããã è§£æ³ æåå ã®æåã 1 åãã¤ãfor æã使ã£ã¦èª¿ã¹ã¦ããã¾ãããã ã³ã¼ã #include <bits/stdc++.h> using namespace std; int</bits/stdc++.h>â¦
楽ããåé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 3 åã®æ´æ° ãä¸ããããã ãããã®æ´æ°ã®ãã¡ã大ããæ¹ãã 2 åã®åãæ±ããã è§£æ³ ããããä¸çªå°ããæ°ããå¼ãã°è¯ãã§ãããã ã®ãã¡ä¸çªå°ããæ°ã¯ãC++ ã§ã¯ãé¢æ° min() ãç¨ã㦠min({A, B, C}) ã¨è¡¨ãâ¦
å¤é for æã«æ £ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ°å ã¨ãé·ã ã®æ°å ãä¸ããããã ãæºããæ´æ°ã®çµ ã®åæ°ãæ±ããã å¶ç´ è§£æ³ å¤é for æã«æ £ãã¾ãããï¼ æ°å ã® çªç®ã¨ãæ°å ã® çªç®ããã¹ã¦èª¿ã¹ãã®ã¯ã次ã®ãã㪠2 éã® for æã§è¨â¦
for æã®ã«ã¼ãã«ã¦ã³ã¿ ãå¶æ°ãå¥æ°ãã«å¿ãã¦å¦çãå¤ããåé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ããå¥æ° ã®æåå ãä¸ããããã ãã®æååã«å¯¾ãã¦ã次ã®æä½ããããã¨ã§ã"IOIOIO...OI" ã¨ããããã« "I" 㨠"O" ãç¹°ãè¿ãæååã«ããããæä½åæ°ã®â¦
é¢æ° max() ã¨é¢æ° min() ã使ãããªããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 2 ã¤ã®æ´æ° ãä¸ããããã 㨠ã®ãã¡ãæ大ã®ãã®ã¨æå°ã®ãã®ãé ã«åºåããã è§£æ³ ã¾ãã 㨠ã®ãã¡ã®æ大ã®ãã®ã¯ max(A + B, A - B) ã¨è¡¨ãã¾ãããªãã 㨠ãåãå¤ã§ããå ´åã«ã¯â¦
for æã®ç·´ç¿ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ°å (ãã¹ã¦ã®è¦ç´ ã¯äºãã«ç¸ç°ãªã) ã«ã¤ãã¦ãæ大å¤ãèããã¨ãããã®å·¦å´ã®ç·åã¨ãå³å´ã®ç·åãããããæ±ããã å¶ç´ è§£æ³ ãã®åé¡ã§ã¯ãæ°å ã®æ大å¤ã ãã§ã¯ãªã ãæ大ã¨ãªããã㪠ãæ±ããå¿ â¦
å¤é for æã®å ¨æ¢ç´¢ã«æ £ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ãä¸ããããã次ã®æ¡ä»¶ãæºãã 3 ã¤çµã®æ´æ° ãåå¨ãããã©ãããå¤å®ããã ã® æåç®ã¯ 'I' ã§ãã ã® æåç®ã¯ 'O' ã§ãã ã® æåç®ã¯ 'I' ã§ãã å¶ç´ è§£æ³ ãæºãããã㪠â¦
ã¡ãã£ã¨ç´°ããã¨ãããã¹ã£ã人ãå¤ããããããªããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã太éã¯å¸°çãããã¨ã«ããã ä»æ¥ãã æ¥å¾ã®ååã«å®å®¶ã«çããä»æ¥ãã æ¥å¾ã®ååã«å®å®¶ãå»ãã ãããèãã¤ããããåã¯ãä»æ¥ãã æ¥å¾ã®åå¾ã«ã太éã®å®å®¶ã訪ãâ¦
ãã®ãããªåé¡ã解ãããã«ããããã±ããããç¿å¾ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ°å ã¨ãé·ã ã®æ°å ãä¸ããããã ãã£ãã®æ°åã®åæ¹ã«ç»å ´ããæ°ããã¹ã¦æé ã§åºåããã å¶ç´ è§£æ³ (1)ï¼1 ãã 100 ã¾ã§ã®æ°ãé ã«èª¿ã¹ã å¶ç´ãè¦ããâ¦
ããã¯é¢ç½ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå J, O, I ãããªããé·ã ã®æåå ãä¸ããããã ã®æåã並ã³æ¿ãã¦ã次ã®æ¡ä»¶ãæºãããã®ãæ±ããã ãã¹ã¦ã®æå J ã¯ããã¹ã¦ã®æå O ãããåã«ãã ãã¹ã¦ã®æå O ã¯ããã¹ã¦ã®æå I ãããåã«ããâ¦
ãã®æ代ã®ä¸æ¬¡äºé¸ã¯ãã¾ã ã¡ãã£ã¨é£ããã£ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 3 åã®æ´æ° ãä¸ããããããããã®æ´æ°ã®ãã¡ã2 çªç®ã«å¤§ããå¤ãæ±ããã å¶ç´ è§£æ³ (1) æã楽ã ã¨æãããæ¹æ³ã¯ã3 åã®æ´æ°ã®ãã¡ã®ãæ大å¤ãã¨ãæå°å¤ããæ±ãã¦ãããæ¹æ³â¦
ã©ã®ããã«ãã¼ã¿ã管çããã°ããããé£ããã¨æãããããããªãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æåãç®± ã«ãããããã¼ã« ãå ¥ã£ã¦ããã 次㮠åã®æä½ãè¡ãã åç®ã®æä½ã§ã¯ããã¼ã« ãå ¥ã£ã¦ããç®±ããããã¼ã« ãåãåºãã¦ããããç®± ã«å ¥ããã æâ¦
åé¡æãé·ãã ãããä¸å¯§ã«æ´çãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 人ã®çå¾ã®ãã¡ã 人ã¯èµ¤çµã§ã 人ã¯ç½çµã§ããã çå¾ã®ä¸äººã§ããèµããã¯ãèªåãä½çµããç¥ããããããã§ãèªå以å¤ã® 人ããããã赤çµã§ãããç½çµã§ãããã調ã¹ãããã®çµæã¯é·ãâ¦
æ´æ°ã®åãä¸ãã®åé¡ãæå¤ã¨æ£ç¢ºã«è§£ãã®ã¯å¤§å¤ãããããªãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ãã¼ã¹ã¨ãªãã¢ã¤ã¹ã¯ãªã¼ã ã®éé¡ã¯ 250 åã§ãé«ã㯠cm ã§ããã追å ã®ã¢ã¤ã¹ã¯ãªã¼ã 㯠1 åã«ã¤ã 100 åã§ã1 å追å ãããã¨ã«ã¢ã¤ã¹ã¯ãªã¼ã ã¿ã¯ã¼ã®é«ãã â¦
人çã§åãã¦ããã°ã©ãã³ã°ãããã¨ãã«ãæåã«è§£ãããåé¡ã® 1 㤠åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ JOI åã® 1 å¹´åã®èº«é·ã¯ cm ã§ãã£ããJOI åã®ä»ã®èº«é·ã¯ cm ã§ããã 身é·ã¯ã©ãã ã伸ã³ããï¼ è§£æ³ èº«é·ã®ä¼¸ã³ã¯ã cm ã§ãã æ´æ°å¤ ãåãåãæ´æ°åå¤â¦
éè¨å¦çã®é¢ç½ãåé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ°å ãä¸ããããã ã«åºç¾ããæ´æ°ã®ãã¡ãåºç¾åæ°ãæå°ã§ããæ´æ°ãåºåããããã®ãããªãã®ãè¤æ°ããã¨ãã¯ããã®ãã¡ã®æå°ã®æ´æ°ãåºåããã å¶ç´ è§£æ³ ãã®ãããªåºç¾é »åº¦ã«é¢ããåé¡ã§â¦
for æãåããªãããã次ã®è¦ç´ ããåæã«è¦ã¦ããã¨ããå®è£ ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå J, O, I ãããªãé·ã ã®æåå ãä¸ããããã ã«ã¤ãã¦ã ã® æåç®ã J ã§ããã¨ãã ã® æåç®ãåºåããã å¶ç´ è§£æ³ for æãåããªããã æåç®ã®æ¬¡ã®â¦
ã·ãã¥ã¬ã¼ã·ã§ã³ãã¦ãããããæ°å¦çã«ç¶ºéºã«è§£ããã¨ãã§ããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æè¨ã¯ 1 ã 12 ãç¹°ãè¿ãã æã® æéå¾ã¯ãä½æã§ããããçããã å¶ç´ è§£æ³ (1)ï¼ã·ãã¥ã¬ã¼ã·ã§ã³ ããåºçºãã¦ã å以ä¸ã®ãã¨ãç¹°ãè¿ãã°ããã 1 å¢ããâ¦
ä¸è¦é£ããè¦ãããã©ãå®ã¯åç´ãªåé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ´æ° ã®æ¸ããã åã®å®ç®±ã¨ãæ´æ° ã®æ¸ããã åã®éµãããã å®ç®± ã¯æ´æ° ãæ¸ãããéµã使ããã¨ã§è§£é ã§ãããåãéµã使ã£ã¦è¤æ°ã®å®ç®±ã解é ãã¦ãããã 解é ã§ããå®ç®±ã®åæ°ã®æ大â¦
JOI ã¯æè²çãªåé¡ãå¤ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå A, B, C, D, E ã®ãããããããªãæåå ãä¸ããããã ã« 3 種é¡ä»¥ä¸ã®æååãç»å ´ãããªãã° Yesãããã§ãªããªãã° No ãåºåããã è§£æ³ æ¬¡ã®ãã㪠5 åã®å¤æ°ãç¨æãã¾ãããï¼ (å¤æ°â¦