Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1.  
  2.  
  3. int n, m, h;
  4. bool usm[200][200], ush[200][200];
  5. piii mx[MAXN], mn;
  6.  
  7. int cnt[MAXN];
  8.  
  9. piii con(int i, int j, int k)
  10. {
  11.     return { i, {j, k} };
  12. }
  13.  
  14. int main()
  15. {
  16.     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  17.     cout.precision(7);
  18.     srand(89398);
  19. #ifdef _DEBUG
  20.     auto _ = freopen("input.txt", "r", stdin);
  21.     _ = freopen("output.txt", "w", stdout);
  22. #else
  23.     //freopen("input.txt", "r", stdin);
  24.     //freopen("output.txt", "w", stdout);
  25.     //freopen("chess.in", "r", stdin);
  26.     //freopen("chess.out", "w", stdout);
  27. #endif
  28.     cin >> n;
  29.     itn m = n * (n - 1) / 2;
  30.  
  31.     for (int i = 0; i < m; i++)
  32.     {
  33.         cin >> mx[i].yy.xx >> mx[i].yy.yy >> mx[i].xx;
  34.         mx[i].yy.xx--;
  35.         mx[i].yy.yy--;
  36.     }
  37.     sort(mx, mx + n);
  38.     reverse(mx, mx + n);
  39.     for (int i = 0; i < n; i++)
  40.         cnt[i] = n - 1;
  41.     ll ans = 0;
  42.     for (int i = 0; i < m; i++)
  43.     {
  44.         cnt[mx[i].yy.xx]--;
  45.         cnt[mx[i].yy.yy]--;
  46.         ans += mx[i].xx * ((cnt[mx[i].yy.xx]) % 2 + (cnt[mx[i].yy.yy]) % 2);
  47.         cout << ans << "  " << mx[i].xx << " " << mx[i].yy.xx << " " << mx[i].yy.yy << "\n";
  48.     }
  49.     cout << ans;
  50. }
  51.  
  52. 8  4 3 4
  53. 16  4 0 2
  54. 20  4 0 1
  55. 20  3 2 1
  56. 22  2 2 4
  57. 25  3 0 3
  58. 29  2 3 1
  59. 33  4 0 4
  60. 33  4 4 1
  61. 33  2 2 3
  62. 33
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement