CODE FESTIVAL 2016 Final

Submission #5474239

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<ll>> tree;
bool visit[10101];
bool white[10101];
vector<vector<ll>> length;

void dfs(int n,int sum){
    if(visit[n]) return;
    visit[n]=true;
    for(int i=0;i<tree[n].size();i++){
        sum+=length[n][tree[n][i]];
        //cout<<tree[n][i]<<":"<<sum<<endl;
        //cout<<sum<<endl;
        if(sum%2==0) white[tree[n][i]]=true;
        dfs(tree[n][i],sum);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    tree.resize(N+1);
    length.assign(N+1,vector<ll>(N+1));

    REP(i,N-1){
        visit[i]=false;
        ll u,v,w;
        cin>>u>>v>>w;
        tree[u-1].push_back(v-1);
        //tree[v-1].push_back(u-1);
        length[u-1][v-1]=length[u-1][v-1]=w;
    }
    white[0]=true;
    dfs(0,0);
    REP(i,N){
        if(white[i]) cout<<0<<endl;
        else cout<<1<<endl;
    }
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 Bondo416
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 1712 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 700 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,01-11.txt,01-12.txt,01-13.txt,01-14.txt,01-15.txt,01-16.txt,01-17.txt,01-18.txt,01-19.txt,01-20.txt,01-21.txt,01-22.txt,01-23.txt,01-24.txt,01-25.txt,01-26.txt,01-27.txt,01-28.txt,01-29.txt,01-30.txt,sample-01.txt,sample-02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt RE
01-02.txt RE
01-03.txt RE
01-04.txt RE
01-05.txt RE
01-06.txt RE
01-07.txt RE
01-08.txt TLE
01-09.txt RE
01-10.txt RE
01-11.txt RE
01-12.txt RE
01-13.txt RE
01-14.txt RE
01-15.txt RE
01-16.txt RE
01-17.txt RE
01-18.txt RE
01-19.txt RE
01-20.txt RE
01-21.txt RE
01-22.txt RE
01-23.txt RE
01-24.txt RE
01-25.txt RE
01-26.txt RE
01-27.txt RE
01-28.txt RE
01-29.txt RE
01-30.txt RE
sample-01.txt RE
sample-02.txt RE