169142025-05-15 18:09:34algoproKét csoportcpp17Wrong answer 15/100168ms19152 KiB
// UUID: b163f1d1-082a-40be-b774-5554b2fb636c
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define iter(v) v.begin(), v.end()
#define riter(v) v.rbegin(), v.rend()
#define gfor(start, end, step, var) for (int i = start; i < end; i += step)
#define v(type, name, size) vector<type> name(size)
#define vv(type, name, size1, size2) vector<vector<type>> name(size1, vector<type>(size2))
//#define int long long

signed main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vector<vector<int>> adj(n+1);
    vector<int> g(n+1);
    vector<int> bad;
    for(int i=1;i<=n;i++)
    {
        int a;
        int cnt=0;
        cin>>a;
        while(a)
        {
            adj[i].pb(a);
            if (i%2==a%2) cnt++;
            cin >> a;
        }
        if(cnt>=2) bad.pb(i);
        g[i] = i%2;
    }
    for(int i=0;i<bad.size();i++)
    {
        int cnt=0;
        int b = 0;
        for(int j : adj[i])
        {
            if(g[i] == g[j]) cnt++;
            else b = j;
        }
        if(cnt >= 2)
        {
            g[i] = !g[i];
            cnt = 0;
            for(int j : adj[b])
            {
                if(g[b] == g[j]) cnt++;
            }
            if(cnt>=2) bad.pb(b);
        }

    }

    cout << n/2 <<endl;
    for(int i=1;i<=n;i++)
    {
        if(g[i]) cout << i << " ";
    }

}
SubtaskSumTestVerdictTimeMemory
base15/100
1Accepted0/01ms316 KiB
2Wrong answer0/046ms6452 KiB
3Accepted3/31ms500 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/31ms316 KiB
12Wrong answer0/34ms844 KiB
13Wrong answer0/36ms820 KiB
14Wrong answer0/36ms820 KiB
15Wrong answer0/648ms6452 KiB
16Wrong answer0/750ms6624 KiB
17Wrong answer0/756ms6492 KiB
18Wrong answer0/694ms12808 KiB
19Wrong answer0/6104ms12652 KiB
20Wrong answer0/6111ms12772 KiB
21Wrong answer0/6143ms19024 KiB
22Wrong answer0/7157ms18996 KiB
23Wrong answer0/7168ms19120 KiB
24Wrong answer0/7165ms19152 KiB