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 N, T;
map<pair<int, int>, int> P;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> T;
for (int i = 0, r, c; i < N; ++i) {
cin >> r >> c;
P.insert({{ r, c }, i });
}
if (T == 1) {
vector<int> s;
map<pair<int, int>, int> candidates;
candidates.insert(*P.begin());
P.erase(P.begin());
while (!candidates.empty()) {
auto node = *candidates.begin();
candidates.erase(candidates.begin());
s.push_back(node.second);
for (int i = -1; i <= 1; ++i) {
for (int j = -1; j <= 1; ++j) {
if (i == 0 && j == 0) {
continue;
}
auto it = P.find({ node.first.first + i, node.first.second + j });
if (it != P.end()) {
candidates.insert(*it);
P.erase(it);
}
}
}
}
if (!P.empty()) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
for (const auto& i : s) {
cout << (i + 1) << endl;
}
}
}
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |