Guest User

Untitled

a guest
Nov 6th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. //#pragma comment(linker, "/STACK:16777216")
  2. #include <fstream>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <iomanip>
  7. #include <complex>
  8. #include <math.h>
  9. #include <cmath>
  10. #include <cstring>
  11. #include <cstdio>
  12. #include <cassert>
  13. #include <set>
  14. #include <vector>
  15. #include <map>
  16. #include <queue>
  17. #include <deque>
  18. #include <stack>
  19. #include <algorithm>
  20. #include <bitset>
  21. #include <list>
  22.  
  23. using namespace std;
  24.  
  25. #define x first
  26. #define y second
  27. #define pb push_back
  28. #define mp make_pair
  29. #define all(a) (a).begin(), (a).end()
  30. #define rall(a) (a).rbegin(), (a).rend()
  31. #define sz(a) int((a).size())
  32. #define sqr(x) ((x)*(x))
  33. #define forn(i, n) for (int i = 0; i < int(n); i++)
  34. #define foreach(i, a) for (auto i : a)
  35. #define NAME "magic"
  36. #define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
  37. #define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
  38.  
  39. #define y0 sdkfaslhagaklsldk
  40. #define y1 aasdfasdfasdf
  41. #define yn askfhwqriuperikldjk
  42. #define j1 assdgsdgasghsf
  43. #define tm sdfjahlfasfh
  44. #define lr asgasgashqt
  45. #define free afdshjioeyqtw
  46. #define next qpowityqwopqw
  47. #define prev paoueoroill
  48.  
  49. typedef unsigned int unt;
  50. typedef long long ll;
  51. typedef unsigned long long ull;
  52. typedef long double ld;
  53. typedef pair < int, int > pii;
  54. typedef pair < ll, ll > pll;
  55.  
  56. const ll MOD = 1e9 + 7;
  57. const int INF = 1e9 + 1;
  58. const ll INF64 = 2e18;
  59. const ll T = 23525;
  60. const ll MD = 1623623452;
  61. const int N = 300011;
  62. const int M = 20010;
  63.  
  64. int n, m, x[N], y[N], color[N];
  65. ll z[N];
  66. vector < pii > g[N];
  67.  
  68. int main() {
  69. FREOPEN;
  70. ios::sync_with_stdio(0);
  71. cin >> n >> m;
  72. forn(i, m) {
  73. cin >> x[i] >> y[i] >> z[i];
  74. g[x[i]].pb(mp(y[i], z[i]));
  75. g[y[i]].pb(mp(x[i], z[i]));
  76. }
  77. for (int v = 1; v <= n; v++) {
  78. ll s1 = 0, s2 = 0;
  79. foreach(u, g[v]) {
  80. if (color[u.x] == color[v])
  81. s1 += u.y;
  82. else
  83. s2 += u.y;
  84. }
  85. if (s1 > s2)
  86. color[v] = 1 - color[v];
  87. }
  88. for (int i = 1; i <= n; i++)
  89. cout << color[i] << ' ';
  90. return 0;
  91. }
  92.  
  93. /*
  94.  
  95.  
  96.  
  97. */
Advertisement
Add Comment
Please, Sign In to add comment