# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
518584 | Monarchuwu | Building Skyscrapers (CEOI19_skyscrapers) | C++17 | 19 ms | 1612 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.
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 2e5 + 8;
int n, t;
struct Point {
int x, y, id;
Point() {}
bool operator < (const Point &o) const {
return y < o.y;
}
} p[N];
int main() {
cin.tie(NULL)->sync_with_stdio(false);
cin >> n >> t;
for (int i = 1; i <= n; ++i)
cin >> p[i].x >> p[i].y, p[i].id = i;
sort(p + 1, p + n + 1);
int i = 1, j;
unordered_set<int> s1;
vector<int> ans;
for (int i = 1, j; i <= n; i = j + 1) {
if (i != 1 && p[i - 1].y + 1 != p[i].y) {
cout << "NO\n";
return 0;
}
j = i;
while (j < n && p[j + 1].y == p[i].y) ++j;
unordered_set<int> s2;
for (int k = i; k <= j; ++k) {
if (i == 1 || s1.count(p[i - 1].x) || s1.count(p[i].x) || s1.count(p[i + 1].x)) {
s2.insert(p[i].x);
ans.push_back(p[i].id);
}
else {
cout << "NO\n";
return 0;
}
}
s1.swap(s2);
}
cout << "YES\n";
for (int x : ans) cout << x << '\n';
}
/** /\_/\
* (= ._.)
* / >0 \>1
**/
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... |