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;
const int N = 2e5 + 5;
int n, x[N], y[N], vis[N];
vector<int> gx[N], gy[N];
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
gx[x[i]].push_back(i);
gy[y[i]].push_back(i);
}
for (int S = 0; S < (1 << n); ++S) {
vector<pair<int, int>> ex, ey;
fill_n(vis, n, 0);
for (int i = 0; i < n; ++i) if (S >> i & 1) {
if (gx[x[i]].size() == 1 || gx[x[i]][1] == i || vis[gx[x[i]][1]]) continue;
ex.emplace_back(i, gx[x[i]][1]), vis[i] = vis[gx[x[i]][1]] = 1;
} else {
if (gy[y[i]].size() == 1 || gy[y[i]][1] == i || vis[gy[y[i]][1]]) continue;
ey.emplace_back(i, gy[y[i]][1]), vis[i] = vis[gy[y[i]][1]] = 1;
}
if (count(vis, vis + n, 0)) continue;
for (auto EX: ex) {
int xx = x[EX.first], ly = min(y[EX.first], y[EX.second]), ry = max(y[EX.first], y[EX.second]);
for (auto EY: ey) {
int yy = y[EY.first], ux = min(x[EY.first], x[EY.second]), dx = max(x[EY.first], x[EY.second]);
if (xx >= ux && xx <= dx && yy >= ly && yy <= ry) {
goto fail;
}
}
}
puts("DA");
for (auto it: ex) cout << it.first + 1 << ' ' << it.second + 1 << '\n';
for (auto it: ey) cout << it.first + 1 << ' ' << it.second + 1 << '\n';
return 0;
fail:;
}
puts("NE");
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... |