fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
백준 33651 (C++) Vandalism
최초 업로드: 2025-03-28 15:26:48
최근 수정 시간: 2025-07-25 10:07:57
게시자: rlatjwls3333
카테고리: 백준
조회수: 13
# [Bronze IV] Vandalism [문제 링크](https://www.acmicpc.net/problem/33651) ## 문제 설명 <p>In recent weeks, the United Association against Property Crime (UAPC) sign has been repeatedly vandalized. Vandals remove some of the letters from <code>UAPC</code> to form an acronym of their choosing. For example, last month, the Unauthorized Art Collective (UAC) removed the letter <code>P</code>.</p> <p>The UAPC is tired of manually determining which letters have been lost and need replacement. They have tasked you with creating an algorithm to automatically identify the missing letters.</p> ## 입력 <p>The first line of input contains a string $s$ of length at most $3$. It is guaranteed that $s$ is non-empty and can be obtained by removing some characters from <code>UAPC</code>, while preserving the order of the remaining letters. It is guaranteed that at least one character has been removed.</p> ## 출력 <p>Output a string consisting of the characters removed from <code>UAPC</code> to obtain $s$, listed in the order they appear in <code>UAPC</code>.</p> ## 풀이 #### 입력으로는 UAPC에서 1개 이상의 임의의 문자가 제거된 후 그대로 들어옵니다. #### UAPC 순서대로 각 문자가 입력으로 들어왔는지 확인한 후 출력하면 됩니다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; string ans="UAPC"; for(int i=0;i<4;i++) { if(ans[i]!=s[i]) { // 문자가 들어오지 않았다면 cout << ans[i]; // 출력 s.insert(s.begin()+i, ans[i]); // 입력된 문자열에 해당 문자 추가 } } } ```