Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int64_t inf = 1000 * 1000 * 1000;
- int64_t inf64 = inf * inf;
- int64_t mod = 228228227;
- int64_t nll = 0;
- #define se second
- #define fi first
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- cerr << fixed << setprecision(8);
- srand(time(0));
- auto START_TIME = chrono::high_resolution_clock::now();
- map<int64_t, map<int64_t, vector<pair<int64_t, int64_t> > > > mp;
- int32_t n;
- cin >> n;
- for (int32_t i = 0; i < n; ++i)
- {
- int32_t a, b, c;
- cin >> a >> b >> c;
- mp[c][b].emplace_back(a, i + 1);
- }
- vector<int64_t> ans;
- for (auto &c : mp)
- {
- for (auto &cc : c.se)
- {
- cout << "Z:" << c.fi << " Y:" << cc.fi << ": ";
- sort(cc.se.begin(), cc.se.end());
- for (int32_t i = 0; i < cc.se.size(); ++i)
- {
- cout << "(" << cc.se[i].fi << " " << cc.se[i].se << ") ";
- //ans.push_back(cc.se[i].se);
- }
- while (cc.se.size() > 1)
- {
- ans.emplace_back(cc.se.back().se);
- cc.se.pop_back();
- ans.emplace_back(cc.se.back().se);
- cc.se.pop_back();
- }
- cout << endl;
- }
- }
- for (auto &c : mp)
- {
- for (auto &cc : c.se)
- {
- //cout << "Z:" << c.fi << " Y:" << cc.fi << ": ";
- sort(cc.se.begin(), cc.se.end());
- for (int32_t i = 0; i < cc.se.size(); ++i)
- {
- //cout << "(" << cc.se[i].fi << " " << cc.se[i].se << ") ";
- ans.push_back(cc.se[i].se);
- }
- while (cc.se.size() > 1)
- {
- ans.emplace_back(cc.se.back().se);
- cc.se.pop_back();
- ans.emplace_back(cc.se.back().se);
- cc.se.pop_back();
- }
- //cout << endl;
- }
- }
- for (int32_t i = 0; i < n; i += 2)
- {
- cout << ans[i] << " " << ans[i + 1] << endl;
- }
- cerr << endl << chrono::duration<long double>(chrono::high_resolution_clock::now() - START_TIME).count() << " sec.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement