Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int64_t inf = 1000 * 1000 * 1000;
  6. int64_t inf64 = inf * inf;
  7. int64_t mod = 228228227;
  8. int64_t nll = 0;
  9.  
  10. #define se second
  11. #define fi first
  12.  
  13. int32_t main() {
  14. ios_base::sync_with_stdio(false);
  15. cin.tie(NULL);
  16. cout.tie(NULL);
  17. cerr << fixed << setprecision(8);
  18. srand(time(0));
  19. auto START_TIME = chrono::high_resolution_clock::now();
  20.  
  21. map<int64_t, map<int64_t, vector<pair<int64_t, int64_t> > > > mp;
  22. int32_t n;
  23. cin >> n;
  24. for (int32_t i = 0; i < n; ++i)
  25. {
  26. int32_t a, b, c;
  27. cin >> a >> b >> c;
  28. mp[c][b].emplace_back(a, i + 1);
  29. }
  30. vector<int64_t> ans;
  31. for (auto &c : mp)
  32. {
  33. for (auto &cc : c.se)
  34. {
  35. cout << "Z:" << c.fi << " Y:" << cc.fi << ": ";
  36. sort(cc.se.begin(), cc.se.end());
  37. for (int32_t i = 0; i < cc.se.size(); ++i)
  38. {
  39. cout << "(" << cc.se[i].fi << " " << cc.se[i].se << ") ";
  40. //ans.push_back(cc.se[i].se);
  41. }
  42. while (cc.se.size() > 1)
  43. {
  44. ans.emplace_back(cc.se.back().se);
  45. cc.se.pop_back();
  46. ans.emplace_back(cc.se.back().se);
  47. cc.se.pop_back();
  48. }
  49. cout << endl;
  50. }
  51. }
  52. for (auto &c : mp)
  53. {
  54. for (auto &cc : c.se)
  55. {
  56. //cout << "Z:" << c.fi << " Y:" << cc.fi << ": ";
  57. sort(cc.se.begin(), cc.se.end());
  58. for (int32_t i = 0; i < cc.se.size(); ++i)
  59. {
  60. //cout << "(" << cc.se[i].fi << " " << cc.se[i].se << ") ";
  61. ans.push_back(cc.se[i].se);
  62. }
  63. while (cc.se.size() > 1)
  64. {
  65. ans.emplace_back(cc.se.back().se);
  66. cc.se.pop_back();
  67. ans.emplace_back(cc.se.back().se);
  68. cc.se.pop_back();
  69. }
  70. //cout << endl;
  71. }
  72. }
  73. for (int32_t i = 0; i < n; i += 2)
  74. {
  75. cout << ans[i] << " " << ans[i + 1] << endl;
  76. }
  77.  
  78. cerr << endl << chrono::duration<long double>(chrono::high_resolution_clock::now() - START_TIME).count() << " sec.";
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement