Submission #5445744


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
vector<vector<int>> edge;
vector<bool> visit;

void dfs(int n){
    if(visit[n]) return;
    visit[n]=true;
    for(int i=0;i<edge[n].size();i++){
        dfs(edge[n][i]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    edge.resize(N+M);
    REP(i,N){
        int k;cin>>k;
        edge[i].resize(k);
        REP(j,k){
            int l;cin>>l;
            l+=N-1;
            edge[i][j]=l;
            edge[l].push_back(i);
        }
    }
    visit.resize(N+M);
    dfs(0);
    REP(i,N) if(!visit[i]){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}

Submission Info

Submission Time
Task C - Interpretation
User Bondo416
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1486 Byte
Status AC
Exec Time 31 ms
Memory 8440 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 2
AC × 12
AC × 27
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 AC 1 ms 256 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 1 ms 384 KB
01-04.txt AC 1 ms 384 KB
01-05.txt AC 1 ms 384 KB
01-06.txt AC 1 ms 384 KB
01-07.txt AC 1 ms 256 KB
01-08.txt AC 1 ms 384 KB
01-09.txt AC 1 ms 384 KB
01-10.txt AC 1 ms 384 KB
02-01.txt AC 22 ms 5504 KB
02-02.txt AC 25 ms 6272 KB
02-03.txt AC 22 ms 4096 KB
02-04.txt AC 30 ms 7040 KB
02-05.txt AC 28 ms 6016 KB
02-06.txt AC 31 ms 7040 KB
02-07.txt AC 29 ms 6144 KB
02-08.txt AC 20 ms 6136 KB
02-09.txt AC 24 ms 8440 KB
02-10.txt AC 20 ms 6140 KB
02-11.txt AC 19 ms 6140 KB
02-12.txt AC 22 ms 6016 KB
02-13.txt AC 22 ms 6016 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB