diff --git a/prob1.cpp "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob1.cpp" similarity index 100% rename from prob1.cpp rename to "\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob1.cpp" diff --git a/prob2.cpp "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob2.cpp" similarity index 100% rename from prob2.cpp rename to "\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob2.cpp" diff --git a/prob3.cpp "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob3.cpp" similarity index 100% rename from prob3.cpp rename to "\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob3.cpp" diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob4.cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob4.cpp" new file mode 100644 index 0000000..f8f2203 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob4.cpp" @@ -0,0 +1,129 @@ +#include +#include +#include +using namespace std; +int N; //ÁöµµÀÇ Å©±â +int color = 1; //´ë·úÀÇ °³¼ö +vector> map; +vector> continent_color; +int dir_x[4] = { 0, 0, -1, 1 }; //»ó ÇÏ Á ¿ì +int dir_y[4] = { 1, -1, 0, 0 }; +void obeserveContinent() //¼­·Î ´Ù¸¥ ´ë·úÀ» ±¸º°Çϱâ À§ÇØ ´Ù¸¥ »öÀ¸·Î »öÄ¥ÇÏ´Â ÇÔ¼ö +{ + continent_color.resize(N, vector(N)); + queue> q; + + for (int i = 0; i < N; i++) + { + for (int j = 0; j < N; j++) + { + if (map[i][j] == 1 && continent_color[i][j] == 0) + { + q.push(make_pair(i, j)); + continent_color[i][j] = color; //¹æ¹®ÇßÀ½ Ç¥½Ã, ´ë·úÀ» »öÄ¥ÇÏ¿© ´Ù¸¥ ´ë·úÀ» ±¸ºÐÇϱâ + while (!q.empty()) + { + int x = q.front().first; + int y = q.front().second; + q.pop(); + for (int k = 0; k < 4; k++) + { + int new_x = x + dir_x[k]; + int new_y = y + dir_y[k]; + if (0 <= new_x && new_x < N && 0 <= new_y && new_y < N) + { + if (continent_color[new_x][new_y] == 0 && map[new_x][new_y] == 1) + { + q.push(make_pair(new_x, new_y)); + continent_color[new_x][new_y] = color; //¹æ¹®ÇßÀ½ Ç¥½Ã, ´ë·úÀ» »öÄ¥ÇÏ¿© ´Ù¸¥ ´ë·úÀ» ±¸ºÐÇϱâ + } + } + } + } + color++; + } + } + } + return; +} +int calculate_min_distance(int color) +{ + for (int i = 0; i < N; i++) //Áöµµ¸¦ 0À¸·Î ÃʱâÈ­ + { + for (int j = 0; j < N; j++) + { + map[i][j] = 0; + } + } + queue> q; + for (int i = 0; i < N; i++) + { + for (int j = 0; j < N; j++) + { + if (continent_color[i][j] == color) //´ë·ú°ú ÀÎÁ¢ÇÑ ¹Ù´Ù Ä­À» Å¥¿¡ ³ÖÀ» °ÍÀÓ + { + for (int k = 0; k < 4; k++) + { + int new_x = i + dir_x[k]; + int new_y = j + dir_y[k]; + if (0 <= new_x && new_x < N && 0 <= new_y && new_y < N) + { + if (continent_color[new_x][new_y] == 0) + { + q.push(make_pair(new_x, new_y)); + map[new_x][new_y] = 1; //´ë·ú¿¡¼­ ÇØ´ç Ä­±îÁö À̵¿ÇÏ´Â µ¥ ÇÊ¿äÇÑ °Å¸® + } + } + } + } + } + } + int count = 100000; + while (!q.empty()) + { + int x = q.front().first; + int y = q.front().second; + q.pop(); + for (int k = 0; k < 4; k++) + { + int new_x = x + dir_x[k]; + int new_y = y + dir_y[k]; + if (0 <= new_x && new_x < N && 0 <= new_y && new_y < N) + { + if (continent_color[new_x][new_y] == 0 && map[new_x][new_y] == 0) + { + q.push(make_pair(new_x, new_y)); + map[new_x][new_y] = map[x][y] + 1; //ÇØ´ç Ä­±îÁö µµÂøÇϴµ¥ ÇÊ¿äÇÑ °Å¸® ±¸Çϱâ + } + if (continent_color[new_x][new_y] != color && continent_color[new_x][new_y] != 0 && count > map[x][y]) + { + count = map[x][y]; + } + } + } + } + return count; +} +int main() +{ + + cin >> N; + map.resize(N, vector(N)); //2Â÷¿ø º¤ÅÍ ÃʱâÈ­ + + for (int i = 0; i < N; i++) //Áöµµ µ¥ÀÌÅÍ ÀÔ·Â ¹Þ±â + { + for (int j = 0; j < N; j++) + { + cin >> map[i][j]; + } + } + obeserveContinent(); //´ë·úÀ» ¼­·Î ´Ù¸¥ »öÀ¸·Î »öÄ¥ÇÔ + int min = calculate_min_distance(1); + for (int i = 2; i < color; i++) + { + int result = calculate_min_distance(i); + if (min > result) + min = result; + } + cout << min; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5(fix).cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5(fix).cpp" new file mode 100644 index 0000000..43d1292 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5(fix).cpp" @@ -0,0 +1,46 @@ +#include +#include +using namespace std; +pair tree[26]; //¿ÞÂÊ Àڽİú ¿À¸¥ÂÊ ÀÚ½ÄÀ» ÀúÀåÇÒ ¼ö ÀÖ´Â ¾ËÆÄ¹î Æ®¸® »ý¼º +void preorder(char root) //ÀüÀ§ ¼øÈ¸ root-left-right +{ + if (root == '.') + return; + cout << root; + preorder(tree[root - 'A'].first); + preorder(tree[root - 'A'].second); +} +void inorder(char root) //ÁßÀ§ ¼øÈ¸ left-root-right +{ + if (root == '.') + return; + inorder(tree[root - 'A'].first); + cout << root; + inorder(tree[root - 'A'].second); +} +void postorder(char root) //ÈÄÀ§ ¼øÈ¸ left-right-root +{ + if (root == '.') + return; + postorder(tree[root - 'A'].first); + postorder(tree[root - 'A'].second); + cout << root; +} +int main() +{ + int N; //Æ®¸®ÀÇ ³ëµå °³¼ö + cin >> N; + for (int i = 0; i < N; i++) //Æ®¸® Á¤º¸ ÀÔ·Â ¹Þ±â + { + char root, left, right; //ÀÔ·Â 1,2,3 + cin >> root >> left >> right; + tree[root - 'A'].first = left; + tree[root - 'A'].second = right; + } + preorder('A'); + cout << '\n'; + inorder('A'); + cout << '\n'; + postorder('A'); + return 0; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5.cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5.cpp" new file mode 100644 index 0000000..8bb0e39 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob5.cpp" @@ -0,0 +1,48 @@ +#include +#include +using namespace std; +pair tree[26]; //¿ÞÂÊ Àڽİú ¿À¸¥ÂÊ ÀÚ½ÄÀ» ÀúÀåÇÒ ¼ö ÀÖ´Â ¾ËÆÄ¹î Æ®¸® »ý¼º +void preorder(char root) //ÀüÀ§ ¼øÈ¸ root-left-right +{ + if (root == '.') + return; + cout << root; + preorder(tree[root - 'A'].first); + preorder(tree[root - 'A'].second); +} +void inorder(char root) //ÁßÀ§ ¼øÈ¸ left-root-right +{ + if (tree[root - 'A'].first != '.') + inorder(tree[root - 'A'].first); + cout << root; + if (tree[root - 'A'].second != '.') + inorder(tree[root - 'A'].second); + return; +} +void postorder(char root) //ÈÄÀ§ ¼øÈ¸ left-right-root +{ + if (tree[root - 'A'].first != '.') + postorder(tree[root - 'A'].first); + if (tree[root - 'A'].second != '.') + postorder(tree[root - 'A'].second); + cout << root; + return; +} +int main() +{ + int N; //Æ®¸®ÀÇ ³ëµå °³¼ö + cin >> N; + for (int i = 0; i < N; i++) //Æ®¸® Á¤º¸ ÀÔ·Â ¹Þ±â + { + char root, left, right; //ÀÔ·Â 1,2,3 + cin >> root >> left >> right; + tree[root - 'A'].first = left; + tree[root - 'A'].second = right; + } + preorder('A'); + cout << '\n'; + inorder('A'); + cout << '\n'; + postorder('A'); + return 0; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob6.cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob6.cpp" new file mode 100644 index 0000000..d73f5b4 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob6.cpp" @@ -0,0 +1,38 @@ +#include +#include +using namespace std; +vector graph[100001]; +bool visited[100001]; +int parent[100001]; +int N; +void DFS(int root) +{ + visited[root] = 1; + for (int i = 0; i < graph[root].size(); i++) //¿¬°áµÈ ³ëµå ²¨³»¿À±â + { + int V = graph[root][i]; + if (!visited[V]) //¹æ¹®ÇÏÁö ¾ÊÀº ³ëµå + { + parent[V] = root; + DFS(V); + } + } + return; +} +int main() +{ + cin >> N; + for (int i = 0; i < N - 1; i++) + { + int v1, v2; + cin >> v1 >> v2; + graph[v1].push_back(v2); //Á¤Á¡ v1°ú v2ÀÇ ¿¬°áÀ» ÀÇ¹Ì + graph[v2].push_back(v1); //¹Ý´ë·Îµµ ¿¬°á + } + DFS(1); + for (int i = 2; i <= N; i++) + { + cout << parent[i] << '\n'; + } + return 0; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob7.cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob7.cpp" new file mode 100644 index 0000000..f5c0351 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob7.cpp" @@ -0,0 +1,50 @@ +#include +#include +using namespace std; +vector> graph[100001]; +bool visited[100001]; +int leaf, max_d; +void DFS(int root, int dist) +{ + visited[root] = 1; + for (int i = 0; i < graph[root].size(); i++) //¿¬°áµÈ ³ëµå ²¨³»¿À±â + { + int V = graph[root][i].first; + int d = graph[root][i].second; + if (!visited[V]) //¹æ¹®ÇÏÁö ¾ÊÀº ³ëµå + { + DFS(V, dist + d); + } + } + if (dist > max_d) + { + leaf = root; + max_d = dist; + } + return; +} +int main() +{ + int N; + cin >> N; + for (int i = 1; i <= N; i++) // 1 ~ N Á¤Á¡ + { + int v1, v2, dist; + cin >> v1; + while (1) //-1ÀÌ ÀÔ·ÂµÉ ¶§ ±îÁö ¿¬°áµÈ Á¤Á¡ÀÇ Á¤º¸ ÀԷ¹ޱâ + { + cin >> v2; + if (v2 == -1) + break; + cin >> dist; + graph[v1].push_back(make_pair(v2, dist)); + } + } + DFS(1, 0); //¸®ÇÁ³ëµå ã±â + for (int j = 1; j <= N; j++) //visied ¹è¿­ ÃʱâÈ­ + visited[j] = 0; + max_d = 0; //ÃÖ´ë°ª ÃʱâÈ­ + DFS(leaf, 0); //¸®ÇÁ³ëµå¿¡¼­ DFSÇϱâ + cout << max_d; + return 0; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob8.cpp" "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob8.cpp" new file mode 100644 index 0000000..7017d37 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\352\267\270\353\236\230\355\224\204)/prob8.cpp" @@ -0,0 +1,45 @@ +#include +#include +using namespace std; +vector> graph[10001]; +bool visited[10001]; +int leaf, max_d; +void DFS(int root, int dist) +{ + visited[root] = 1; + for (int i = 0; i < graph[root].size(); i++) //¿¬°áµÈ ³ëµå ²¨³»¿À±â + { + int V = graph[root][i].first; + int d = graph[root][i].second; + if (!visited[V]) //¹æ¹®ÇÏÁö ¾ÊÀº ³ëµå + { + DFS(V, dist + d); + } + } + if (dist > max_d) + { + leaf = root; + max_d = dist; + } + return; +} +int main() +{ + int N; + cin >> N; + for (int i = 0; i < N - 1; i++) // 1 ~ N Á¤Á¡ + { + int v1, v2, dist; + cin >> v1 >> v2 >> dist; + graph[v1].push_back(make_pair(v2, dist)); + graph[v2].push_back(make_pair(v1, dist)); + + } + DFS(1, 0); //¸®ÇÁ³ëµå ã±â + for (int j = 1; j <= N; j++) //visied ¹è¿­ ÃʱâÈ­ + visited[j] = 0; + max_d = 0; //ÃÖ´ë°ª ÃʱâÈ­ + DFS(leaf, 0); //¸®ÇÁ³ëµå¿¡¼­ DFSÇϱâ + cout << max_d; + return 0; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob1.cpp" "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob1.cpp" new file mode 100644 index 0000000..a191b50 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob1.cpp" @@ -0,0 +1,39 @@ +#include +#include +using namespace std; +int main() +{ + int LAN[10001]; + int K; //óÀ½ °¡Áö°í ÀÖ´Â ·£¼± ¼ö (10000ÀÌÇÏ) + int N; //¸¸µé¾î¾ß ÇÏ´Â ·£¼± ¼ö + long long result = 0; //Á¶°ÇÀ» ¸¸Á·ÇÏ´Â ·£¼±ÀÇ ÃÖ´ë ±æÀÌ + int MAX_LAN = 0; //°¡Áö°í ÀÖ´Â ·£¼± Áß ÃÖ°í°ª + cin >> K >> N; + for (int i = 0; i < K; i++) + { + cin >> LAN[i]; + MAX_LAN = max(MAX_LAN, LAN[i]); + } + long long left = 1; + long long right = MAX_LAN; + long long mid; + while (left <= right) + { + mid = (right + left) / 2; + int count = 0; + for (int i = 0; i < K; i++) + { + count += LAN[i] / mid; + } + if (count >= N) + { + left = mid + 1; + result = max(result, mid); + } + else + { + right = mid - 1; + } + } + cout << result; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob2.cpp" "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob2.cpp" new file mode 100644 index 0000000..7824143 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob2.cpp" @@ -0,0 +1,40 @@ +#include +#include +using namespace std; +int main() +{ + int tree[10001]; + int N; //º§ ¼ö ÀÖ´Â ³ª¹«ÀÇ ¼ö + int M; //ÁýÀ¸·Î °¡Á®°¡·Á´Â ³ª¹«ÀÇ ±æÀÌ + int result = 0; //Àý´Ü±â¿¡ ¼³Á¤ÇÒ ¼ö ÀÖ´Â ÃÖ´ë ³ôÀÌ + int max_tree = 0; //º§ ¼ö ÀÖ´Â ³ª¹« Áß °¡Àå ³ôÀº ³ª¹« + cin >> N >> M; + for (int i = 0; i < N; i++) + { + cin >> tree[i]; + max_tree = max(max_tree, tree[i]); + } + int left = 0; //´Ù º£¾îºñ°Ú´Ù. + int right = max_tree - 1; // °¡Àå ³ôÀº ³ª¹«µé¸¸ 1m¾¿ º¥´Ù. + int mid; + while (left <= right) + { + mid = (right + left) / 2; + long long count = 0; + for (int i = 0; i < N; i++) + { + if (tree[i] > mid) + count += tree[i] - mid; //º£¾î¼­ ¾òÀº ³ª¹« + } + if (count >= M) //Àý´Ü±â ³ôÀÌÀÇ ´õ Å« °ªÀ» ¾ò±â À§ÇÔ + { + left = mid + 1; + result = max(result, mid); + } + else //Á¶°ÇÀ» ÃæÁ·Çϱâ À§Çؼ­ ³ôÀ̸¦ ³·Ãã + { + right = mid - 1; + } + } + cout << result; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob3.cpp" "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob3.cpp" new file mode 100644 index 0000000..503e28c --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob3.cpp" @@ -0,0 +1,43 @@ +#include +#include +using namespace std; +int main() +{ + int House[10001]; //ÁýÀÇ ÁÂÇ¥ ÀúÀå + int N; //°øÀ¯±â¸¦ ¼³Ä¡ÇÒ ¼ö ÀÖ´Â ÁýÀÇ °³¼ö + int C; //¼³Ä¡ÇØ¾ß ÇÏ´Â °øÀ¯±âÀÇ ¼ö + int result = 0; //°¡Àå ÀÎÁ¢ÇÑ °øÀ¯±â »çÀÌÀÇ ÃÖ´ë °Å¸® + cin >> N >> C; + for (int i = 0; i < N; i++) + { + cin >> House[i]; + } + sort(House, House + N); //¿À¸§Â÷¼øÀ¸·Î Á¤·Ä + int left = 1; //ÃÖ¼Ò °Å¸® + int right = House[N - 1] - House[0]; // ÃÖ´ë °Å¸®(¸¶Áö¸· Áý - ù ¹øÂ° Áý) + int mid; + while (left <= right) + { + mid = (right + left) / 2; + int count = 1; //ù ¹øÂ° Áý¿¡ °øÀ¯±â ¼³Ä¡ + int lastRoute = House[0]; //¸¶Áö¸·¿¡ ¼³Ä¡ÇÑ °øÀ¯±âÀÇ À§Ä¡ + for (int i = 0; i < N; i++) + { + if (House[i] - lastRoute >= mid) //¼³Á¤ÇÑ ÃÖ´ë °Å¸® ÀÌ»óÀÎ °÷¿¡ °øÀ¯±â¸¦ ¼³Ä¡Çϱâ + { + lastRoute = House[i]; + count++; + } + } + if (count >= C) //ÃÖÀûÀÇ °ªÀ» ã±âÀ§ÇØ ´õ Ž»ö + { + left = mid + 1; + result = max(result, mid); + } + else //Á¶°ÇÀ» ¸¸Á·ÇÏ´Â ´äÀ» ã±â À§ÇØ ´õ Ž»ö + { + right = mid - 1; + } + } + cout << result; +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob4.cpp" "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob4.cpp" new file mode 100644 index 0000000..d1efccc --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob4.cpp" @@ -0,0 +1,46 @@ +#include +#include +using namespace std; +int main() +{ + int list[10001]; //°¡Áö°í ÀÖ´Â Ä«µå ÀúÀå + int N; //°¡Áö°í ÀÖ´Â Ä«µåÀÇ ¼ö + int M; //°¡Áö°í ÀÖ´Â Áö È®ÀÎÇØ¾ß ÇÏ´Â Ä«µåÀÇ ¼ö + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + cin >> N; + for (int i = 0; i < N; i++) + { + cin >> list[i]; + } + sort(list, list + N); //¿À¸§Â÷¼øÀ¸·Î Á¤·Ä + cin >> M; + int card; + int mid; + for (int i = 0; i < M; i++) + { + int left = 0; + int right = N - 1; + cin >> card; //°¡Áö°í ÀÖ´Â Áö È®ÀÎÇØ¾ß ÇÏ´Â Ä«µå + bool found = 0; + while (left <= right) + { + mid = (right + left) / 2; + if (list[mid] < card) //ã°í ÀÖ´Â °ªÀÌ Ä¿¼­ mid ¿À¸¥ÂÊ¿¡¼­ ã¾Æ¾ßÇÔ + { + left = mid + 1; + } + else if (list[mid] == card) //ã¾Ò´Ù. + { + found = 1; + break; + } + else //ã°í ÀÖ´Â °ªÀÌ À۾Ƽ­ mid ¿ÞÂÊ¿¡¼­ ã¾Æ¾ßÇÔ + { + right = mid - 1; + } + } + cout << found << " "; + } +} \ No newline at end of file diff --git "a/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob5.cpp" "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob5.cpp" new file mode 100644 index 0000000..96f98e6 --- /dev/null +++ "b/\354\235\264\352\260\225\353\257\274(\354\235\264\353\266\204\355\203\220\354\203\211)/prob5.cpp" @@ -0,0 +1,26 @@ +#include +#include +#include +using namespace std; +int main() +{ + map map;//°¡Áö°í ÀÖ´Â Ä«µå ÀúÀå + int N; //°¡Áö°í ÀÖ´Â Ä«µåÀÇ ¼ö + int M; //°¡Áö°í ÀÖ´Â Áö È®ÀÎÇØ¾ß ÇÏ´Â Ä«µåÀÇ ¼ö + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + cin >> N; + int card; + for (int i = 0; i < N; i++) + { + cin >> card; + map[card]++; + } + cin >> M; + for (int i = 0; i < M; i++) + { + cin >> card; //°¡Áö°í ÀÖ´Â Áö È®ÀÎÇØ¾ß ÇÏ´Â Ä«µå + cout << map[card] << " "; + } +} \ No newline at end of file