This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 50000
vector<int> a[N];
map<int,int> x[N];
void solve(){
int n,m,o,p,q;
cin>>n>>m;
for(int i=o=0;i<n;i++){
cin>>p;
if(p>0) o=1;
while(p--){
cin>>q;
x[i][q]=1;
a[i].append(q);
}
}
for(int i=0;i<n;i++){
for(auto& j:a[i]){
for(auto& k:a[j]){
if(x[i][k]){
cout<<min(3,m);
return;
}
}
}
}
cout<<min(o+1,m);
}
int main(){
L0TA;
solve();
return 0;
}
# | 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... |