#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define int long long
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using oms = tree<
pair<int,int>,
null_type,
less<pair<int,int>>,
rb_tree_tag,
tree_order_statistics_node_update
>;
*/
#define f first
#define s second
const int N = 4e5 + 10;
int lcm(int a,int b){
return (a*b)/(__gcd(a,b));
}
void solve(){
int n,k;
cin >> n >> k;
vector < vector < bool > > v(n + 1,vector <bool> (n + 1));
for(int i = 1;i <= n;i++){
int x;
cin >> x;
for(int j = 1;j <= x;j++){
int xx;
cin >> xx;
v[i][xx+1] = 1;
}
}
bool b = 0;
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
if(v[i][j] == 1 && v[j][i] == 1){
b = 1;
break;
}
}
}
if(b)cout<<"2";
else cout << '1';
}
signed main(){
// freopen("guard.in","r",stdin);
// freopen("guard.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
//cin >> tt;
while(tt--){
solve();
cout << '\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |