Submission #5474239
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<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 Info
Submission Time |
|
Task |
D - Pair Cards |
User |
Bondo416 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1712 Byte |
Status |
RE |
Exec Time |
2632 ms |
Memory |
86900 KB |
Judge Result
Set Name |
sample |
all |
Score / Max Score |
0 / 0 |
0 / 700 |
Status |
|
|
Set Name |
Test Cases |
sample |
sample-01.txt, sample-02.txt |
all |
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 |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
RE |
97 ms |
256 KB |
01-02.txt |
RE |
1800 ms |
-675392 KB |
01-03.txt |
RE |
1732 ms |
-675612 KB |
01-04.txt |
RE |
1930 ms |
-675496 KB |
01-05.txt |
RE |
1686 ms |
-675488 KB |
01-06.txt |
RE |
1982 ms |
-675600 KB |
01-07.txt |
RE |
1952 ms |
-675488 KB |
01-08.txt |
TLE |
2632 ms |
-675484 KB |
01-09.txt |
RE |
2064 ms |
-675360 KB |
01-10.txt |
RE |
1784 ms |
-675224 KB |
01-11.txt |
RE |
1785 ms |
-675020 KB |
01-12.txt |
RE |
2057 ms |
-674988 KB |
01-13.txt |
RE |
1874 ms |
-674844 KB |
01-14.txt |
RE |
1707 ms |
-675184 KB |
01-15.txt |
RE |
1785 ms |
-675112 KB |
01-16.txt |
RE |
1791 ms |
-675108 KB |
01-17.txt |
RE |
1975 ms |
-675048 KB |
01-18.txt |
RE |
1719 ms |
-675108 KB |
01-19.txt |
RE |
1690 ms |
-675132 KB |
01-20.txt |
RE |
1787 ms |
-675132 KB |
01-21.txt |
RE |
1844 ms |
-674984 KB |
01-22.txt |
RE |
1777 ms |
-675000 KB |
01-23.txt |
RE |
2037 ms |
-674968 KB |
01-24.txt |
RE |
1783 ms |
-675080 KB |
01-25.txt |
RE |
1691 ms |
-675016 KB |
01-26.txt |
RE |
1786 ms |
-675164 KB |
01-27.txt |
RE |
1791 ms |
-675036 KB |
01-28.txt |
RE |
454 ms |
86900 KB |
01-29.txt |
RE |
99 ms |
2816 KB |
01-30.txt |
RE |
98 ms |
256 KB |
sample-01.txt |
RE |
96 ms |
256 KB |
sample-02.txt |
RE |
96 ms |
256 KB |