Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#pragma comment(linker, "/STACK:16777216")
- #include <fstream>
- #include <stdio.h>
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <complex>
- #include <math.h>
- #include <cmath>
- #include <cstring>
- #include <cstdio>
- #include <cassert>
- #include <set>
- #include <vector>
- #include <map>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <algorithm>
- #include <bitset>
- #include <list>
- using namespace std;
- #define x first
- #define y second
- #define pb push_back
- #define mp make_pair
- #define all(a) (a).begin(), (a).end()
- #define rall(a) (a).rbegin(), (a).rend()
- #define sz(a) int((a).size())
- #define sqr(x) ((x)*(x))
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- #define foreach(i, a) for (auto i : a)
- #define NAME "magic"
- #define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
- #define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
- #define y0 sdkfaslhagaklsldk
- #define y1 aasdfasdfasdf
- #define yn askfhwqriuperikldjk
- #define j1 assdgsdgasghsf
- #define tm sdfjahlfasfh
- #define lr asgasgashqt
- #define free afdshjioeyqtw
- #define next qpowityqwopqw
- #define prev paoueoroill
- typedef unsigned int unt;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef pair < int, int > pii;
- typedef pair < ll, ll > pll;
- const ll MOD = 1e9 + 7;
- const int INF = 1e9 + 1;
- const ll INF64 = 2e18;
- const ll T = 23525;
- const ll MD = 1623623452;
- const int N = 300011;
- const int M = 20010;
- int n, m, x[N], y[N], color[N];
- ll z[N];
- vector < pii > g[N];
- int main() {
- FREOPEN;
- ios::sync_with_stdio(0);
- cin >> n >> m;
- forn(i, m) {
- cin >> x[i] >> y[i] >> z[i];
- g[x[i]].pb(mp(y[i], z[i]));
- g[y[i]].pb(mp(x[i], z[i]));
- }
- for (int v = 1; v <= n; v++) {
- ll s1 = 0, s2 = 0;
- foreach(u, g[v]) {
- if (color[u.x] == color[v])
- s1 += u.y;
- else
- s2 += u.y;
- }
- if (s1 > s2)
- color[v] = 1 - color[v];
- }
- for (int i = 1; i <= n; i++)
- cout << color[i] << ' ';
- return 0;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment