传统题 400ms 64MiB

2023春-A-3 K Vertex

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

题目描述

Given a directed graph, a K-vertex is a vertex of which the out degree is larger than the indegree. For example, the vertices a and b in the figure are K-vertices.

Your job is to list all the K-vertices in a given graph.

输入格式

Each input file contains one test case. For each case, the first line contains 2 positive integers: NN (200\le 200) and MM, which are the number of vertices and the number of edges, respectively. Then MM lines follow, each gives a directed edge < v1 , v2 > in the format:

v1 v2

Here we assume that all the vertices are numbered from 00 to N1N-1. It is guaranteed that v1 is never the same as v2.

Finally a line of NN strings is given, where the ii-th string corresponds to the key of the ii-th vertex (i=0,,N1i=0, \cdots , N-1). Each string consists of no more than 2 lower-cased English letters.

输出格式

Output the keys of all the K-vertices, each occupies a line, in alphabetical order. It is guaranteed that there is at least one output.

样例

4 5
0 1
2 1
3 1
2 0
3 2
c d b a
a
b

限制

Java (javac) 时间限制 900 ms 内存限制 256 MB

其他编译器 时间限制 400 ms 内存限制 64 MB

PAT2023春季重现赛

未参加
状态
已结束
规则
IOI
题目
9
开始于
2025-11-30 18:30
结束于
2025-11-30 22:00
持续时间
3.5 小时
主持人
参赛人数
71