#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 1e5 + 100;
#define int long long
int x[MAXN], y[MAXN];
set<pair<int,int>> active;
vector<pair<int,int>> ans, P[MAXN];
void check() {
for (int i = 1; i < MAXN; i++) {
if (P[i].size() == 2) {
int x1 = P[i][0].f, x2 = P[i][1].f;
auto u = active.lower_bound({x1, 0});
auto v = active.lower_bound({x2, 1e9});
if (u == v)
ans.push_back({P[i][0].s, P[i][1].s});
else {
auto P1 = active.lower_bound({x1, 0});
auto P2 = active.lower_bound({x2, 0});
if (P1 != active.end() && (*P1).f == x1) {
ans.push_back({P[i][0].s, (*P1).s});
active.erase(P1);
} else
active.insert({x1, P[i][0].s});
if (P2 != active.end() && (*P2).f == x2) {
ans.push_back({P[i][1].s, (*P2).s});
active.erase(P2);
} else
active.insert({x2, P[i][1].s});
}
} else if (P[i].size() == 1) {
int x1 = P[i][0].f;
auto P1 = active.lower_bound({x1, 0});
if (P1 != active.end() && (*P1).f == x1) {
ans.push_back({P[i][0].s, (*P1).s});
active.erase(P1);
} else
active.insert({x1, P[i][0].s});
}
}
if (active.size())
return ;
cout << "DA\n";
for (auto u : ans)
cout << u.f << " " << u.s << "\n";
exit(0);
}
signed main() {
fast;
int N;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> x[i] >> y[i];
P[x[i]].push_back({y[i], i+1});
}
check();
active.clear();
ans.clear();
for (int i = 0; i < MAXN; i++)
P[i].clear();
for (int i = 0; i < N; i++)
P[y[i]].push_back({x[i], i+1});
check();
cout << "NE\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
2 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
2 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Incorrect |
2 ms |
2908 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
2 ms |
2652 KB |
Output is correct |
11 |
Correct |
2 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Incorrect |
2 ms |
2908 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |