# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93528 | Sa1loum | Norela (info1cup18_norela) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)1e5+10;
int n,m,x,a[100],q[100][100],num[100];
string s;
string to_string(int n){
string t;
t.clear();
int x=10;
while (n%x) {
t+=(char)(n%x+'0');
n/=x;
}
reverse(t.begin(),t.end());
t+=" ";
return t;
}
bool possible(int a[100],int i) {
/*
for (int k=0;k<num[i];k++) {
a[q[i][k]]++;
}*/
int p=1;
for (int l=1;l<=n;l++) {
if (a[l]%2==0) p=0;
}
if (p) return 1;
for (int j=i;j<m;j++) {
s+=to_string(j+1);
for (int k=0;k<num[j];k++) {
a[q[j][k]]++;
}
if (possible(a,j+1)) {
return 1;
}
else {
s.pop_back();
while (s[s.size()-1]!=' ') s.pop_back();
for (int k=0;k<num[j];k++) {
a[q[j][k]]--;
}
}
}
return 0;
}
int main()
{
s.clear();
s+=" ";
scanf("%d%d",&n,&m);
for (int i=0;i<m;i++) {
cin>>num[i];
for (int j=0;j<num[i];j++) {
cin>>q[i][j];
}
}
for (int i=0;i<m;i++) {
if (possible(a,i)) {
cout<<s;
return 0;
}
s.clear();
}
}