#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);
}
}
ll c = 0;
map <pair <ll, ll>, bool> vis, exist;
priority_queue <pair <ll, ll>> pq;
void bfs(ll x, ll y)
{
pq.push({x, y});
while (pq.size())
{
c++;
x = pq.top().f, y = pq.top().s;
vis[{x, y}] = true;
pq.pop();
if (exist[{x + 1, y}] && !vis[{x + 1, y}]) pq.push({x + 1, y});
if (exist[{x - 1, y}] && !vis[{x - 1, y}]) pq.push({x - 1, y});
if (exist[{x, y + 1}] && !vis[{x, y + 1}]) pq.push({x, y + 1});
if (exist[{x, y - 1}] && !vis[{x, y - 1}]) pq.push({x, y - 1});
if (exist[{x + 1, y + 1}] && !vis[{x + 1, y + 1}]) pq.push({x + 1, y + 1});
if (exist[{x + 1, y - 1}] && !vis[{x + 1, y - 1}]) pq.push({x + 1, y - 1});
if (exist[{x - 1, y + 1}] && !vis[{x - 1, y + 1}]) pq.push({x - 1, y + 1});
if (exist[{x - 1, y - 1}] && !vis[{x - 1, y - 1}]) pq.push({x - 1, y - 1});
}
}
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);
map <pair <ll, ll>, ll> mp;
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.rbegin(), a.rend());
bfs(a[0].f, a[0].s);
if (vis.size() != n)
{
cout << "NO";
return 0;
}
cout << "YES" << newl;
for (auto v : a) cout << mp[v] << newl;
//cout << 1;
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:73:20: warning: comparison of integer expressions of different signedness: 'std::map<std::pair<long long int, long long int>, bool>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
73 | if (vis.size() != n)
| ~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
1 ms |
300 KB |
Full cells must be connected |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
1 ms |
300 KB |
Full cells must be connected |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
1 ms |
300 KB |
Full cells must be connected |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
616 KB |
ans=NO N=1934 |
2 |
Correct |
3 ms |
596 KB |
ans=NO N=1965 |
3 |
Execution timed out |
3578 ms |
525988 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Incorrect |
1 ms |
300 KB |
Full cells must be connected |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3576 ms |
272460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
616 KB |
ans=NO N=1934 |
2 |
Correct |
3 ms |
596 KB |
ans=NO N=1965 |
3 |
Execution timed out |
3578 ms |
525988 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |