This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
map<int, vector<int> > x, y;
for (int i = 0; i < n; i++) {
int foo, bar;
cin >> foo >> bar;
x[bar].emplace_back(i + 1);
y[foo].emplace_back(i + 1);
assert( (int) x[bar].size() <= 2);
assert( (int) y[foo].size() <= 2);
}
auto solve = [&] (const map<int, vector<int>> &where) {
int valid = 0;
for (auto to : where) valid += ((int)to.second.size() == 2);
if (valid == n / 2) {
cout << "DA\n";
for (auto to : where) {
cout << to.second[0] << ' ' << to.second[1] << '\n';
}
return true;
}
return false;
};
if (!solve(x) && !solve(y)) cout << "NE" << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |