Logo
(追記) (追記ここまで)

30611번 - Course Prerequisites 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 1024 MB103836379.747%

문제

As a student at a university, you want to choose a set of courses for the next semester. Each course may or may not have a set of prerequisite courses. Therefore, before making your final decision, you want to ensure that you have satisfied all the prerequisites required for the courses you intend to take.

For instance, suppose a student has successfully completed courses courseA, courseB, courseC, courseE, courseG, and courseH. The course she wishes to enroll in has specific prerequisites, namely courseA, courseC, and courseG. In this scenario, the student meets the prerequisites because she has already completed all of them - courseA, courseC, and courseG.

입력

The first line of the input contains a single integer m, the size of set A (1 ≤ m ≤ 500,000). The second line of input contains the courses of set A separated by spaces. The third line of the input contains a single integer n, the size of set B (1 ≤ n ≤ 500,000). The fourth line of input contains the courses of set B separated by spaces.

All courses are strings. It is guaranteed that each string given contains at most 10 characters, and only consists of alphanumeric characters. The size of the input data is guaranteed to not exceed 5 megabytes.

출력

Output 0 if prerequisites are not satisfied, else 1 if prerequisites are satisfied.

제한

예제 입력 1

5
CourseA CourseB CourseC CourseD CourseE
2
CourseC CourseD

예제 출력 1

1

예제 입력 2

6
CourseA CourseB CourseD CourseE CourseO CourseI
4
CourseD CourseE CourseO CourseG

예제 출력 2

0

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > Greek Collegiate Programming Contest > GRCPC 2023 3번

  • 문제의 잘못된 점을 전체적으로 찾은 사람: hjroh0315
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /