Submission #349103

#TimeUsernameProblemLanguageResultExecution timeMemory
349103Sho10Norela (info1cup18_norela)C++17
100 / 100
104 ms512 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #define ll long long #define double long double #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define aint(a) (a).begin(), (a).end() #define f first #define s second #define pb push_back #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 1000000007 #define PI 3.14159265359 #define MAXN 100005 #define INF 1000000005 #define LINF 1000000000000000005ll #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll n,m,ans,sz=LINF,a[30]; void solve(ll nrcar,ll x,ll nrvraj,ll vraj){ if(x==m){ if(nrcar==(1ll<<n)-1){ if(sz>vraj){ sz=vraj; ans=nrvraj; } } return; } solve(nrcar^a[x],x+1,nrvraj^(1<<x),vraj+1); solve(nrcar,x+1,nrvraj,vraj); } int32_t main(){ CODE_START; cin>>n>>m; for(ll i=0;i<m;i++) { ll y; cin>>y; for(ll j=0;j<y;j++) { ll x; cin>>x; x--; a[i]^=(1ll<<x); } } solve(0,0,0,0); cout<<sz<<endl; for(ll i=0;i<m;i++) { if((1ll<<i)&ans){ cout<<i+1<<' '; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...