#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define db double
#define pb push_back
#define pf push_front
#define newl "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define MOD 1000000007
using namespace std;
#pragma GCC diagnostic ignored "-Wunused-result"
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(15);
if (name.size()) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
map <pair <ll, ll>, bool> vis, exist;
vector <ll> ans;
priority_queue <pair <ll, ll>, vector <pair <ll, ll>>, greater <pair <ll, ll>>> pq;
map <pair <ll, ll>, ll> mp;
void bfs(ll ii, ll jj)
{
pq.push({ii, jj});
vis[{ii, jj}] = true;
ans.pb(mp[{ii, jj}]);
while (pq.size())
{
ll x = pq.top().f, y = pq.top().s;
pq.pop();
for (ll i = x - 1; i <= x + 1; i++)
{
for (ll j = y - 1; j <= y + 1; j++)
{
if (exist[{i, j}] && !vis[{i, j}])
{
vis[{i, j}] = true;
pq.push({i, j});
}
}
}
ans.pb(mp[{x, y}]);
}
}
int main()
{
//fast
//setIO("");
//freopen("filename.in", "r", stdin);
//freopen("filename.out", "w", stdout);
ll n, t; cin >> n >> t;
vector <pair <ll, ll>> a(n);
for (ll i = 0; i < n; i++)
{
cin >> a[i].f >> a[i].s;
mp[a[i]] = i + 1;
exist[a[i]] = true;
}
sort(a.begin(), a.end());
bfs(a[0].f, a[0].s);
if (ans.size() < n)
{
cout << "NO" << newl;
return 0;
}
cout << "YES" << newl;
for (auto v : ans) cout << v << newl;
//cout << 1;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:76:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
76 | if (ans.size() < n)
| ~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
596 KB |
ans=NO N=1965 |
3 |
Incorrect |
5 ms |
724 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
17120 KB |
ans=NO N=66151 |
2 |
Correct |
99 ms |
9324 KB |
ans=NO N=64333 |
3 |
Incorrect |
205 ms |
15388 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
596 KB |
ans=NO N=1965 |
3 |
Incorrect |
5 ms |
724 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |