๐ฉ๐ป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);
}
}
}
โ