Submission #518584

#TimeUsernameProblemLanguageResultExecution timeMemory
518584MonarchuwuBuilding Skyscrapers (CEOI19_skyscrapers)C++17
0 / 100
19 ms1612 KiB
#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)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:25:9: warning: unused variable 'i' [-Wunused-variable]
   25 |     int i = 1, j;
      |         ^
skyscrapers.cpp:25:16: warning: unused variable 'j' [-Wunused-variable]
   25 |     int i = 1, j;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...