Submission #993450


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

/* template {{{ */
/* vim: set foldmethod=marker: */
/* Roadagain {{{ */
/****************************************************************************************/
/*                                                                                      */
/*                                                                                      */
/*                                                                                      */
/*  /#######                            /##                               /##           */
/* | ##__  ##                          | ##                              |__/           */
/* | ##  \ ##  /######   /######   /#######  /######   /######   /######  /## /#######  */
/* | #######/ /##__  ## |____  ## /##__  ## |____  ## /##__  ## |____  ##| ##| ##__  ## */
/* | ##__  ##| ##  \ ##  /#######| ##  | ##  /#######| ##  \ ##  /#######| ##| ##  \ ## */
/* | ##  \ ##| ##  | ## /##__  ##| ##  | ## /##__  ##| ##  | ## /##__  ##| ##| ##  | ## */
/* | ##  | ##|  ######/|  #######|  #######|  #######|  #######|  #######| ##| ##  | ## */
/* |__/  |__/ \______/  \_______/ \_______/ \_______/ \____  ## \_______/|__/|__/  |__/ */
/*                                                    /##  \ ##                         */
/*                                                   |  ######/                         */
/*                                                    \______/                          */
/*                                                                                      */
/****************************************************************************************/
/* }}} */
/* constant {{{ */
const int    INF = (int)1e9;
const int    MOD = (int)1e9 + 7;
const double PI  = acos(-1);
const double EPS = 1e-14;
/* }}} */
/* alias {{{ */
template <class T> using vec = vector<T>;
using ll   = long long;
using ull  = unsigned long long;
using vi   = vec<int>;
using vl   = vec<ll>;
using vd   = vec<double>;
using pii  = pair<int, int>;
using pdd  = pair<double, double>;
using vec2 = complex<double>;
/* }}} */
/* repetition {{{ */
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPIT(i, obj) for (auto i = (obj).begin(); i != (obj).end(); ++i)
#define RREPIT(i, obj) for (auto i = (obj).rbegin(); i != (obj).rend(); ++i)
/* }}} */
/* short {{{ */
#define pb emplace_back
#define mp make_pair
#define fst first
#define sec second
/* }}} */
/* input {{{ */
template <class T = int> inline T in(){ T x; cin >> x; return x; }
template <class T = int> inline vec<T> in(int n){ vec<T> v(n); REP(i, n) v[i] = in<T>(); return v; }
template <class T = int> inline void in(T* x, int n){ REP(i, n) x[i] = in<T>(); }
#define inl in<ll>
#define ind in<double>
#define ins in<string>
/* }}} */
/* container util {{{ */
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLA(ary, n) (ary), ((ary) + (n))
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define SZ(obj) (obj).size()
#define SZA(ary) (sizeof(ary) / sizeof(*ary))
#define SORT(obj) sort(ALL(obj))
#define SORTA(ary, n) sort(ALLA(ary, n))
#define EXIST(obj, key) ((obj).find(key) != (obj).end())
#define CLEARY(ary) memset((ary), 0, sizeof(ary))
/* }}} */
/* print util {{{ */
template <class T> inline void print(const T& x){ cout << x << '\n'; }
template <class T> inline void printd(const T& x, int d){ cout << fixed << setprecision(d) << x << '\n'; }
template <class T> inline void printv(vec<T>& v){ int n = sz(v); REP(i, n) cout << v[i] << "\n "[i < n - 1]; }
template <class T> inline void printv(vec<T>& v, int n){ REP(i, n) cout << v[i] << "\n "[i < n - 1]; }
template <class T> inline void printa(T* ary, int n){ REP(i, n) cout << ary[i] << "\n "[i < n - 1]; }
#define DUMP(x) cerr << #x << ": " << (x) << '\n'
#define DEBUG(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << '\n'
/* }}} */
/* template }}} */

bool talked[10010];
bool reserved[10010];
set<int> lang[10010];
set<int> person[10010];
set<int> talkable;
queue<int> que;
set<int> tmp;

signed main()
{
    int n = in(), m = in();

    REP(i, n){
        int k = in();
        REP(j, k){
            int l = in();
            lang[l].insert(i);
            person[i].insert(l);
        }
    }

    for (int i : person[0]){
        que.push(i);
    }
    while (not que.empty()){
        int l = que.front();
        que.pop();

        if (talked[l]) continue;
        talked[l] = true;

        tmp.clear();
        // DEBUG(l);
        for (int i : lang[l]){
            // DEBUG(i);
            talkable.insert(i);
            for (int j : person[i]){
                // DEBUG(j);
                if (not reserved[j]){
                    tmp.insert(j);
                    reserved[j] = true;
                }
            }
        }
        // print("End");
        for (int i : tmp){
            que.push(i);
        }
        // print("Push end");
    }
    print(talkable.size() == n ? "YES" : "NO");

    return 0;
}

Submission Info

Submission Time
Task C - Interpretation
User ringoh72
Language C++14 (GCC 5.4.1)
Score 200
Code Size 5255 Byte
Status RE
Exec Time 123 ms
Memory 3456 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 0 / 200
Status
AC × 2
AC × 12
AC × 12
RE × 13
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
Case Name Status Exec Time Memory
01-01.txt AC 3 ms 1152 KB
01-02.txt AC 4 ms 1280 KB
01-03.txt AC 4 ms 1280 KB
01-04.txt AC 4 ms 1280 KB
01-05.txt AC 4 ms 1280 KB
01-06.txt AC 4 ms 1280 KB
01-07.txt AC 4 ms 1280 KB
01-08.txt AC 4 ms 1280 KB
01-09.txt AC 4 ms 1280 KB
01-10.txt AC 4 ms 1280 KB
02-01.txt RE 108 ms 1152 KB
02-02.txt RE 123 ms 3072 KB
02-03.txt RE 111 ms 1152 KB
02-04.txt RE 111 ms 1152 KB
02-05.txt RE 122 ms 3456 KB
02-06.txt RE 108 ms 1152 KB
02-07.txt RE 123 ms 3200 KB
02-08.txt RE 120 ms 3072 KB
02-09.txt RE 110 ms 1152 KB
02-10.txt RE 107 ms 1152 KB
02-11.txt RE 108 ms 1152 KB
02-12.txt RE 109 ms 1152 KB
02-13.txt RE 111 ms 1152 KB
sample-01.txt AC 3 ms 1152 KB
sample-02.txt AC 3 ms 1152 KB