๐Ÿ‘ฉ‍๐Ÿ’ปProgramming/Coding Test

[C#] [BOJ#1920] ์ˆ˜ ์ฐพ๊ธฐ

taesooya 2022. 8. 13. 16:43

https://www.acmicpc.net/problem/1920

 

1920๋ฒˆ: ์ˆ˜ ์ฐพ๊ธฐ

์ฒซ์งธ ์ค„์— ์ž์—ฐ์ˆ˜ N(1 ≤ N ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ ์ค„์—๋Š” N๊ฐœ์˜ ์ •์ˆ˜ A[1], A[2], …, A[N]์ด ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ ์ค„์—๋Š” M(1 ≤ M ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ ์ค„์—๋Š” M๊ฐœ์˜ ์ˆ˜๋“ค์ด ์ฃผ์–ด์ง€๋Š”๋ฐ, ์ด ์ˆ˜๋“ค

www.acmicpc.net

 

 

My Solution


using System;
using System.Linq;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            // ์ฒซ์งธ ์ค„ : N๊ฐœ์˜ ๋ฐฐ์—ด 1
            // ์„ธ๋ฒˆ์งธ ์ค„ : M ๊ฐœ์˜ ๋ฐฐ์—ด 2

            int[] arrA = new int[int.Parse(Console.ReadLine())];
            arrA = Array.ConvertAll<string, int>(Console.ReadLine().Split(), int.Parse);
            int[] arrB = new int[int.Parse(Console.ReadLine())];
            arrB = Array.ConvertAll<string, int>(Console.ReadLine().Split(), int.Parse);

            foreach (int i in arrB)
            {

                if (arrA.Contains(i))
                    sb.Append(1 + "\\n");
                else sb.Append(0 + "\\n");
            }
            Console.WriteLine(sb);

        }
    }
}
โ€‹