CODE FESTIVAL 2016 Final

Submission #5379476

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<int> G[100100];
vector<int> L[100100];
bool isvisit[100100];

void dfs(int v){
    isvisit[v] = true;
    //for(auto l : L[v]){
    //    for(auto next : G[l]) {
    for(int i = 0; i < L[v].size(); i++){
        int l = L[v][i];
        for(int j = 0; j < G[l].size(); j++) {
            int next = G[l][j];
            if(isvisit[next]) continue;
            dfs(next);
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    REP(i,N){
        int K;
        cin >> K;
        REP(j,K){
            int l;
            cin >> l;
            l--;
            L[i].push_back(l);
            G[l].push_back(i);
        }
    }

    dfs(0);

    bool ans = true;
    REP(i,N){
        if(!isvisit[i])
            ans = false;
    }

    if(ans)
        cout << "YES" << endl;
    else 
        cout << "NO" << endl;
    return 0;
}

Submission

Task問題 C - Interpretation
User nameユーザ名 kurakura
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 200
Source lengthソースコード長 1247 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,sample-01.txt,sample-02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 3 ms 4992 KB
01-02.txt AC 3 ms 4992 KB
01-03.txt AC 4 ms 4992 KB
01-04.txt AC 4 ms 4992 KB
01-05.txt AC 4 ms 4992 KB
01-06.txt AC 4 ms 4992 KB
01-07.txt AC 4 ms 4992 KB
01-08.txt AC 4 ms 4992 KB
01-09.txt AC 4 ms 4992 KB
01-10.txt AC 5 ms 4992 KB
02-01.txt AC 56 ms 7808 KB
02-02.txt AC 76 ms 12160 KB
02-03.txt AC 58 ms 7552 KB
02-04.txt AC 68 ms 8192 KB
02-05.txt AC 72 ms 10624 KB
02-06.txt AC 71 ms 8192 KB
02-07.txt AC 73 ms 8576 KB
02-08.txt TLE
02-09.txt TLE
02-10.txt TLE
02-11.txt TLE
02-12.txt AC 328 ms 9728 KB
02-13.txt AC 334 ms 9472 KB
sample-01.txt AC 3 ms 4992 KB
sample-02.txt AC 3 ms 4992 KB