<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>データセット選択メニュー - IQパズルステップ</title>
	<atom:link href="https://chokomon.com/category/paiza/16-data_structure/feed/" rel="self" type="application/rss+xml" />
	<link>https://chokomon.com</link>
	<description>ちょこっと頭を良くするIQパズル問題集</description>
	<lastBuildDate>Sun, 10 Jul 2022 20:57:19 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://chokomon.com/wp-content/uploads/2022/02/cropped-icon512-32x32.png</url>
	<title>データセット選択メニュー - IQパズルステップ</title>
	<link>https://chokomon.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【データセット選択メニュー】集合の結合 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-04-05-00463/</link>
					<comments>https://chokomon.com/16-data_structure-04-05-00463/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 20:57:19 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1600]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5621</guid>

					<description><![CDATA[【データセット選択メニュー】> FINAL問題 集合の結合 (paizaランク C 相当) [難易度: 1642 ±14] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a rel="noreferrer noopener" href="https://paiza.jp/works/mondai/data_structure/data_structure__set_boss" target="_blank">FINAL問題 集合の結合 (paizaランク C 相当)</a> [難易度: <strong>1642 ±14</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img fetchpriority="high" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-05-01.png" alt="" class="wp-image-5622"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の要素からなる数列 A, B が与えられます。A または B に含まれる値をすべて列挙し、重複を取り除いて昇順に出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>3<br>1 2 3<br>3 4 5</p>



<p><strong>出力値（例）</strong><br>1 2 3 4 5</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    $b = explode(" ", trim(fgets(STDIN)));
    
    $c = array_merge($a, $b);
    
    $delete = array_unique($c);
    sort($delete);
    
    $result = implode(" ", $delete);
    
    echo $result;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-05-02.png" alt="" class="wp-image-5623"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-04-05-00463/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】重複の判定 2 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-04-04-00462/</link>
					<comments>https://chokomon.com/16-data_structure-04-04-00462/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 20:37:32 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5616</guid>

					<description><![CDATA[【データセット選択メニュー】> 【集合の結合】STEP: 4 重複の判定 2 (paizaランク C 相当) [難易度: 1202 ±20] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__set_step4" target="_blank" rel="noreferrer noopener">【集合の結合】STEP: 4 重複の判定 2 (paizaランク C 相当)</a> [難易度: <strong>1202 ±20</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-04-01.png" alt="" class="wp-image-5617"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の要素からなる数列 A が与えられます。2 ≦ i ≦ N の各 i に対して、A_i と同じ値が A_1 から A_{i-1} の間にあるかどうかを判定してください。ただし、A_i は非常に大きくなることがあります。</p>



<p></p>



<p><strong>入力値（例）</strong><br>9<br>1 2 3 2 5 3 3 10 2</p>



<p><strong>出力値（例）</strong><br>No<br>No<br>Yes<br>No<br>Yes<br>Yes<br>No<br>Yes</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $array = explode(" ", trim(fgets(STDIN)));
    
    for($i = 1; $i &lt; $n; $i++) {
        
        $s = array_slice($array, 0, $i);
        $tail = $array[$i];
        
        if(in_array($tail, $s)) {
            echo "Yes". "\n";
        } else {
            echo "No". "\n";
        }
    }
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="350" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-04-02.png" alt="" class="wp-image-5618"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-04-04-00462/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】重複の判定 1 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-04-03-00461/</link>
					<comments>https://chokomon.com/16-data_structure-04-03-00461/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 18:57:15 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1400]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5610</guid>

					<description><![CDATA[【データセット選択メニュー】> 【集合の結合】STEP: 3 重複の判定 1 (paizaランク C 相当) [難易度: 1495 ±17] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例 解説 問題を読み解くの…]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__set_step3" target="_blank" rel="noreferrer noopener">【集合の結合】STEP: 3 重複の判定 1 (paizaランク C 相当)</a> [難易度: <strong>1495 ±17</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-03-01.png" alt="" class="wp-image-5611"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の要素からなる数列 A が与えられます。2 ≦ i ≦ N の各 i に対して、A_i と同じ値が A_1 から A_{i-1} の間にあるかどうかを判定してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>9<br>1 2 3 2 5 3 3 10 2</p>



<p><strong>出力値（例）</strong><br>No<br>No<br>Yes<br>No<br>Yes<br>Yes<br>No<br>Yes</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $array = explode(" ", trim(fgets(STDIN)));
    
    for($i = 1; $i &lt; $n; $i++) {
        
        $s = array_slice($array, 0, $i);
        $tail = $array[$i];
        
        if(in_array($tail, $s)) {
            echo "Yes". "\n";
        } else {
            echo "No". "\n";
        }
    }
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="350" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-03-02.png" alt="" class="wp-image-5612"/></figure>



<h2 class="wp-block-heading">解説</h2>



<p>問題を読み解くのに少し苦労しました。</p>



<p>入力値（例）の例でみると、</p>



<p class="has-gray-background-color has-background">9<br>1 2 3 2 5 3 3 10 2</p>



<p></p>



<p>まず、「1」と「2」が重複しているかを調べます。→　No</p>



<p>次に、「1」と「2」と「3」→　No</p>



<p>次は、「1」「2」「3」「2」で　最後の2は重複しているので　→　Yes</p>



<p>次は、「1」「2」「3」「2」「5」で　最後の5は重複していないので　→　No</p>



<p>次の「1」「2」「3」「2」「5」「3」で　最後の3が重複しているので　→　Yes...</p>



<p>と最後の数値が重複しているかを調べていきます。</p>



<p>for()文でループしながら、</p>



<pre class="wp-block-preformatted has-gray-background-color has-background">$s = array_slice($array, 0, $i);</pre>



<p></p>



<p>配列をスライスで切り取りつつ、最後の数値を$tailに入れて　in_array()で特定の値が含まれているか調べます。</p>



<p>in_array()は第1引数が探したい値、第2引数が配列で、TRUEかFALSEを返します。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-04-03-00461/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】重複の削除 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-04-02-00460/</link>
					<comments>https://chokomon.com/16-data_structure-04-02-00460/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 17:05:07 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1400]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5605</guid>

					<description><![CDATA[【データセット選択メニュー】> 【集合の結合】STEP: 2 重複の削除 (paizaランク C 相当) [難易度: 1428 ±16] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__set_step2" target="_blank" rel="noreferrer noopener">【集合の結合】STEP: 2 重複の削除 (paizaランク C 相当)</a> [難易度: <strong>1428 ±16</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-02-01.png" alt="" class="wp-image-5606"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の要素からなる数列 A が与えられます。数列 A は昇順にソートされています。A の重複した要素を取り除いて昇順に出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>6<br>1 2 3 3 4 5</p>



<p><strong>出力値（例）</strong><br>1 2 3 4 5</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $array = explode(" ", trim(fgets(STDIN)));
    
    $delete = array_unique($array);
    
    $result = implode(" ", $delete);
    
    echo $result;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-02-02.png" alt="" class="wp-image-5607"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-04-02-00460/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】集合の探索 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-04-01-00459/</link>
					<comments>https://chokomon.com/16-data_structure-04-01-00459/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 02:34:13 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5600</guid>

					<description><![CDATA[【データセット選択メニュー】> 【集合の結合】STEP: 1 集合の探索 (paizaランク C 相当) [難易度: 1206 ±19] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__set_step1" target="_blank" rel="noreferrer noopener">【集合の結合】STEP: 1 集合の探索 (paizaランク C 相当)</a> [難易度: <strong>1206 ±19</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-01-01.png" alt="" class="wp-image-5601"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の要素からなる数列 A と、整数 B が与えられます。B が A に含まれているかどうかを判定してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5 4<br>1 2 3 4 5</p>



<p><strong>出力値（例）</strong><br>Yes</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $b) = explode(" ", trim(fgets(STDIN)));
    $array = explode(" ", trim(fgets(STDIN)));
    
    $flag = false;
    
    foreach($array as $value) {
        if($value == $b) {
            $flag = true;
            break;
        }
    }
    echo ($flag) ? "Yes" : "No";
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/07/16-04-01-02.png" alt="" class="wp-image-5602"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-04-01-00459/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】商品の検索 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-03-05-00458/</link>
					<comments>https://chokomon.com/16-data_structure-03-05-00458/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 10 Jul 2022 00:23:51 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1400]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5595</guid>

					<description><![CDATA[【データセット選択メニュー】> FINAL問題 商品の検索 (paizaランク C 相当) [難易度: 1467 ±14] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a rel="noreferrer noopener" href="https://paiza.jp/works/mondai/data_structure/data_structure__dict_boss" target="_blank">FINAL問題 商品の検索 (paizaランク C 相当)</a> [難易度: <strong>1467 ±14</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-05-01.png" alt="" class="wp-image-5596"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>N 個の文字列 S_1, ... , S_N と、Q 個の文字列 T_1, ... , T_Q が与えられます。各 T_i について、以下の処理を行ってください。</p>



<p>・ S_j == T_i を満たす最小の j を出力する。ただし、そのような j が存在しない場合は -1 を出力する。</p>



<p></p>



<p><strong>入力値（例）</strong><br>3 2<br>a<br>b<br>c<br>b<br>d</p>



<p><strong>出力値（例）</strong><br>2<br>-1</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $q) = explode(" ", trim(fgets(STDIN)));
    
    for($i = 0; $i &lt; $n; $i++) {
        $s = trim(fgets(STDIN));
        
        if(isset($array[$s]) == false) {
            $array[$s] = $i + 1;
        } 
    }

    for($i = 0; $i &lt; $q; $i++) {
        $item = trim(fgets(STDIN));
        
        if(isset($array[$item])) {
            echo $array[$item]. "\n";
        } else {
            echo (-1). "\n";
        }
    }
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="200" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-05-02.png" alt="" class="wp-image-5597"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-03-05-00458/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】価格の算出 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-03-04-00457/</link>
					<comments>https://chokomon.com/16-data_structure-03-04-00457/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sat, 09 Jul 2022 23:54:53 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1300]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5590</guid>

					<description><![CDATA[【データセット選択メニュー】> 【商品の検索】STEP: 4 価格の算出 (paizaランク C 相当) [難易度: 1305 ±17] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__dict_step4" target="_blank" rel="noreferrer noopener">【商品の検索】STEP: 4 価格の算出 (paizaランク C 相当)</a> [難易度: <strong>1305 ±17</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-04-01.png" alt="" class="wp-image-5591"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>paiza 商店では N 個の商品が売られており、i 番目の商品の名前は A_i で、価格は B_i です。<br>あなたは M 個の商品名が書かれたお買い物リスト S を持っています。リストに書かれているそれぞれの商品について、paiza 商店での価格を出力してください。リストには paiza 商店が扱っていない商品も書かれている可能性がありますが、その場合は価格の代わりに -1 を出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>3 4<br>eraser 50<br>pencil 30<br>book 100<br>book<br>eraser<br>pencil<br>margaret</p>



<p><strong>出力値（例）</strong><br>100<br>50<br>30<br>-1</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $m) = explode(" ", trim(fgets(STDIN)));
    
    for($i = 0; $i &lt; $n; $i++) {
        list($item, $price) = explode(" ", trim(fgets(STDIN)));
        $items[$item] = $price;
    }
    
    for($i = 0; $i &lt; $m; $i++) {
        $s_item = trim(fgets(STDIN));
        
        if(isset($items[$s_item])) {
            echo $items[$s_item]. "\n";
        } else {
            echo (-1). "\n";
        }
    }
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="240" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-04-02.png" alt="" class="wp-image-5592"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-03-04-00457/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】文字列の出現率 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-03-03-00456/</link>
					<comments>https://chokomon.com/16-data_structure-03-03-00456/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sat, 09 Jul 2022 21:08:45 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1400]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5585</guid>

					<description><![CDATA[【データセット選択メニュー】> 【商品の検索】STEP: 3 文字列の出現率 (paizaランク C 相当) [難易度: 1452 ±16] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__dict_step3" target="_blank" rel="noreferrer noopener">【商品の検索】STEP: 3 文字列の出現率 (paizaランク C 相当)</a> [難易度: <strong>1452 ±16</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-03-01.png" alt="" class="wp-image-5586"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>文字列が N 個与えられます。各文字列の出現回数を文字列の辞書順に出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5<br>bcd<br>abc<br>bcd<br>bcd<br>bcd</p>



<p><strong>出力値（例）</strong><br>abc 1<br>bcd 4</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    
    $array = [];
    
    for($i = 0; $i &lt; $n; $i++) {
        $str = trim(fgets(STDIN));
        
        if(isset($array[$str])) {
            $array[$str] += 1;
            
        } else {
            $array[$str] = 1;
        }
    }

    ksort($array);
    
    foreach($array as $key =&gt; $value) {
        echo $key. " ". $value. "\n";
    }
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="200" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-03-02.png" alt="" class="wp-image-5587"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-03-03-00456/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】英小文字の出現率 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-03-02-00455/</link>
					<comments>https://chokomon.com/16-data_structure-03-02-00455/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sat, 09 Jul 2022 19:07:30 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1300]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5579</guid>

					<description><![CDATA[【データセット選択メニュー】> 【商品の検索】STEP: 2 英小文字の出現率 (paizaランク C 相当) [難易度: 1361 ±17] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例 解説 ①　$coun…]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__dict_step2" target="_blank" rel="noreferrer noopener">【商品の検索】STEP: 2 英小文字の出現率 (paizaランク C 相当)</a> [難易度: <strong>1361 ±17</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-02-01.png" alt="" class="wp-image-5580"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>長さ N の文字列 S が与えられます。S に含まれている各文字の出現回数をそれぞれ求め、「a」の出現回数、「b」の出現回数、...、「z」の出現回数をこの順に半角スペース区切りで1行に出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>13<br>aaabbbccdddde</p>



<p><strong>出力値（例）</strong><br>3 3 2 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $a = range('a', 'z');
    $count = array_fill_keys($a, 0);
    //print_r($count);
    
    $n = trim(fgets(STDIN));
    $str = trim(fgets(STDIN));
    
    for($i = 0; $i &lt; $n; $i++) {
        $count[$str[$i]] += 1;
    }
    
    $ans = implode(" ", $count);
    
    echo $ans;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-02-02.png" alt="" class="wp-image-5581"/></figure>



<h2 class="wp-block-heading">解説</h2>



<p>①　$count()という配列にaからzまでのキーで0をセットします。</p>



<p class="has-gray-background-color has-background">　　array_fill_keys(keys, value)</p>



<p></p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$a = range('a', 'z');
$count = array_fill_keys($a, 0);</pre></div>



<p></p>



<p>出力</p>



<p class="has-gray-background-color has-background">Array <br>(    <br> [a] => 0    <br> [b] => 0   <br> [c] => 0  <br> [d] => 0     <br> [e] => 0    <br> [f] => 0    <br> [g] => 0    <br> [h] => 0    <br> [i] => 0    <br> [j] => 0    <br> [k] => 0    <br> [l] => 0    <br> [m] => 0    <br> [n] => 0    <br> [o] => 0    <br> [p] => 0    <br> [q] => 0    <br> [r] => 0    <br> [s] => 0    <br> [t] => 0    <br> [u] => 0    <br> [v] => 0    <br> [w] => 0    <br> [x] => 0    <br> [y] => 0    <br> [z] => 0 <br>)</p>



<p></p>



<p>②　入力値を受け取ります。</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$n = trim(fgets(STDIN));
$str = trim(fgets(STDIN));</pre></div>



<p></p>



<p>③　for()文で$i =0; $i &lt; $n;回ループします。</p>



<p>配列の$countの$str[$i]（$str[$i]は例えば$str[0]はa）、つまり$count[a]には+=1を足します。</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">for($i = 0; $i &lt; $n; $i++) {
    $count[$str[$i]] += 1;
}</pre></div>



<p></p>



<p>④　implode()で配列$countを分割します。echoで出力します。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-03-02-00455/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【データセット選択メニュー】数値の出現率 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/16-data_structure-03-01-00454/</link>
					<comments>https://chokomon.com/16-data_structure-03-01-00454/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sat, 09 Jul 2022 17:47:17 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[データセット選択メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=5574</guid>

					<description><![CDATA[【データセット選択メニュー】> 【商品の検索】STEP: 1 数値の出現率 (paizaランク C 相当) [難易度: 1269 ±17] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/16-data_structure/">データセット選択メニュー</a>】> <a href="https://paiza.jp/works/mondai/data_structure/data_structure__dict_step1" target="_blank" rel="noreferrer noopener">【商品の検索】STEP: 1 数値の出現率 (paizaランク C 相当)</a> [難易度: <strong>1269 ±17</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-01-01.png" alt="" class="wp-image-5575"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>0 以上 9 以下の整数が N 個与えられます。各数値の出現回数を求め、「0」の出現回数、「1」の出現回数、...「9」の出現回数、をこの順に半角スペース区切りで1行に出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5<br>1 2 3 3 6</p>



<p><strong>出力値（例）</strong><br>0 1 1 2 0 0 1 0 0 0</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $number = explode(" ", trim(fgets(STDIN)));
    
    $count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    
    for($i = 0; $i &lt; $n; $i++) {
        $count[$number[$i]] += 1;
    }
    
    $result = implode(" ", $count);
    
    echo $result;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/07/16-03-01-02.png" alt="" class="wp-image-5576"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/16-data_structure-03-01-00454/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
