CODE FESTIVAL 2016 Final

Submission #992613

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i, N) {
    int K; cin >> K;
    rep(i, K) {
      int l; cin >> l;
      G[i].push_back(l - 1);
    }
  }

  queue<int> q;
  q.push(0);

  vector<int> dist(N, inf);

  while(!q.empty()) {
    auto p = q.front(); q.pop();
    for(auto e: G[p]) {
      if(dist[e] == inf) {
        dist[e] = dist[p] + 1;
        q.push(e);
      }
    }
  }

  bool ok = 1;
  rep(i, N) {
    ok &= dist[i] != inf;
  }

  cout << (ok ? "YES" : "NO") << endl;
  
  return 0;
}

Submission

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

Test case

Set

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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt WA
01-02.txt WA
01-03.txt AC 3 ms 256 KB
01-04.txt WA
01-05.txt AC 3 ms 256 KB
01-06.txt WA
01-07.txt WA
01-08.txt AC 3 ms 384 KB
01-09.txt WA
01-10.txt WA
02-01.txt WA
02-02.txt AC 43 ms 3448 KB
02-03.txt AC 33 ms 1152 KB
02-04.txt WA
02-05.txt WA
02-06.txt AC 42 ms 2364 KB
02-07.txt WA
02-08.txt AC 37 ms 3448 KB
02-09.txt WA
02-10.txt WA
02-11.txt AC 44 ms 3324 KB
02-12.txt WA
02-13.txt AC 39 ms 2176 KB
sample-01.txt WA
sample-02.txt AC 2 ms 256 KB