# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660310 | 600Mihnea | Building Skyscrapers (CEOI19_skyscrapers) | C++17 | 121 ms | 6560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
bool home = 0;
#include <bits/stdc++.h>
using namespace std;
struct T
{
int x;
int y;
};
bool operator < (T a, T b)
{
if (a.x != b.x)
{
return a.x < b.x;
}
return a.y < b.y;
}
const int N = 150000 + 7;
int n;
int task;
T points[N];
bool vis[N];
map<T, int> w;
int main()
{
if (home == 0)
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
else
{
freopen ("input.txt", "r", stdin);
}
cin >> n >> task;
assert(task == 1 || task == 2);
for (int i = 1; i <= n; i++)
{
cin >> points[i].x >> points[i].y;
w[points[i]] = i;
}
vector<int> ord;
int start = 1;
queue<int> q;
q.push(start);
vis[start] = 1;
while (!q.empty())
{
int a = q.front();
ord.push_back(a);
q.pop();
for (int dx = -1; dx <= +1; dx++)
{
for (int dy = -1; dy <= +1; dy++)
{
T nw = {points[a].x + dx, points[a].y + dy};
if (w.count(nw))
{
int j = w[nw];
if (vis[j] == 0)
{
vis[j] = 1;
q.push(j);
}
}
}
}
}
if ((int) ord.size() != n)
{
cout << "NO\n";
return 0;
}
cout << "YES\n";
for (auto &v : ord)
{
cout << v << "\n";
}
return 0;
}
Compilation message (stderr)
# | 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... |