162012025-04-14 16:56:02algoproKét csoportcpp17Wrong answer 15/100184ms18996 KiB
// UUID: 1074045e-0335-4ce7-9fda-d9bd187e9b06
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300'001;

int col[MAXN];
vector<int> g[MAXN];

void solve() {
    int n; cin >> n;
    fill(col, col+MAXN, 0);
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        while (x) {
            g[i].emplace_back(x);
            cin >> x;
        }
    }

    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j : g[i]) {
            if (col[i] == col[j]) cnt++;
        }
        if (cnt > 1) col[i] ^= 1;
    }
    cout << count(col+1, col+n+1, 0) << "\n";
    for (int i = 1; i <= n; i++) {
        if (col[i] == 0) cout << i << " ";
    }
    cout << "\n";
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/100
1Accepted0/07ms8500 KiB
2Wrong answer0/056ms12080 KiB
3Accepted3/38ms8500 KiB
4Accepted3/38ms8500 KiB
5Accepted3/38ms8500 KiB
6Accepted3/38ms8500 KiB
7Accepted3/38ms8500 KiB
8Wrong answer0/27ms8692 KiB
9Wrong answer0/38ms8500 KiB
10Wrong answer0/39ms8500 KiB
11Wrong answer0/38ms8512 KiB
12Wrong answer0/313ms8756 KiB
13Wrong answer0/312ms8980 KiB
14Wrong answer0/313ms8756 KiB
15Wrong answer0/659ms12084 KiB
16Wrong answer0/759ms11832 KiB
17Wrong answer0/763ms11840 KiB
18Wrong answer0/6111ms15608 KiB
19Wrong answer0/6114ms15408 KiB
20Wrong answer0/6122ms15152 KiB
21Wrong answer0/6163ms18996 KiB
22Wrong answer0/7168ms18992 KiB
23Wrong answer0/7180ms18768 KiB
24Wrong answer0/7184ms18740 KiB