求调
查看原帖
求调
1034661
no_oier楼主2024/4/25 21:14
#include <iostream>
#include <vector>
using namespace std;

int main () {
    int q;
    cin >> q;
    
    for (int i = 0; i < q; ++i) {
        int k = 0, res = -1;
        int n, m;
        cin >> n >> m;
        vector<bool> a(n + 1, false);
        for (int j = 1; j <= m; ++j) {
            int t, x;
            cin >> t >> x;
            if (t == 1) {
                if (a[x] == false) {
                    a[x] = true;
                    k++;
                }
            }
            if (t == 2) {
                for (int i = 1; i <= n; ++i) {
                    if (i == x) {
                        continue;
                    } else {
                        if (a[i] == false) {
                            a[i] = true;
                            k++;
                        } 
                    }
                }
            }
            if (k == n) {
                res = j;
                break;
            }
        }
        cout << res << endl;
    } 
    
    return 0;
}
2024/4/25 21:14
加载中...