fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
AtCoder Beginner Contest 421-A (C++) Misdelivery
최초 업로드: 2025-08-30 14:11:34
최근 수정 시간: 2025-08-30 14:12:03
게시자: rlatjwls3333
카테고리: Atcoder
조회수: 9
# A - Misdelivery [문제 링크](https://atcoder.jp/contests/abc421/tasks/abc421_a) ## Problem Statement Mansion AtCoder has \$N\$ rooms numbered from room \$1\$ to room \$N\$. Each room \$i\$ is inhabited by one person named \$S\_i\$. You are to deliver a package addressed to Mr./Ms. \$Y\$ in room \$X\$. Determine whether the destination is correct. ## Constraints * \$1 \le N \le 100\$ * \$1 \le X \le N\$ * \$N\$ and \$X\$ are integers. * \$S\_i\$ and \$Y\$ are strings consisting of lowercase English letters with length between \$1\$ and \$10\$, inclusive. ## Input The input is given from Standard Input in the following format: \$N\$ \$S\_1\$ \$S\_2\$ \$\vdots\$ \$S\_N\$ \$X\ \ Y\$ ## Output Print `Yes` if the name of the person living in room \$X\$ is \$Y\$, and `No` otherwise. ## 풀이 x번째 인덱스에 저장된 문자열이 Y과 같은지 확인하였다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<string> v(n); for(int i=0;i<n;i++) cin >> v[i]; int idx; string s; cin >> idx >> s; if(v[idx-1].compare(s)==0) cout << "Yes"; else cout << "No"; } ```