Submission #7927870


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX_N 100001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> Gh[MAX_N],Gl[MAX_N];
ll n,m,used_l[MAX_N]={},used_h[MAX_N]={};
void search_human(ll v);
void search_lang(ll v);

void search_human(ll v){
  if(used_h[v]){
    return;
  }
  used_h[v]=true;
  for(int i=0;i<Gh[v].size();i++){
    search_lang(Gh[v][i]);
  }
}
void search_lang(ll v){
  if(used_l[v]){
    return;
  }
  used_l[v]=true;
  for(int i=0;i<Gl[v].size();i++){
    search_human(Gl[v][i]);
  }
}
signed main(){
  ll k,l;
  bool can=true;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> l;
      l--;
      Gh[i].push_back(l);
      Gl[l].push_back(i);
    }
  }
  search_human(0);
  for(int i=0;i<n;i++){
    if(used_h[i]==false){
      can=false;
      break;
    }
  }
  if(can){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}

Submission Info

Submission Time
Task C - Interpretation
User shop_one
Language C++14 (GCC 5.4.1)
Score 400
Code Size 997 Byte
Status
Exec Time 58 ms
Memory 9856 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
Test Cases sample-01.txt, sample-02.txt sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, sample-01.txt, sample-02.txt
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt 3 ms 4992 KB
01-02.txt 3 ms 4992 KB
01-03.txt 3 ms 4992 KB
01-04.txt 3 ms 4992 KB
01-05.txt 3 ms 4992 KB
01-06.txt 3 ms 4992 KB
01-07.txt 3 ms 4992 KB
01-08.txt 3 ms 4992 KB
01-09.txt 3 ms 4992 KB
01-10.txt 3 ms 4992 KB
02-01.txt 50 ms 9344 KB
02-02.txt 48 ms 9856 KB
02-03.txt 46 ms 8960 KB
02-04.txt 58 ms 9728 KB
02-05.txt 55 ms 9856 KB
02-06.txt 58 ms 9728 KB
02-07.txt 55 ms 9856 KB
02-08.txt 40 ms 9584 KB
02-09.txt 54 ms 9588 KB
02-10.txt 45 ms 9588 KB
02-11.txt 45 ms 9588 KB
02-12.txt 45 ms 9472 KB
02-13.txt 47 ms 9600 KB
sample-01.txt 3 ms 4992 KB
sample-02.txt 3 ms 4992 KB