$O(n)$
#include<cstdio> int n, m, a[501], b[501], c[501] = { 1 }, r; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d %d", a + i, b + i); scanf("%d", &m); for (int i = 0, x; i < m; i++) scanf("%d", &x), c[x] = 1; for (int i = 1; i <= n; i++) r += !c[i] & !c[a[i]] & !c[b[i]]; printf("%d", r); return 0; }
댓글 없음 :
댓글 쓰기