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> mp;
void read() {
cin >> n;
cin >> t;
for (int i = 0; i < n; ++i) {
int a, b;
cin >> a >> b;
mp[{a, b}] = i + 1;
}
}
pair<int, int> dir[8] {
{-1, -1},
{-1, 0},
{-1, 1},
{0, -1},
{0, 1},
{1, -1},
{1, 0},
{1, 1}
};
void solve1() {
int cnt = 0;
queue<pair<int, int>> q;
set<pair<int, int>> bio;
vector<int> ans;
q.emplace(mp.begin()->first);
while (!q.empty()) {
auto p = q.front();
q.pop();
++cnt;
ans.push_back(mp[p]);
bio.emplace(p);
for (auto &[dx, dy] : dir) {
auto np = p;
np.first += dx;
np.second += dy;
if (!bio.count(np) && mp.count(np)) {
q.emplace(np);
bio.emplace(np);
}
}
}
if (cnt != n) cout << "NO\n";
else {
cout << "YES\n";
for (auto a : ans) cout << a << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
read();
if (t == 1) {
solve1();
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |