CODE FESTIVAL 2016 Final

Submission #5445744

Source codeソースコード

#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

Task問題 C - Interpretation
User nameユーザ名 Bondo416
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1486 Byte
File nameファイル名
Exec time実行時間 31 ms
Memory usageメモリ使用量 8440 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 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