// 더 많은 정보는 42jerrykim.github.io 에서 확인하세요.
#include<bits/stdc++.h>usingnamespacestd;intmain(){ios::sync_with_stdio(false);cin.tie(nullptr);strings;if(!(cin>>s))return0;stringt="UAPC",removed;size_tj=0;for(charc:t){if(j<s.size()&&c==s[j])j++;elseremoved.push_back(c);}cout<<removed;return0;}
구현 (Python)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 더 많은 정보는 42jerrykim.github.io 에서 확인하세요.importsysdefsolve():s=sys.stdin.readline().strip()t="UAPC"j=0removed=[]forcint:ifj<len(s)ands[j]==c:j+=1else:removed.append(c)print("".join(removed))if__name__=="__main__":solve()