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, vis;
int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int main() {
// freopen("test.inp", "r", stdin);
ios :: sync_with_stdio(0); cin.tie(0);
cin >> n >> T;
vector <pair <int, int> > P;
int X = 0, Y = 0;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
mp[{x, y}] = i;
X = x, Y = y;
}
priority_queue <pair <int, int> > q;
q.push({X, Y});
vis[{X, Y}] = 1;
vector <int> ans;
while (q.size()) {
int x = q.top().first;
int y = q.top().second;
ans.push_back(mp[{x, y}]);
q.pop();
for (int i = 0; i < 8; ++i) {
int u = x + dx[i];
int v = y + dy[i];
if (mp.find({u, v}) == mp.end() || vis[{u, v}]) continue;
vis[{u, v}] = 1;
q.push({u, v});
}
}
if (ans.size() != n) {
cout << "NO\n";
exit(0);
}
cout << "YES\n";
for (int i = 0; i < ans.size(); ++i) cout << ans[i] << '\n';
}
Compilation message (stderr)
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | if (ans.size() != n) {
| ~~~~~~~~~~~^~~~
skyscrapers.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for (int i = 0; i < ans.size(); ++i) cout << ans[i] << '\n';
| ~~^~~~~~~~~~~~
# | 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... |