1134. Vertex Cover (25)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1134. Vertex Cover (25)相关的知识,希望对你有一定的参考价值。

稍微做一点点手脚就不会超时了。。。还是挺简单的,考试时候也做出来了。。。

#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

const int inf = 99999999;

int main() {
    
    int v, e;
    cin >> v >> e;
    int check[10001];
    vector<int> m1[10001];

    for (int i = 0; i < e; i++) {
        int n1, n2;
        cin >> n1 >> n2;

        m1[n1].push_back(i);
        m1[n2].push_back(i);
    }

    int num;
    cin >> num;

    for (int i = 0; i < num; i++) {
        fill(check, check + 10001, 0);

        int n;
        cin >> n;
        for (int j = 0; j < n; j++) {
            int k;
            cin >> k;
            for (int p = 0; p < m1[k].size(); p++) {
                check[m1[k][p]] = 1;
            }
        }
        bool f = 1;
        for (int q = 0; q < e; q++) {
            if (check[q] == 0) {
                f = 0;
                break;
            }
        }


        if (f == 0) {
            cout << "No" << endl;
        }

        else {
            cout << "Yes" << endl;
        }
    }

    system("pause");
}

 

以上是关于1134. Vertex Cover (25)的主要内容,如果未能解决你的问题,请参考以下文章

1134. Vertex Cover (25)

PAT Advanced 1134 Vertex Cover (25) [hash散列]

1134 Vertex Cover (25 分)难度: 一般 / 知识点: 模拟

PAT甲级1134 Vertex Cover (25分)

PAT 1134 Vertex Cover

1134 Vertex Cover