CODE FESTIVAL 2016 Final

Submission #7927870

Source codeソースコード

#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

Task問題 C - Interpretation
User nameユーザ名 shop_one
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 997 Byte
File nameファイル名
Exec time実行時間 58 ms
Memory usageメモリ使用量 9856 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
dataset1 200 / 200 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 200 / 200 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 3 ms 4992 KB
01-02.txt AC 3 ms 4992 KB
01-03.txt AC 3 ms 4992 KB
01-04.txt AC 3 ms 4992 KB
01-05.txt AC 3 ms 4992 KB
01-06.txt AC 3 ms 4992 KB
01-07.txt AC 3 ms 4992 KB
01-08.txt AC 3 ms 4992 KB
01-09.txt AC 3 ms 4992 KB
01-10.txt AC 3 ms 4992 KB
02-01.txt AC 50 ms 9344 KB
02-02.txt AC 48 ms 9856 KB
02-03.txt AC 46 ms 8960 KB
02-04.txt AC 58 ms 9728 KB
02-05.txt AC 55 ms 9856 KB
02-06.txt AC 58 ms 9728 KB
02-07.txt AC 55 ms 9856 KB
02-08.txt AC 40 ms 9584 KB
02-09.txt AC 54 ms 9588 KB
02-10.txt AC 45 ms 9588 KB
02-11.txt AC 45 ms 9588 KB
02-12.txt AC 45 ms 9472 KB
02-13.txt AC 47 ms 9600 KB
sample-01.txt AC 3 ms 4992 KB
sample-02.txt AC 3 ms 4992 KB