CODE FESTIVAL 2016 Final

Submission #992604

Source codeソースコード

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)
using namespace std;

#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

void search(vector<vector<int>> &G, vector<bool> &visited, int i) {
  visited[i] = true;
  REP(j, G[i].size()) {
    if (!visited[G[i][j]]) {
      search(G, visited, G[i][j]);
    }
  }
}

// 二乗を計算する。
int sq(int x) { return x * x; }
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> L(N);
  vector<set<int>> speaker(M + 1);
  REP(i, N) {
    int K;
    cin >> K;
    L[i].resize(K);
    REP(j, K) {
      cin >> L[i][j];
      speaker[L[i][j]].insert(i);
    }
  }
  vector<vector<int>> G(N);
  REP(i, N) {
    set<int> pre;
    REP(j, L[i].size()) {
      for(auto k : speaker[L[i][j]]) {
        pre.insert(k);
      }
    }
    for (auto j : pre) {
      G[i].push_back(j);
    }
  }

  vector<bool> visited(N, false);
  search(G, visited, 0);
  bool ok = true;
  REP(i, N) {
    if (!visited[i]) ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;

  return 0;
}

Submission

Task問題 C - Interpretation
User nameユーザ名 StoneDot
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 200
Source lengthソースコード長 1434 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 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 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 AC 2 ms 256 KB
01-02.txt AC 3 ms 384 KB
01-03.txt AC 3 ms 384 KB
01-04.txt AC 44 ms 3456 KB
01-05.txt AC 4 ms 384 KB
01-06.txt AC 3 ms 384 KB
01-07.txt AC 3 ms 384 KB
01-08.txt AC 3 ms 384 KB
01-09.txt AC 3 ms 384 KB
01-10.txt AC 82 ms 4480 KB
02-01.txt AC 74 ms 11136 KB
02-02.txt AC 1026 ms 67200 KB
02-03.txt AC 86 ms 9984 KB
02-04.txt AC 105 ms 16256 KB
02-05.txt AC 199 ms 20736 KB
02-06.txt AC 103 ms 16128 KB
02-07.txt AC 195 ms 19840 KB
02-08.txt TLE
02-09.txt TLE
02-10.txt TLE
02-11.txt TLE
02-12.txt TLE
02-13.txt TLE
sample-01.txt AC 2 ms 256 KB
sample-02.txt AC 2 ms 256 KB